I believe your problem is that the mysqli_fetch_array function on line 39 returns an enumerated array and the extract function on line 41 takes the values in an array and assigns it to an associative array based on the keys. Since the keys in an enumerated array are numbers, those are the variable names. I believe you will have an easier time if you do the following: while ($row=mysqli_fetch_array($data)) { $building = $row[0]; $parking_lot = $row[1]; $month = $row[2]; $day = $row[3]; $occupancy = $row[4]; $empty_spaces = $row[5]; $special_days = $row[6]; echo "<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$month</td>\n <td>$day</td>\n <td>$occupancy</td>\n <td>$empty_spaces</td>\n <td>$special_days</td>\n </tr>\n"; echo "<tr><td colspan='7'><hr /></td></tr>\n"; } Now it is important in the order with which the fields are returned from the database since that will affect the row values when you are assigning them to variables (ie- if the day is returned first in the array it should be " $day = $row[0]" ) Hope that helps Thanks patrick Sent from: Decatur Ga United States. On Sat, Feb 14, 2009 at 12:05 AM, Sashikanth Gurram <sashi34u@xxxxxx> wrote: > Hi all, > > I am trying to run a query to retrieve data from mysql database and display > it in a webpage in a table. The query is running fine, but the the data is > not appearing on the webpage. All I see is a webpage with few empty cells. > The echo command starting from line 42 is something like this > *echo "<tr>\n > <td>$building</td>\n > <td>$parking_lot</td>\n <td>$month</td>\n > <td>$day</td>\n > <td>$occupancy</td>\n > <td>$empty_spaces</td>\n > <td>$special_days</td>\n > </tr>\n";* > > The variables I have used here ie., $building, $parking_lot etc are nothing > but the column names in the mysql database ie., building, parking_lot etc. I > hope I did not mess up in that sense. But, I do not know the reason for the > non appearance of the data. > > I am posting the whole code below. Also I am attaching a screenshot of the > display in the webpage. If anyone has any answer please let me know. > > Thanks > Sashi > > <?php > > // Connects to your Database > $host="******"; > $user="******"; > $password="******"; > $dbname="******"; > $cxn=mysqli_connect($host, $user, $password, $dbname) ; > if (!$cxn=mysqli_connect($host, $user, $password, $dbname)) > { > $error=mysqli_error($cxn); > echo "$error"; > die(); > } > else > { > echo "Connection established successfully"; > } > > $sql="SELECT * FROM occupancy"; > $data = mysqli_query($cxn,$sql); > if (!$data=mysqli_query($cxn,$sql)) > { > $error=mysqli_error($cxn); > echo "$error"; > die(); > } > else > { > echo "<br>"; > echo "Query sent successfully"; > } > > > echo "<br>"; > echo "<h1> OCCUPANCY <h1>"; > echo "<table cellspacing='0'>"; > echo "<tr><td colspan='7'><hr /></td></tr>"; > while ($row=mysqli_fetch_array($data)) > { > extract($row); > echo "<tr>\n > <td>$building</td>\n > <td>$parking_lot</td>\n > <td>$month</td>\n <td>$day</td>\n > <td>$occupancy</td>\n > <td>$empty_spaces</td>\n > <td>$special_days</td>\n > </tr>\n"; > echo "<tr><td colspan='7'><hr /></td></tr>\n"; > } > echo "</table>\n"; > > > ?> > > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Sashikanth Gurram > Graduate Research Assistant > Department of Civil and Environmental Engineering > Virginia Tech > Blacksburg, VA 24060, USA > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >