refiking Posted September 26, 2008 Share Posted September 26, 2008 I want to retrieve all the web addresses of the pictures and post the pictures in rows of 3. I know how to retrieve the results. I just don't know how to span it over the different table cells. Also, under each photo, I need to insert a link. Here's what I have so far: $sql = mysql_query("SELECT * FROM owners_skins WHERE sid = '$sid'")or die(mysql_error()); while ($row = mysql_fetch_assoc($sql)){ $pix = $row['location']; $pid = $row['pid']; Echo'<TABLE width="80%" border="4"> <TR> <TD align="center"><img src=' . $pix . ' border="0"></BR><A HREF="preview.php?pid=' . $pid . '">Preview</A></BR></TD> <TD align="center"><img src=' . $pix . ' border="0"></BR><A HREF="preview.php?pid=' . $pid . '">Preview</A></BR></TD> <TD align="center"><img src=' . $pix . ' border="0"></BR><A HREF="preview.php?pid=' . $pid . '">Preview</A></BR></TD> </TR>'; } Right now, only the first record shows up in all 3 table cells. Quote Link to comment https://forums.phpfreaks.com/topic/125887-solved-need-with-splitting-query-results-into-table/ Share on other sites More sharing options...
F1Fan Posted September 26, 2008 Share Posted September 26, 2008 First, I will warn you that there are many people on this forum that will give you grief for using tables for non-tabular data. With that out of the way, it mostly looks ok to me, besides the fact that you don't have a table close tag, but that wouldn't make it not work. You really should put your src in quotes, and your line break tags <br> shouldn't have slashes at the beginning. That would make it look kinda weird. Fix those things and refresh it. Quote Link to comment https://forums.phpfreaks.com/topic/125887-solved-need-with-splitting-query-results-into-table/#findComment-650961 Share on other sites More sharing options...
dezkit Posted September 26, 2008 Share Posted September 26, 2008 echo '<TABLE width="80%" border="4">'; $sql = mysql_query("SELECT * FROM owners_skins WHERE sid = '$sid'")or die(mysql_error()); while ($row = mysql_fetch_assoc($sql)){ $pix = $row['location']; $pid = $row['pid']; echo '<TR> <TD align="center"><img src=' . $pix . ' border="0"></BR><A HREF="preview.php?pid=' . $pid . '">Preview</A></TD> </TR>'; }\ echo '</table>'; You only need one table echo in a while loop........ Quote Link to comment https://forums.phpfreaks.com/topic/125887-solved-need-with-splitting-query-results-into-table/#findComment-650963 Share on other sites More sharing options...
refiking Posted September 26, 2008 Author Share Posted September 26, 2008 Thanks for the help so far guys... Dezkit, I don't need them to show up one row at a time. I need the pictures to show up 3 to a row. That only produces one. And it's still the same record everytime. F1Fan, Is there another way to get 3 images per row? The only way I could think of was a table. I'm open to all suggestions. Page just started about 50 lines ago. Can scrap it and start from scratch if necessary. Easier to do it now then later. Thanks again for the input guys Quote Link to comment https://forums.phpfreaks.com/topic/125887-solved-need-with-splitting-query-results-into-table/#findComment-650970 Share on other sites More sharing options...
redarrow Posted September 26, 2008 Share Posted September 26, 2008 TAKE THE PID=PID AWAY FROM UR SELECT PLEASE PLEASE GRRRRRRRRRRRRRRRR Quote Link to comment https://forums.phpfreaks.com/topic/125887-solved-need-with-splitting-query-results-into-table/#findComment-650974 Share on other sites More sharing options...
refiking Posted September 26, 2008 Author Share Posted September 26, 2008 TAKE THE PID=PID AWAY FROM UR SELECT PLEASE PLEASE GRRRRRRRRRRRRRRRR LOL IT'S GONE IT'S GONE So, how will I be able to identify which pic they clicked on? Quote Link to comment https://forums.phpfreaks.com/topic/125887-solved-need-with-splitting-query-results-into-table/#findComment-650980 Share on other sites More sharing options...
redarrow Posted September 26, 2008 Share Posted September 26, 2008 by the picture name i hope Quote Link to comment https://forums.phpfreaks.com/topic/125887-solved-need-with-splitting-query-results-into-table/#findComment-650986 Share on other sites More sharing options...
refiking Posted September 26, 2008 Author Share Posted September 26, 2008 How will they be able to do that if there's no identifier? That was why I use pid(picture id). That way, I could retrieve it from there. :-\ sigh..... So, what's the better way to do that? Quote Link to comment https://forums.phpfreaks.com/topic/125887-solved-need-with-splitting-query-results-into-table/#findComment-650995 Share on other sites More sharing options...
redarrow Posted September 26, 2008 Share Posted September 26, 2008 Dont get this mate.............. are the users logged in to see the images,,,,,,,,,,,,,,,,,,,,, Quote Link to comment https://forums.phpfreaks.com/topic/125887-solved-need-with-splitting-query-results-into-table/#findComment-651003 Share on other sites More sharing options...
refiking Posted September 26, 2008 Author Share Posted September 26, 2008 yes Quote Link to comment https://forums.phpfreaks.com/topic/125887-solved-need-with-splitting-query-results-into-table/#findComment-651004 Share on other sites More sharing options...
F1Fan Posted September 26, 2008 Share Posted September 26, 2008 As far as the 3 per line, you'll have to do some counting. Here's a very simple example: <?php $count = 0; echo '<table><tr>'; while (whatever){ if ($count==3){ echo '</tr><tr>'; $count = 0; } echo '<td>Blah...</td>'; $count++; } // this next part just closes up the table if there aren't three cells in the last row while ($count<3){ echo '<td> </td>'; $count++; } echo '</tr></table>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/125887-solved-need-with-splitting-query-results-into-table/#findComment-651008 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.