Jump to content

array trouble


desmondMorris

Recommended Posts

hi,

 

i am pulling data from a database, a picture and some text, i am able to have the records display vertically but i want them to display across the screen rather than downwards, but because of the page size, i only want 2 results per line. does any one know how i can do this?

 

thanks in advance.

 

Des

 

This is the code i am currently using

 

$result = mysql_query("select * from staff'");

 

 

echo "<table border='0' cellpadding='10' cellspacing='0'>";

echo "<tr>";

while($row = mysql_fetch_array($result))

{

 

echo "<td><img src=../upload/".$row['Pic']." border='0' width='140' height='105' /></td>";

echo "<td>".$row['Name']."</br><b>".$row['Role']."</b></td>";

 

}

echo "</tr>";

echo "</table>";

 

Link to comment
Share on other sites

$result = mysql_query("select * from staff'");
$i=0:

echo "<table border='0' cellpadding='10' cellspacing='0'>";
//echo "<tr>";
while($row = mysql_fetch_array($result))
{
if($i == 0) echo '<tr>';
$i++;
echo "<td><img src=../upload/".$row['Pic']." border='0' width='140' height='105' /></td>";
echo "<td>".$row['Name']."</br><b>".$row['Role']."</b></td>";
if($i==2){echo '</tr>'; $i=0;}
}
if($i>0)echo "<td> </td></tr>";
echo "</table>";

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.