I'm unsure whether to use 'while' or 'for each' for this code.
I have a mysql query that will bring back more then one result.
I then, for each result, want to do a certain thing if $row[number]
is empty or not
I have this:
$sql = "SELECT * FROM $tbl_name WHERE username=\"$myusername\"";
$result=mysql_query($sql);
$numResults = mysql_num_rows($result);
if ($numResults = 0) {
header ("Location: /sms_error.php?error=no_adders");
}
while($row = mysql_fetch_array($result)) {
$number1=$row["number"];
if (!empty($number1)) {
}
if (empty($number1)) {
}
This is coming up with completely blank for $number1 (even though there is data on the db).
Everything up to that is correct, $myusername and the mysql query doesn't return empty.
So should it be mysql-fetch-assoc or -array and should it be while or for each??
thanks, Niall