Jump to content

[SOLVED] small doubt


Nandini

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.