weberin Posted December 15, 2006 Share Posted December 15, 2006 i'm trying to modify a code, originally used for image galleries, to create a pictoral update table for my website (with each cell displaying a pic, date, title, and description), four columns across, no more than the 20 most recent updates. My code keeps messing up though. This is the PHP code, after putting 2 full entries in the SQL database "update_data":[code]<h1>Updates</h1><table border="2" border-color="white"><?php $number_of_updates_in_row = 4; $sql = mysql_query("SELECT *, date_format(update_date, '%M %D, %Y') as update_date FROM update_data ORDER BY update_id LIMIT 20"); while ($row = mysql_fetch_array($sql)) { $sql_array[] = "<img src='" . $row['update_file'] . "' border='0' alt='" . $row['update_title'] . "' /><BR />" . print $row['update_date'] . "<BR />" . print $row['update_title'] . "<BR />" . print $row['update_desc'] . "<BR />"; } mysql_free_result($sql); $sql_final = "<tr>\n"; foreach ($sql_array as $thumbnail_link) { if ($counter == $number_of_updates_in_row) { $counter = 1; $result_final .= "\n</tr>\n<tr>\n"; } else $counter++; $result_final .= "\t<td>" . $thumbnail_link . "</td>\n"; } if ($counter) { if ($number_of_updates_in_row - $counter) $result_final .= "\t<td colspan='" . ($number_of_updates_in_row - $counter) . "'> </td>\n"; } $result_final .= "</tr>"; ?></table>[/code]And this is the resulting HTML code:[code]<h1>Updates</h1><table border="2" border-color="white">(10 photos)<BR />Vegas vacation<BR />1July 21st, 2006<BR />1(story)<BR />Kitty love<BR />1December 14th, 2006<BR />1 </table>[/code]Please help me. Thank you. Link to comment https://forums.phpfreaks.com/topic/30723-creating-update-table-using-phpsql/ Share on other sites More sharing options...
trq Posted December 15, 2006 Share Posted December 15, 2006 What is your question? Link to comment https://forums.phpfreaks.com/topic/30723-creating-update-table-using-phpsql/#findComment-141592 Share on other sites More sharing options...
weberin Posted December 15, 2006 Author Share Posted December 15, 2006 I'm asking how to make the code output be what it's supposed to, which is:--------------.......<tr><td><img src='pic1.jpg' border='0' alt='Vegas vacation'><BR />July 21st, 2006<BR />Vegas vacation<BR />(10 photos)<BR /></td><td><img src='pic2.jpg' border='0' alt='Kitty Love'><BR />December 14th, 2006<BR />Kitty Love<BR />(story)<BR /></td>...</tr>.........-----------Instead, something in the code is making it output differently, into the HTML viewed in my original post. Link to comment https://forums.phpfreaks.com/topic/30723-creating-update-table-using-phpsql/#findComment-141595 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.