The database and everything worked, but only during that class..
After that class I tried to check it again but it didn't work.. is there something wrong I'm doing here?
I put the database file (school_of_engineering.sql) into the same folder as the php (assignment.php) file..
but the result always displays "test 01" and does not display the table..
here is the code in the assignment.php that i have come up with to display the table (inventory) from the database (school_of_engineering).
Code: Select all
<?php
//step 1: connect & select DB
$db = "school_of_engineering";
$table = "inventory";
//$conn = @mysqli_connect("localhost","root","")or die("Unable to connect to $db");
$conn = @mysqli_connect("localhost","root","") or die ("no mysql connection");
@mysqli_select_db($conn,$db) or die ("test 01");
//Step 2: query the table
$sql = "select * from $table";
$query = mysqli_query($conn, $sql);
echo "<table border='1' cellspacing = '3' cellpadding= '3'>";
echo "<table heading='1'";
//step3: retreive and display the data
$row = mysqli_fetch_row($query);
do{
echo "<tr>";
echo "<td>$row[0]</td>";
echo "<td>$row[3]</td>";
echo "<td>$row[5]</td>";
echo "</tr>";
$row = mysqli_fetch_row($query);
}while($row);
echo "</table>";
//step 4: free the memory
mysqli_free_result($query);
//step 5: close the connection
mysqli_close($conn);
?>In case you need the file to check out the whole thing yourself, here is the link to get the file too..
http://speedy.sh/M357V/assignment.php
http://speedy.sh/HDxhd/school-of-engineering.sql