$query = "SELECT cat FROM db WHERE pound=$loc"; //find where else cat lives $result = mysql_query($query, $db); if (!$result) { echo "Error connecting to table<br>\n"; } else { if ($row = mysql_fetch_array($result)) { while ($row){ <---is this valid? if $loc == $row['pound'] { //another pound? echo "Error: This cat already has a home!<br>"; $cat=$row['cat']; echo "$loc : $cat"; } } }
$result = mysql_query($query, $db); $column_count = mysql_num_fields($result); //this is per table
but I want to loop through records searching for specific fields in a table.
You mean like: $result = mysql_query($query, $db);
while($rows = mysql_fetch_rows($result)) { $id = $rows[0]; ... }
?
It would help if you just asked a clear question.