php frage

hero1977

hero1977

Mitglied
Thread Starter
Dabei seit
19.06.2006
Beiträge
1.608
Reaktionspunkte
22
hallo,
ich fummle grad am xtcommerce shop rum und habe die "show_product_thumbs.php" jetzt so umgeschrieben, das da keine thumbnails mehr sind sondern das da textlinks stehen. in meinem fall "front" und "back". wenn jetzt ein drittes produktbild dazukommt heißt der link dann natürlich auch "back", der soll aber z.b. "top" heißen. kann mir einer erklären wie ich das mache?

?>
<body bgcolor="#FFFFFF">
<table align="center">
<tr>
<?

$mo_images = xtc_get_products_mo_images((int) $_GET['pID']);
if ((int) $_GET['imgID'] == 0)
$actual = ' bgcolor="#ffffff"';
else
unset ($actual);
echo '<td align="left" border="0" cellpadding="0" cellspacing="0"'.$actual.'>';
$products_query = xtc_db_query("select pd.products_name, p.products_image from ".TABLE_PRODUCTS." p left join ".TABLE_PRODUCTS_DESCRIPTION." pd on p.products_id = pd.products_id where p.products_status = '1' and p.products_id = '".(int) $_GET['pID']."' and pd.language_id = '".(int) $_SESSION['languages_id']."'");
$products_values = xtc_db_fetch_array($products_query);
echo '<a style="font-family: Verdana, Arial, sans-serif; color: #000000; font-size: 12px; font-weight:bold; text-decoration:none;" href="popup_image.php?pID='.(int) $_GET['pID'].'&imgID=0" target="_parent">'.front.'</a>';
echo '</td>';
echo '<td style="width:10px;">';
echo '</td>';
if ($mo_images != false) {
foreach ($mo_images as $mo_img) {
if ($mo_img['image_nr'] == (int) $_GET['imgID'])
$actual = ' bgcolor="#ffffff"';
else
unset ($actual);
echo '<td align=left'.$actual.'><a style="font-family: Verdana, Arial, sans-serif; color: #000000; font-size: 12px; font-weight:bold; text-decoration:none;" href="popup_image.php?pID='.(int) $_GET['pID'].'&imgID='.$mo_img['image_nr'].'" target="_parent">'.back.'</a></td>';
}
}

?>
</tr>
</table>
</body>
 
die anzahl der images mitzählen und dann statt dem foreach für die back ausgabe das entsprechend anders ausgeben...
 
und dann statt dem foreach für die back ausgabe das entsprechend anders ausgeben...

ja das hab ich mir auch so gedacht, aber wie setze ich das um? hab von PHP leider wenig ahnung ;) fummle die scripte manchmal irgendwie um, aber das da ist grad zu hoch für mich.
 
Die Frage ist, woher kommt der Text für den Link!
Wenn Du immer die selten Ansichten in der selben Reihenfolge hast, bietet es sich an, die Namen hierfür ein Array bereitzustellen, welches die Texte beinhaltet:

PHP:
$ansichtsnamen = array(
  0 => 'top';
  1 => 'back';
  2 => 'front';
  3 => 'left';
  4 => 'right';
  5 => 'bottom';
);

In der Schleife wird dann der Zähler ja immer erhöht, und als Schlüssel für den Zugriff auf das Array benutzt.

Oder Du benutzt Bilder, die Text enthalten, was dann die einfachste Lösung wäre :D
 
Die Frage ist, woher kommt der Text für den Link!

der ist hier:

echo '<a style="font-family: Verdana, Arial, sans-serif; color: #000000; font-size: 12px; font-weight:bold; text-decoration:none;" href="popup_image.php?pID='.(int) $_GET['pID'].'&imgID=0" target="_parent">'.front.'</a>';

und hier:

echo '<td align=left'.$actual.'><a style="font-family: Verdana, Arial, sans-serif; color: #000000; font-size: 12px; font-weight:bold; text-decoration:none;" href="popup_image.php?pID='.(int) $_GET['pID'].'&imgID='.$mo_img['image_nr'].'" target="_parent">'.back.'</a></td>';

der ist also schon da. jetzt fehlt nur noch top. die frage ist nur, wie mache ich das.
 
Ist das die richtige Kombination der Vorschläge?

PHP:
$bildnamen = array (2 => 'back', 3 => 'top');
$bildzaehler = 1;
foreach ($mo_images as $mo_img) {
	$bildzaehler ++;
	if ($mo_img['image_nr'] == (int) $_GET['imgID']) {
		$actual = ' bgcolor="#ffffff"';
	}
	else {
		unset ($actual);
	}
	echo '<td align="left"' . $actual . '><a style="font-family: Verdana, Arial, sans-serif; color: #000000; font-size: 12px; font-weight:bold; text-decoration:none;" href="popup_image.php?pID=' . (int) $_GET['pID'] . '&imgID=' . $mo_img['image_nr'] . '" target="_parent">' . $bildnamen[$bildzaehler] . '</a></td>';
}
 
Zuletzt bearbeitet:
wobei das nicht ganz rein gecoded wurde, php wird n notice rauswerfen.

besser:
PHP:
$bildnamen = array (2 => 'back', 3 => 'top');
$bildzaehler = 1;
foreach ($mo_images as $mo_img) {
    $bildzaehler ++;
    if ($mo_img['image_nr'] == (int) $_GET['imgID']) {
        $actual = ' bgcolor="#ffffff"';
    }
    else {
        $actual = '';
    }
    echo '<td align="left"' . $actual . '><a style="font-family: Verdana, Arial, sans-serif; color: #000000; font-size: 12px; font-weight:bold; text-decoration:none;" href="popup_image.php?pID=' . (int) $_GET['pID'] . '&imgID=' . $mo_img['image_nr'] . '" target="_parent">' . $bildnamen[$bildzaehler] . '</a></td>';
}

Gruß,
Saman
 
Stimmt! Der gesamte Code dieses Shops, so er denn mehr oder weniger hier Original gepostet wurde, ist nicht wirklich schön...
 
Zurück
Oben Unten