0

i tried so many code, but the result still a blank page. i have mysql database stored in my localhost, and i did not use phpmyadmin to create the table.

Did i have to create mysql table via phpmyadmin,so that php can access it? i also use MAMP for apache web server and mySql server running.

<!DOCTYPE HTML>
<?php
//make connection
mysql_connect('localhost', 'root', '');

//select database 
mysql_select_db('locker');

$sql= "SELECT * FROM locker";

$records=mysql_query($sql);

echo #records;

?>

<HTML>
<body>

<table width="600" border="1" cellpadding="1" cellspacing="1">
<tr>
 <th>username</th>
 <th>UID</th>
 <th>NoLoker</th>    
    </tr>
<?php

while ($locker=mysql_fetch_assoc($records))
{

    echo "<tr>";

    echo "<td>".$locker['username']."</td>";

    echo "<td>".$locker['UID']."</td>";

    echo "<td>".$locker['NoLoker']."</td>";;

    echo "</tr>";
}//end while

?>
</table>
</body>

  • This is normally due to syntax errors. For instance: `echo #records;` is invalid code. – KIKO Software Jul 16 '16 at 17:45
  • In response to what @KIKOSoftware said, you should change it to `echo $records;` – The Codesee Jul 16 '16 at 17:51
  • @TheCodesee, probably not. The result of [mysql_query](http://php.net/manual/en/function.mysql-query.php) (with `SELECT`) is a resource / false. Since the op is already fetching the results later in the code, removing that line seems like a better option. – FirstOne Jul 16 '16 at 17:58

0 Answers0