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.. Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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 ??? Quote Link to comment 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? Quote Link to comment 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> " ; ?> Quote Link to comment 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>"; } ?> Quote Link to comment 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? Quote Link to comment 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 ?? Quote Link to comment 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 Quote Link to comment 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>"; ?> Quote Link to comment 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 Quote Link to comment 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>"; ?> Quote Link to comment 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.. 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.