I am trying to pair every new user to another user from two different tables .i.e Tables 1 Men, Table 2 Women, using the registered user data. My problem is if there no users in Men then the query should look into Women table and find match based on time in ascending order using 24hours timeline
$query = "INSERT INTO tb_users (username, password, ip, email, bank, norek, nama, namalengkap, alamat, kota, country, kodepos,
phone)
VALUES('$username','$pass','$laip','$email','$bank','$norek','$nama','$namalengkap','$alamat', '$kota', '$country','$phone')";
mysqli_query($query)
// To Find Match from Here using readygh and 24 hours timelin
if(mysqli_num_rows($gh =mysqli_query("select * from tb_gh where readygh='1' ORDER BY datetime ASC",$con))>0){
$row=mysqli_fetch_array($gh);
//Extract Data if match found in tb_gh query should Stop Here But If Not Found
}
else //Then Query should Search Find Match in tb_users
{
$ghadmin = mysqli_query("Select * from tb_users where username='admin' ORDER BY id DESC limit 1");
$ghadmin_row=mysqli_fetch_array($ghadmin);
while(mysqli_num_rows ==1)
$ghadm_username =$ghadmin_row['username'];
$ghadm_fname =$ghadmin_row['namalengkap'];
$ghadm_phone =$ghadmin_row['phone'];
$ghadm_bank =$ghadmin_row['bank'];
$ghadm_acc_num =$ghadmin_row['norek'];
$ghadm_acc_name =$ghadmin_row['nama'];
// Elseif // Match Fo
//If Match found in
$admph = mysqli_query("INSERT INTO tb_match(idtrx,ph_username,ph_phone,gh_username,gh_name,gh_acc_name,gh_acc_number,gh_phone)
VALUES ('uniktrx','$username','$phone','$ghadm_username','$ghadm_fname','$ghadm_acc_name','$ghadm_acc_num','$ghadm_phone'",$con);
exit;
}
?>