something weird happens
Posted: Sat Sep 12, 2009 7:45 pm
okay, so i was trying to have this php code prints out everything on my database and next to it, i would have a link that would remove that entry from the database.
Here is the code
And This is how my table looks like
0dorkass 3434 Remove
2dingdong 3434 Remove
4dennis 12312 Remove
6dududt 99999 Remove
note that it starts with 0 and then 2 and then... stops at 6... I find this very weird... can someone explain to me what's happening here?
Thank You!
Dennis
Here is the code
Code: Select all
<?php
$username ='dennis';
$password ='dindan';
if(!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) ||
$_SERVER['PHP_AUTH_USER'] != $username || $_SERVER['PHP_AUTH_PW'] != $password)
{
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Admin Page"');
exit('You need to enter the right password');
}
?>
<html>
<head>
<title></title>
</head>
<body>
<?php
$dbc = mysqli_connect ('localhost','root','','cp5');
$query = "SELECT * FROM cptable";
$result = mysqli_query($dbc,$query);
$i = 0;
while($row = mysqli_fetch_array($result)){
echo $i;
echo $row['name'] . ' ' . $row['score'] .' '.
'<a href="confirmation.php?name='.$row['name'].'&score='.$row['score'].'> Remove </a> <br/>';
$i++;
}
mysqli_close($dbc);
?>
</body>
</html>
For some reason the first code that I posted only showed thismysql> select * from cptable;
+----------+------------+--------------------------+--------------+
| name | score | description | logo |
+----------+------------+--------------------------+--------------+
| dorkass | 3434 | i dork | |
| monkey | 3434 | i love banana | |
| dingdong | 3434 | man this sux | verified.gif |
| gamogamo | 435435 | dude i love sleeping too | verified.gif |
| dennis | 12312 | love sleep | verified.gif |
| saru | 3434 | banana suki dayo | |
| dududt | 99999 | i love 999 | |
| doraemon | 2147483647 | dorayaki! | |
+----------+------------+--------------------------+--------------+
8 rows in set (0.00 sec)
0dorkass 3434 Remove
2dingdong 3434 Remove
4dennis 12312 Remove
6dududt 99999 Remove
note that it starts with 0 and then 2 and then... stops at 6... I find this very weird... can someone explain to me what's happening here?
Thank You!
Dennis