Nate Hunter
March 21st, 2008, 03:37 PM
I am a newby so parden my ignorence.
I am trying to display data from my db into a webpage. I can connect to the db but when I am writing to the webpage I am having problems in the echo. Any help would be appreciated. Here is my code:
<body>
<center>
<?php
// hostname or ip of server (for local testing, localhost should work)
$dbServer='myServer';
// username and password to log onto db server
$dbUser='myUser';
$dbPass='myPass';
// name of database
$dbName='myDbName';
$link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect");
mysql_select_db("$dbName", $link);
?>
<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Position</th>
<th>TimeSlot</th>
</tr>
<?php
$sql = "SELECT FirstName, LastName, Email, Phone, Position, TimeSlot FROM Volunteers";
$result = mysql_query ($sql);
while($row = mysql_fetch_array($query)) {
echo "<tr>"; //This is the part where I think I have the problem I start displaying text in my webpage of the rest of this code.
echo "<td>".$row['FirstName']."</td>";
echo "<td>".$row['LastName']."</td>";
echo "<td>".$row['Position']."</td>";
echo "<td>".$row['TimeSlot']."</td>";
echo "</tr>";
}
mysql_close($link);
?>
</table>
</center>
</body>
I am trying to display data from my db into a webpage. I can connect to the db but when I am writing to the webpage I am having problems in the echo. Any help would be appreciated. Here is my code:
<body>
<center>
<?php
// hostname or ip of server (for local testing, localhost should work)
$dbServer='myServer';
// username and password to log onto db server
$dbUser='myUser';
$dbPass='myPass';
// name of database
$dbName='myDbName';
$link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect");
mysql_select_db("$dbName", $link);
?>
<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Position</th>
<th>TimeSlot</th>
</tr>
<?php
$sql = "SELECT FirstName, LastName, Email, Phone, Position, TimeSlot FROM Volunteers";
$result = mysql_query ($sql);
while($row = mysql_fetch_array($query)) {
echo "<tr>"; //This is the part where I think I have the problem I start displaying text in my webpage of the rest of this code.
echo "<td>".$row['FirstName']."</td>";
echo "<td>".$row['LastName']."</td>";
echo "<td>".$row['Position']."</td>";
echo "<td>".$row['TimeSlot']."</td>";
echo "</tr>";
}
mysql_close($link);
?>
</table>
</center>
</body>