yami007 Posted August 28, 2008 Share Posted August 28, 2008 well, This is first I came here, i hope it's my way, so ... i wanted to echo something like this ... <?php echo "<table> <tr> <td><center><a href=\"index.php?singer=" . urlencode($page["id"]) . "\"><img src=\"{$page["image"]\"/><br />{$page["menu_name"]}</a><br /></center></td <td><center><a href=\"index.php?singer=" . urlencode($page["id"]) . "\"><img src=\"{$page["image"]\"/><br />{$page["menu_name"]}</a><br /></center></td <td><center><a href=\"index.php?singer=" . urlencode($page["id"]) . "\"><img src=\"{$page["image"]\"/><br />{$page["menu_name"]}</a><br /></center></td </tr> </table> " ; ?> but i want to show a different content rather to show the same thing three times PLEASE HELP Thanks in advance.. Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/ Share on other sites More sharing options...
dezkit Posted August 28, 2008 Share Posted August 28, 2008 you might want to use a while loop Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/#findComment-627914 Share on other sites More sharing options...
trq Posted August 28, 2008 Share Posted August 28, 2008 Where is the different content coming from? Where is $page defined? Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/#findComment-627923 Share on other sites More sharing options...
yami007 Posted August 28, 2008 Author Share Posted August 28, 2008 oh how can i use this while loop, please explain ??? Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/#findComment-627945 Share on other sites More sharing options...
trq Posted August 28, 2008 Share Posted August 28, 2008 Once again. Where is the different content coming from? Where is $page defined? Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/#findComment-627947 Share on other sites More sharing options...
yami007 Posted August 28, 2008 Author Share Posted August 28, 2008 Where is the different content coming from? Where is $page defined? <?php if (isset($_GET['page'])) { $subject_pages = get_pages_for_subject($sel_subject['id']); while($page = mysql_fetch_array($subject_pages)) { echo "<table> <tr> <td><center><a href=\"index.php?singer=" . urlencode($page["id"]) . "\"><img src=\"{$page["image"]\"/> {$page["menu_name"]}[/url] </center></td <td><center><a href=\"index.php?singer=" . urlencode($page["id"]) . "\"><img src=\"{$page["image"]\"/> {$page["menu_name"]}[/url] </center></td <td><center><a href=\"index.php?singer=" . urlencode($page["id"]) . "\"><img src=\"{$page["image"]\"/> {$page["menu_name"]}[/url] </center></td </tr> </table> " ; ?> Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/#findComment-627948 Share on other sites More sharing options...
PHPTOM Posted August 28, 2008 Share Posted August 28, 2008 <?php if (isset($_GET['page'])) { $subject_pages = get_pages_for_subject($sel_subject['id']); echo "<table>"; while($page = mysql_fetch_array($subject_pages)) { echo " <tr> <td align=\"center\"><a href=\"index.php?singer=" . urlencode($page['id']) . "\"><img src=\"".$page['image']."\"/>".$page['menu_name']."</a> </td></tr>"; } echo "</table>"; } ?> Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/#findComment-627949 Share on other sites More sharing options...
trq Posted August 28, 2008 Share Posted August 28, 2008 Your already using a while loop then. Maybe your query only returns one row? Also, because your using a loop you don't need to write the code out three times. Also, note the use of tags on the forum? Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/#findComment-627953 Share on other sites More sharing options...
yami007 Posted August 28, 2008 Author Share Posted August 28, 2008 Your already using a while loop then. Maybe your query only returns one row? Also, because your using a loop you don't need to write the code out three times. Also, note the use of tags on the forum? What i tried to say is that i want to display the first three subjects on the first row, and then the second ones....etc.. HOW ?? Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/#findComment-627959 Share on other sites More sharing options...
yami007 Posted August 28, 2008 Author Share Posted August 28, 2008 oh PHPTOM this is not what i wanted.... i hope you get me right thanks again Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/#findComment-627961 Share on other sites More sharing options...
PHPTOM Posted August 28, 2008 Share Posted August 28, 2008 Right Have a database Have a row called menu (used here) Have 3 columns called id, image and name <?PHP // Connect to database etc echo "<table>"; $query = mysql_query("SELECT * FROM `menu`"); while ($array = mysql_fetch_array($query)){ echo ' <tr> <td align="center"><a href="index.php?singer='.$array['id'].'"><img src="'.$array['image'].'" />'.$array['name'].'</a></td> </tr>'; } echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/#findComment-627963 Share on other sites More sharing options...
PHPTOM Posted August 28, 2008 Share Posted August 28, 2008 Basically you want to do this right? Subject 1 Subject 2 Subject 3 Subject 4 So... On... ---------------- Now playing: 2pac - Changes via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/#findComment-627965 Share on other sites More sharing options...
yami007 Posted August 28, 2008 Author Share Posted August 28, 2008 right but... it doesnt come with this... <?php echo "<table>"; $query = mysql_query("SELECT * FROM `tbl_pages`"); while ($array = mysql_fetch_array($query)){ echo ' <tr> <td align="center"><a href="index.php?singer='.$array['id'].'"><img src="'.$array['image'].'" />'.$array['menu_name'].'</a></td> </tr>'; } echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/#findComment-627970 Share on other sites More sharing options...
yami007 Posted August 28, 2008 Author Share Posted August 28, 2008 sorry guys i should've told you how it was solved, well... PHPTOM told me to do this ... and it worked <?PHP // Connect to database etc echo "<table><tr>"; $rows = 0; $query = mysql_query("SELECT * FROM `menu`"); while ($array = mysql_fetch_array($query)){ $rows++; echo '<td align="center"><a href="index.php?singer='.$array['id'].'"><img src="'.$array['image'].'" />'.$array['name'].'</a></td>'; if ($rows %3 == 0) { echo '</tr><tr>'; } } echo "</tr></table>"; ?> Thanks PHPTOM.. Link to comment https://forums.phpfreaks.com/topic/121720-solved-what-should-i-use-to-echo-this/#findComment-628077 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.