gdfhghjdfghgfhf Posted May 6, 2008 Share Posted May 6, 2008 yeah well i'm stuck here... i know my problem is stupid but i'm still a newbie >< $query78 = "SELECT * from pp_files WHERE category = '$id'"; $res78 = mysql_query($query78) or die(mysql_error()); while($row = mysql_fetch_array($res78)) { $picture = $row["picture"]; $vidid = $row["id"]; $rows = mysql_num_rows($res78); } if ($rows > 0) { echo "<br><table width=\"85%\" align=\"center\" cellpadding=\"8\"><tr><td style=\"background: url(1.png); border: 1px dashed #FFFFFF; cellpadding: 5px;\" colspan=\"5\">"; echo "<center><b><font size=\"3\">$vbphrase[ilya]il y a <font size=\"5\">$rows</font> $vbphrase[vids]</font></b><br>"; $query78 = "SELECT * from pp_files WHERE category = '$id'"; $res78 = mysql_query($query78) or die(mysql_error()); while($row = mysql_fetch_array($res78)) { echo "<a href=\"videos/video.php?id=$vidid\"><img src=\""; echo $picture; echo "\" border=\"0\" alt=\"$vbphrase[vids_click]\"></a> "; } echo "<br><font size=\"2\"><a href=\"videos/submit.php\">$vbphrase[vids_add]</a></font></center></td></tr></table>"; } i have multiple items in tables of my database and i am trying to display all of the pictures, with a link to the corresponding picture my problem is that only the last item is displayed.... If there is 3 entry to display, 3 items will be displayed, but with the same picture (none) and the same link (last id of the array) Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 6, 2008 Share Posted May 6, 2008 Do NOT run mysql_num_rows inside of the while loop. Take it out and put it before the loop. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted May 6, 2008 Share Posted May 6, 2008 the problem is you loop over the records loading variables, but you don't do anything with those variables until after the loop. so all you get is the last ones. i suggest that you use the variables as you load them or that you load them all into arrays and use them after the loop while($row = mysql_fetch_array($res78)) { // here, you loop over every record setting values, but never using them. $picture = $row["picture"]; $vidid = $row["id"]; $rows = mysql_num_rows($res78); } Quote Link to comment Share on other sites More sharing options...
gdfhghjdfghgfhf Posted May 6, 2008 Author Share Posted May 6, 2008 ehhh i don't understand i should remove all mysql_fetch_array parts? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 6, 2008 Share Posted May 6, 2008 No....You're rewriting the results every time you use the while loop with your command though. Think about it. Quote Link to comment Share on other sites More sharing options...
gdfhghjdfghgfhf Posted May 6, 2008 Author Share Posted May 6, 2008 could you just fix the code for me... i'd understand better cuz right now i'm really lost.. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 6, 2008 Share Posted May 6, 2008 Where are you getting $vbphrase? Also: Ton site est en francais? o-O Quote Link to comment Share on other sites More sharing options...
gdfhghjdfghgfhf Posted May 6, 2008 Author Share Posted May 6, 2008 i use $vbphrase because i am putting this script inside a vbulletin template... so all $vbphrase variables will be replaced with its corresponding language signification from the vbulletin's language and phrases system.... so basically it's just words and text, but i use it to have both a french and an english version of my site oui mon site est en francais Tu parles francais? D'ou viens tu? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 6, 2008 Share Posted May 6, 2008 Oh, okay. I'll try to fix up the code. Oui, je parle francais...mais, je suis venu des Etats-Unis. >_> Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 6, 2008 Share Posted May 6, 2008 $query78 = "SELECT * from pp_files WHERE category = '$id'"; $res78 = mysql_query($query78) or die(mysql_error()); $rows = mysql_num_rows($res78); while($row = mysql_fetch_array($res78)) { $picture = $row["picture"]; $vidid = $row["id"]; } if ($rows > 0) { while($row = mysql_fetch_array($res78)) { $picture = $row["picture"]; $vidid = $row["id"]; echo "<br><table width=\"85%\" align=\"center\" cellpadding=\"8\"><tr><td style=\"background: url(1.png); border: 1px dashed #FFFFFF; cellpadding: 5px;\" colspan=\"5\">"; echo "<center><b><font size=\"3\">$vbphrase[ilya]il y a <font size=\"5\">$rows</font> $vbphrase[vids]</font></b><br>"; echo "<a href=\"videos/video.php?id=$vidid\"><img src=\""; echo $picture; echo "\" border=\"0\" alt=\"$vbphrase[vids_click]\"></a> "; echo "<br><font size=\"2\"><a href=\"videos/submit.php\">$vbphrase[vids_add]</a></font></center></td></tr></table>"; } Je pense qu'il va fonctionner... } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.