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
https://forums.phpfreaks.com/topic/211090-array-trouble/
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
https://forums.phpfreaks.com/topic/211090-array-trouble/#findComment-1100856
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.