#1 14. August 2009 & [SQL] Bilder den passenden Texten zuweisen Moin zusammen, ich bastel hier gerade ein bisschen an einer Seite für meine Mum herum und habe da ein Problem. Hier erst einmal der Code dazu: PHP: <? php if ( $_SESSION [ 'lang' ] == "en" ) { mysql_query ( "SET NAMES 'utf8'" , $db ); mysql_query ( "SET CHARACTER SET 'utf8'" , $db ); $abfrage = "SELECT `id`, `headline`, `headline_small`, `text`, `price`, `price_object`, `status_new` FROM `objects_en` WHERE `status_new` = '1'" ; } elseif ( $_SESSION [ 'lang' ] == "de" ) { mysql_query ( "SET NAMES 'utf8'" , $db ); mysql_query ( "SET CHARACTER SET 'utf8'" , $db ); $abfrage = "SELECT `id`, `headline`, `headline_small`, `text`, `price`, `price_object`, `status_new` FROM `objects_de` WHERE `status_new` = '1'" ; } elseif ( $_SESSION [ 'lang' ] == "es" ) { mysql_query ( "SET NAMES 'utf8'" , $db ); mysql_query ( "SET CHARACTER SET 'utf8'" , $db ); $abfrage = "SELECT `id`, `headline`, `headline_small`, `text`, `price`, `price_object`, `status_new` FROM `objects_es` WHERE `status_new` = '1'" ; } elseif ( $_SESSION [ 'lang' ] == "ru" ) { mysql_query ( "SET NAMES 'utf8'" , $db ); mysql_query ( "SET CHARACTER SET 'utf8'" , $db ); $abfrage = "SELECT `id`, `headline`, `headline_small`, `text`, `price`, `price_object`, `status_new` FROM `objects_ru` WHERE `status_new` = '1'" ; } elseif ( $_SESSION [ 'lang' ] == "pl" ) { mysql_query ( "SET NAMES 'utf8'" , $db ); mysql_query ( "SET CHARACTER SET 'utf8'" , $db ); $abfrage = "SELECT `id`, `headline`, `headline_small`, `text`, `price`, `price_object`, `status_new` FROM `objects_pl` WHERE `status_new` = '1'" ; } $result = mysql_query ( $abfrage , $db ) or die( mysql_error ()); while( $row = mysql_fetch_array ( $result )) { $id = $row [ 'id' ]; $headline = $row [ 'headline' ]; $headline_small = $row [ 'headline_small' ]; $text = $row [ 'text' ]; $price = $row [ 'price' ]; $price_object = $row [ 'price_object' ]; $status_show = $row [ 'status_show' ]; $status_new = $row [ 'status_new' ]; $status_rent = $row [ 'status_rent' ]; $status_sale = $row [ 'status_sale' ]; $status_sold = $row [ 'status_sold' ]; ?> <span class="headline"><?php echo $headline ; ?></span> <table style="border-style: none; width="494" border="1"> <tr> <td width="173" height="170" style="border-style: none; border-width: medium"><a onClick="window.open('images/objects/apartments/villa3.jpg')"><img src="images/objects/apartments/villa3.jpg" width="153" height="135" alt="screen" border="0" hspace="10" align="left" /></a></td> <td width="4" style="border-style: none; border-width: medium"> </td> <td width="298" style="border-style: none; border-width: medium"><h6><?php echo $text ; ?></h6></td> </tr> <tr> <td style="border-style: none; border-width: medium"><b><h6><?php echo $price ; ?>: € <?php echo $price_object ; ?></h6></b></td> <td style="border-style: none; border-width: medium"> </td> <td style="border-style: none; border-width: medium"> </td> </tr> </table> <p class="headline"><center><img src="images/hr01.gif" width="467" height="6" alt="" border="0"></center></p> <?php } ?> (Wenn es Verbesserungsvorschläge dazu gibt, gerne her damit, ich lerne halt nebenbei immer ein wenig) Eine Schleife für die Texte habe ich drin, allerdings möchte ich auch dass der ausgegebene Text auch das passende Bild dazu hat. Aktuell habe ich ja nur: Code: <td width="173" height="170" style="border-style: none; border-width: medium"><a onClick="window.open('images/objects/apartments/villa3.jpg')"><img src="images/objects/apartments/villa3.jpg" width="153" height="135" alt="screen" border="0" hspace="10" align="left" /></a></td> Nur wie kann ich jetzt die passenden bilder auch zu den Texten, die ausgegeben werden sollen, zuweisen. Das verstehe ich noch nicht so ganz Würde mich über Hilfe sehr freuen //Dw4rf + Multi-Zitat Zitieren
#2 14. August 2009 AW: & [SQL] Bilder den passenden Texten zuweisen PHP: <? phpmysql_query ( "SET NAMES 'utf8'" , $db ); $suffix = 'en' ;switch( $_SESSION [ 'lang' ]) { case 'en' : case 'de' : case 'es' : case 'ru' : case 'pl' : $suffix = $_SESSION [ 'lang' ]; break;} $res = mysql_query ( ' SELECT `id`, `headline`, `headline_small`, `text`, `price`, `price_object`, `status_new` FROM `objects_' . $suffix . '` WHERE `status_new` = 1' , $db ) or exit( mysql_error ()); while( $row = mysql_fetch_assoc ( $res )) { extract ( $row , EXTR_OVERWRITE ); ?> <span class="headline"><?php echo $headline ; ?></span><table style="border-style: none; width="494" border="1"> <tr> <td width="173" height="170" style="border-style: none; border-width: medium"><a onClick="window.open('images/objects/apartments/villa3.jpg')"><img src="images/objects/apartments/villa3.jpg" width="153" height="135" alt="screen" border="0" hspace="10" align="left" /></a></td> <td width="4" style="border-style: none; border-width: medium"> </td> <td width="298" style="border-style: none; border-width: medium"><h6><?php echo $text ; ?></h6></td> </tr> <tr> <td style="border-style: none; border-width: medium"><b><h6><?php echo $price ; ?>: € <?php echo $price_object ; ?></h6></b></td> <td style="border-style: none; border-width: medium"> </td> <td style="border-style: none; border-width: medium"> </td> </tr></table><p class="headline"><center><img src="images/hr01.gif" width="467" height="6" alt="" border="0"></center></p> <?php } ?> zum problem: speicher den pfad zum bild mit in der datenbank und gib den pfad einfach aus + Multi-Zitat Zitieren