Wednesday, 25 September 2013

Issue with else statement

Issue with else statement

I have the code below to retrieve row from the database, but if I enter id
that doesn't exist in the database in 'assign_id_input', it won't execute
the else statement and display out 'Error'.
$assign_id_input = $_POST['assign_id_input'];
$search_assign_user_id = mysql_query("SELECT * FROM free_ebook WHERE useid
= $assign_id_input;")or die(mysql_error());
while($assign_user_id_array = mysql_fetch_array($search_assign_user_id,
MYSQL_ASSOC)) {
$filtered_assign_user_id_array = array_filter($assign_user_id_array);
if(count($filtered_assign_user_id_array) > 0) {
echo 'No Error';
}
else{
echo 'Error';
}
}

No comments:

Post a Comment