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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.