Jump to content

Mysql table to html table 3d array...please help


louis_coetzee

Recommended Posts

I have a table

|id|userid|name  |surname  |detail|

|1 |  2  |Elisha |Cuthbert | Hot  |

|2 |  2  |Sara  |Monroe  | Okay |

 

What I want to do is, fetch this from mysql and display it in a html table.

I realise that I did it wrong, but please help me do it the right way...

$result = mysql_query("SELECT * FROM Celebs where userid = '$userid'");
$size = count($result);
if (size !== 0)
{
echo '<table width="500" border="1" cellpadding="4" cellspacing="0" class="boderstyle">
  <tr class="menuitems">
    <td width="16" bgcolor="#666666"><strong>ID</strong></td>
    <td width="70" bgcolor="#666666"><strong>Name</strong></td>
    <td width="153" bgcolor="#666666"><strong>Surname</strong></td>
    <td width="122" bgcolor="#666666"><strong>Detail</strong></td>
  </tr>';

for($k=1; $k <= $size; $k++)
{
	while ($row = mysql_fetch_array($result))
	{
	$id = $row['id'];
	$name = $row['name'];
	$surname = $row['surname'];
	$detail = $row['detail'];
	}
	echo '<tr>
    <td height="31" class="one">'.$id.'</td>
    <td>'.$name.'</td>
    <td>'.$surname.'</td>
    <td>'.$detail.'</td>
  </tr>';
}
echo '</table>';
}

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.