PHP & MySQL - Checking if database entry does NOT exist? -
i'm collecting birthdates of users in system, doing linking the user's unique id birthday entry in table.
to prevent users accidentally/purposefully entering 2 birthdate entries accounts, i'd remove entry form birthdays if user has entered birthday prior.
for instance:
$value = mysqli_query("select bd_user_id user_birthdate bd_user_id="$user_id";"); from data, how able homecoming form value determine if whether user's id has been index in user_birthdate or not? (where $user_id = current user's id)
or perhaps i'm taking wrong approach here? logic behind what's been getting me.
how can check if whether value not indexed in database table?
you query database did
$value = mysqli_query("select bd_user_id user_birthdate bd_user_id="$user_id";"); than utilize mysqli_num_rows(), , check if returns 0.
$num_rows = mysqli_num_rows($value); if($num_rows > 0){ //exists }else{ //doesn't exist } **sorry, devon said in case it's mysqli_num_rows not mysql_num_rows.
php mysql database compare mediawiki
No comments:
Post a Comment