Als ik deze code gebruik, dan werkt het gewoon.
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$result = mysql_query("SELECT * FROM top");
echo "<table border='1'>
<tr>
<th> ID </th>
<th> Test </th>
<th> Num </th>
<th> Num1 </th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['test'] . "</td>";
echo "<td>" . $row['num'] . "</td>";
echo "<td>" . $row['num1'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
Maar als ik er order by bijzet werkt het niet meer.
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$result = mysql_query("SELECT * FROM top ORDER BY num1");
echo "<table border='1'>
<tr>
<th> ID </th>
<th> Test </th>
<th> Num </th>
<th> Num1 </th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['test'] . "</td>";
echo "<td>" . $row['num'] . "</td>";
echo "<td>" . $row['num1'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
Owja ik krijg dan deze error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\filip\Bureaublad\TWlan\htdocs\linkex\top100.php on line 20
1.781 views