trying to write a code that will repeat a name until it gets to the number on the database.
Database Information
Name Number
Mike 2
Oscar 2
Robert 1
Wanted to look like
Full Name
Mike
Mike
Oscar
Oscar
Robert
Here is my Code
<?php
$result = mysql_query("SELECT * FROM `people`");
echo
"<table border='1'>
<tr>
<th>Full Name</th>
<th> </th>
</tr>";
for ($i = 1 , $row = mysql_fetch_array($result) ; $i <= $row['Number'] ; $i++ )
{
echo "<tr>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td> </td>";
echo "</tr>";
}
echo "</table>";
?>
When i run the code it will only show the result like this
Full Name
Mike
Mike
and when i put the "for" again in the bottom of the first one it will show like this
Full Name
Mike
Mike
Oscar
Oscar
<?php
$result = mysql_query("SELECT * FROM `people`");
echo
"<table border='1'>
<tr>
<th>Full Name</th>
<th> </th>
</tr>";
for ($i = 1 , $row = mysql_fetch_array($result) ; $i <= $row['Number'] ; $i++ )
{
echo "<tr>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td> </td>";
echo "</tr>";
}
for ($i = 1 , $row = mysql_fetch_array($result) ; $i <= $row['Number'] ; $i++ )
{
echo "<tr>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td> </td>";
echo "</tr>";
}
echo "</table>";
?>
i need something to repeat "For" until it finishes all the Names