Nandini Posted October 29, 2008 Share Posted October 29, 2008 Hi i want to display values from mysql table. Before display i want to check the conditions. like select * from astcdr where lastapp<>WaitExten and callednum<>$trunk; here $trunk is the trunk values from another table like select trunk from sip; Finally what i want to do is I want to display values from one table with, compare one table field with another table field. Can anyone send me the script. here is my script $sqlt=mysql_query("select * from sip"); while($rowr=mysql_fetch_array($sqlt)) { $t[]=$rowr['trunk']; } foreach($t as $v) { $where="where lastapp<>'WaitExten' and callednum<>$v"; } $sql=mysql_query("select * from astcdr $where"); while($row=mysql_fetch_array($sql)) { echo $row['accountcode']." ".$row['callednum']; echo "<br>"; } Link to comment https://forums.phpfreaks.com/topic/130529-solved-small-doubt/ Share on other sites More sharing options...
zenag Posted October 29, 2008 Share Posted October 29, 2008 can try this..... $sqlt=mysql_query("select * from sip"); while($rowr=mysql_fetch_array($sqlt)) { $t[]=$rowr['trunk']; } $sql=mysql_query("select * from astcdr where lastapp<>'WaitExten'"); foreach($t as $v) { $sql.=" and callednum <> '".$v."'"; } while($row=mysql_fetch_array($sql)) { echo $row['accountcode']." ".$row['callednum']; echo "<br>"; } Link to comment https://forums.phpfreaks.com/topic/130529-solved-small-doubt/#findComment-677208 Share on other sites More sharing options...
Nandini Posted October 29, 2008 Author Share Posted October 29, 2008 this is not working. Your $sql. = something. this is out of query i think. y because $sql is already with in close braces Link to comment https://forums.phpfreaks.com/topic/130529-solved-small-doubt/#findComment-677214 Share on other sites More sharing options...
zenag Posted October 29, 2008 Share Posted October 29, 2008 sorry 've done a small mistake...here u go try this out..its working for me.. $sqlt=mysql_query("select * from sip"); while($rowr=mysql_fetch_array($sqlt)) { $t[]=$rowr['trunk']; } $sql="select * from astcdr where lastapp<>'WaitExten'"; foreach($t as $v) { $sql.=" and callednum <> '".$v."'"; } $sqlquery=mysql_query($sql); while($row=mysql_fetch_array($sqlquery)) { echo $row['accountcode']." ".$row['callednum']; echo "<br>"; } Link to comment https://forums.phpfreaks.com/topic/130529-solved-small-doubt/#findComment-677267 Share on other sites More sharing options...
Nandini Posted October 29, 2008 Author Share Posted October 29, 2008 Thanq very much zenag. Its working fine. Link to comment https://forums.phpfreaks.com/topic/130529-solved-small-doubt/#findComment-677287 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.