I’m trying to check a database and do one thing depending on the results of a query. If there are ten or more entries then I want to basic tell people they can’t progress. If there’s less than ten then I want them to be able to progress…
This is what I’ve got so far
<?php
$query="select COUNT(customer_id) as cnt from orders where country=\"USA\"";
$result=dbselect( $query,"dbLinkInt" );
if( $result[0]['cnt'] >=3 ) { $exists=1; }
......
if( $exists!=1 ) {
execute code here
}
?>
<?php if($_GET['commit']==1 ) { ?>
This works
<?php } elseif( $_GET['commit']==1 && $exists=1 ) { ?>
This doesn't work
<?php } else { ?>
This works
} ?>
I thought it was from this line:
query=“select COUNT(customer_id) as cnt from orders where country="USA"”;
$result=dbselect( $query,“dbLinkInt” );
if( $result[0][‘cnt’] >=3 ) { $exists=1; }
The reason I though that was the best way of doing it is because if it’s 1 then I’ll send them to one place and if it’s not then I’ll send them else where
Executing it directly against the database, sure. But when running it in php, you need to assign it to a variable to be able to access it…
(I’m sure there’s a better way since my php is so rusty, but this is the general gist. You’d need to insert this right after the dbselect statement (I’m assuming that method does a mysqli query):
I changed the var_dump to show $exists instead and it showed 1 (it shows NULL if the number is less than 10) which is correct. So it looks like it’s this part that’s not working: