php - mysql query doesn't work inside loop -
i have written code`
$serial_no = 1; while($rowss = mysqli_fetch_array($selectquery)) echo $rowss['work_date']; $mauzanameqry = mysqli_query($conn,"select moza_name moza_names mauza_id =1"); echo mysql_error(); $mauzanamerslt = mysqli_fetch_array($mauzanameqry); `echo $rowss['work_date']; `
it not return me in $rowss[] array when write query of select inside loop have written above select query inside while loop selects data moza_name table. $rowss[] shows data if remove inside query of moza_name table. doesn't show error's.
i'm not sure trying do, may it?
<?php $serial_no = 1; while($row = mysqli_fetch_array($selectquery)) { echo $row['work_date']; } $mauzanameqry = mysqli_query($conn,"select moza_name moza_names wehre `mauza_id`='1'") or die(mysqli_error($mauzanameqry)); while($row = mysqli_fetch_array($mauzanameqry)) { echo $row['work_date']; } ?>
update:
are trying nested loop?
<?php $serial_no = 1; while($rowss = mysqli_fetch_array($selectquery)) { echo $rowss['work_date']; $mauzanameqry = mysqli_query($conn,"select moza_name moza_names `mauza_id`='1'") or die(); while($mauzanamerslt = mysqli_fetch_array($mauzanameqry)) { echo $mauzanamerslt['work_date']; } } ?>
update 3:
<?php $userid = 1; //id search $id = mysqli_query($conn,"select * work_sheet `mauza_id`='$userid'") or die(); //get id , if doesn't exist, exit $idfromtable1 = $id['moza_id']; // set correct id table1 $mauzanameqry = mysqli_query($conn,"select * moza_names `mauza_id`='$idfromtable1'") or die(); //check table1's correct id on table2 echo $mauzanamerslt['moza_name']; //echo name table1's id ?>
Comments
Post a Comment