php - Using a while loop on a query -


i have following query, problem following:

 $insert_email = "select * customers"; $run_email = mysqli_query($con, $insert_email);  $find_email = mysqli_fetch_array($run_email); $demail = $find_email['customer_email'];  echo $demail; 

my problem @ current state returns first item in customers table, want return of customer_email in row , not first one.

this because later want compare it

if($email!= $demail){ 

where if email entered user during registration found in database tell user email in use throwing in else statement.

update:

$insert_email = "select * customers customer_email='$email'"; $run_email = mysqli_query($con, $insert_email); if(mysqli_num_rows($run_email)>0){      $crs_id = $_get['crs_id'];     $_session['usercoupon'] = $_post['couponcoderegisteramount'];     $_session['usercouponname'] = $_post['couponcoderegister'];           $_session['customer_email']=$email;            $insert_c = "insert customers (customer_fname,customer_lname,customer_email,customer_pass,coupon_code_register,coupon_code_register_amount) values ('$fname','$lname','$email','$pass','$couponcoderegister','$couponcoderegisteramount')";          $run_c = mysqli_query($con, $insert_c);            echo "<script>window.open('coursepage.php?crs_id=$crs_id#attend','_self')</script>";           echo "<script>           document.getelementbyid('registererror').innerhtml = 'account has been created successfully, thanks!'          </script>";  }  else {     echo "<script>window.open('coursepage.php?crs_id=$crs_id#attend','_self')</script>";      echo "<script>         document.getelementbyid('registererror').innerhtml = 'this email has been taken. please use one.'        </script>"; } 

while ($find_email = mysqli_fetch_array($run_email)) {   if($email == $find_email['customer_email']){  } } 

or better use this:

$insert_email = "select * customers customer_email='".$email."'"; $run_email = mysqli_query($con, $insert_email); if (mysqli_num_rows($run_email)>0){} else {echo 'no customers found email!'; } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -