pelehelp
03-28-2009, 09:39 AM
Hi
Thanks a lot for the guidlines, is very helpful and I realise my mistakes too. Now i have another problem is that I can't retrieve certain column (full_name and ic_number)from the database into a table form. I wondering what is my problem here.
<?php
//Connect to the MySQL server
$db_host = "localhost";
$db_username = "root";
$db_password = "fsktm";
$server = mysql_connect($db_host,$db_username,$db_password)or die("Could not connect!/n");
//Select a database that has created
$db_name = "cinema";
mysql_select_db($db_name)or die("Could not select the database $db_name!\n");
//Retrieve or select the data
$retrieve = mysql_query("SELECT *FROM user") or die(mysql_error());
echo"<table border = 1 width = 100% height = 100% style = 'background-color:#F0F8FF;'>
<tr>
<th>Username</th>
<th>Password</th>
<th>Full Name</th>
<th>IC Number</th>
<th>Telephone</th>
<th>Email</th>
<th>History</th>
</tr>";
//Display the data from the database in a table using aray
while($row = mysql_fetch_array($retrieve))
{
echo "<tr>";
echo"</td><td>";
echo $row['username'];
echo "</td><td>";
echo $row['password'];
echo "</td><td>";
echo $row['fullname'];
echo "</td><td>";
echo $row['ic'];
echo "</td><td>";
echo $row['telephone'];
echo "</td><td>";
echo $row['email'];
echo "</td><td>";
echo $row['history'];
echo "</tr>";
}
echo "</table>";
mysql_close($server);
?>
Thanks a lot for the guidlines, is very helpful and I realise my mistakes too. Now i have another problem is that I can't retrieve certain column (full_name and ic_number)from the database into a table form. I wondering what is my problem here.
<?php
//Connect to the MySQL server
$db_host = "localhost";
$db_username = "root";
$db_password = "fsktm";
$server = mysql_connect($db_host,$db_username,$db_password)or die("Could not connect!/n");
//Select a database that has created
$db_name = "cinema";
mysql_select_db($db_name)or die("Could not select the database $db_name!\n");
//Retrieve or select the data
$retrieve = mysql_query("SELECT *FROM user") or die(mysql_error());
echo"<table border = 1 width = 100% height = 100% style = 'background-color:#F0F8FF;'>
<tr>
<th>Username</th>
<th>Password</th>
<th>Full Name</th>
<th>IC Number</th>
<th>Telephone</th>
<th>Email</th>
<th>History</th>
</tr>";
//Display the data from the database in a table using aray
while($row = mysql_fetch_array($retrieve))
{
echo "<tr>";
echo"</td><td>";
echo $row['username'];
echo "</td><td>";
echo $row['password'];
echo "</td><td>";
echo $row['fullname'];
echo "</td><td>";
echo $row['ic'];
echo "</td><td>";
echo $row['telephone'];
echo "</td><td>";
echo $row['email'];
echo "</td><td>";
echo $row['history'];
echo "</tr>";
}
echo "</table>";
mysql_close($server);
?>