Forum Moderators: coopster

Message Too Old, No Replies

Reading out the data from a table, should actually be simple

         

SteveJobs

5:22 pm on Aug 1, 2004 (gmt 0)



Hello.
Well, it's what the subject says. I want to read out all the data from the table sprachen, where the data in the column German is supposed to be Garten. But it does not work. Only the top row is displayed, with the names of the languages (I am building a sort of private dictionary, nothing big). The error_log of my apache tells me the argument in the mysql_num_rows was not a valid MySQL resource.

I am rather new to PHP, albeit not new to programming since I can write some Java and SQL, since we did that at school.

That's the code:
<html>
<body>
<?PHP
$db = mysql_connect() or exit("Keine Verbindung hergestellt!");
mysql_select_db("testdb",$db);
$tab = "sprachen";
$sqlbef = "SELECT * FROM " . $tab . " WHERE German = Garten";
$sqlerg = mysql_query($sqlbef, $db);
$anz = mysql_num_rows($sqlerg);
$feldliste = mysql_list_fields("testdb", $tab, $db);
$feldanz = mysql_num_fields($feldliste);
mysql_close($db);

echo "<table border>";
echo "<tr>";
for ($h=0; $h<$feldanz; $h=$h+1)
{
$f = mysql_field_name($feldliste, $h);
$f = strtoupper($f);
echo "<td>$f";
}
echo "</tr>";
for ($i=0; $i<$anz; $i=$i+1)
{
echo "<tr>";
for ($j=0; $j<$feldanz; $j=$j+1)
{
$f = mysql_field_name($feldliste, $j);
$v = mysql_result($sqlerg, $i, $f);
echo "<td>$v</td>";
}
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>

Can you help me?

Thanks in advance,
Steve

lorax

7:46 pm on Aug 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>> WHERE German = Garten

should be

WHERE German = 'Garten'

for starters