A
Anonymous
Guest
What is the simplest way to compare a string variable with a MySQL result array?
<?php
// Your string:
$name = 'John';
$result = mysql_query("SELECT name FROM table WHERE id=8");
$array = mysql_fetch_array($result);
// Let´s say the returned 'name' is John!
// The $array will be:
// array ([0] => "John", ['name'] => "John")
// So you can do:
if($name == $array['name']){
// Do something
}
// Or...
if($name == $array[0]){
// Do something
}
?>