Jump to content

[SOLVED] What should I use to echo this ??


yami007

Recommended Posts

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
Share on other sites

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
Share on other sites

<?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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

sorry guys i should've told you how it was solved, well...

PHPTOM told me to do this ... and it worked  8)

 

<?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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.