i'm using below code
<?php $site_id = '7af099d94576f8c4'; // check monitor id site id $sql = "select * status site_id='$site_id'"; $result = $conn->query($sql); while ($row = $result->fetch_assoc()) { $st_id = $row['st_id']; $mon_id = $row['mon_id']; $mon_site_id = $row['mon_site_id']; echo $mon_id; $result = mysql_query("select * monitors mon_id='$mon_id'") or die(mysql_error()); // keeps getting next row until there no more while ($row = mysql_fetch_array($result)) { // print out contents of each row echo $row['name'] . "<br />"; } } ?> and i'm getting 2 mon_id 1 , 2 next want use these 2 mon_id in 2nd select query 2nd query give me 1 result mean give result one name. how can 2nd name ?
you overwriting $result variable in second query, losing data first query. change names second query variables , you're done.
<?php $site_id = '7af099d94576f8c4'; // check monitor id site id $sql = "select * status site_id='$site_id'"; $result = $conn->query($sql); while($row = $result->fetch_assoc()) { $st_id = $row['st_id']; $mon_id = $row['mon_id']; $mon_site_id = $row['mon_site_id']; echo $mon_id; /// change here $result2 = mysql_query("select * monitors mon_id='$mon_id'") or die(mysql_error()); /// change here // keeps getting next row until there no more /// change here while($row2 = mysql_fetch_array( $result2 )) { /// change here // print out contents of each row /// change here echo $row2['name']."<br />"; /// change here } } ?>
Comments
Post a Comment