Now, I have never been exactly good with the foreach function, But I have managed to get along with it fairly well. However, I am not sure what is wrong with this.
[code=php]<?
$sqlconn = “localhost”;
$sqluser = “username”;
$sqlpass = “password”;
$sqldb = “database”;
$username = $_SESSION[‘username’];
$conn = mysql_connect($sqlconn, $sqluser, $sqlpass);
if(!$conn) {
die(“Could not connect to: “.$sqlconn.”:.:”.mysql_error());
}
mysql_select_db($sqldb, $conn)
or die(“Could not select:.:”.$sqldb.” – “.mysql_error());
$query = mysql_query(“SELECT * FROM nav”) or die(“Query Failed: “.mysql_error());
$row = mysql_fetch_assoc($query);
echo “<table border=”1″ cellpadding=”3″ cellspacing=”0″>n”;
while($line = mysql_fetch_array($query, MYSQL_ASSOC)) {
echo “t<tr>n”;
foreach($line as $col_value) {
echo “tt<td>$col_value</td>n”;
}
}
echo “</table>”;
mysql_free_result($query);
mysql_close($conn);
?>
Now this code, is supposed to connect to the database, run a query to select everything from a table, and then print out each item in database table into a table on the page. There is one row in the database table, only when I go to the page, It isn’t printing out the row. It is showing the html that I have added other than that(I didn’t post it in with it as its unrelavent) when I view the source code, so it is the right page and everything, and It has the opening and close table tags. It just isn’t printing it out, I immagine that it would be some simple problem, but as I say, try as I might, I cannot get the hang of this function. Your Help is appreciated.
Thanks,
[B]~[I]Travis