Forum Moderators: coopster
First the code:
$region = mysql_query('SELECT * FROM `regions` WHERE 1');
if (!$region) {
die('Invalid query: ' . mysql_error());
}
echo "<br>";
echo "
<div style=\"margin-bottom: 10px; width: 100%; height: 149\">
- <b>Total Population</b>: ".number_format($region['total_pop'])."
<br>
<b>R</b>: ".number_format($region['total_R'])."
<br>
<b>C</b>: ".number_format($region['total_C'])."
<br>
<b>I</b>: ".number_format($region['total_I'])."
<p> It should not return zero, but it does! I assume the problem has something to do with:
$region = mysql_query('SELECT * FROM `regions` WHERE 1');
$region = mysql_query('SELECT 1 FROM regions');
doesn't work either
Any ideas?
-thanks in advance
just saw that you forgot to actually fetch your row from the result identyfier. See [de3.php.net ]
for more info.
Try something like
...
mysql_connect("hostname","user","password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
//
$sql = "SELECT * FROM regions";
$query = mysql_query($sql);
//
if ($query) {
while ($row = mysql_fetch_row($query)) {
... your code here
}
} else {
die("NULL query: $sql");
}
...
Hope this helps.
Regards
Markus