This topic is locked

Compare value with another table

1/7/2008 10:07:13 AM
PHPRunner General questions
F
funkfish author

Hello,
I want to have one of my columns value to be compared with another table column so if anything from allissues exists, then show "Yes" otherwise "No".
Example of what I have right now, my output is No for everything, but should be Yes for some.
// Issue -

$value="";

$value = ProcessLargeText(GetData($data,"Issue", ""),"field=Issue".$keylink,"",MODE_LIST);

global$conn;

$strSQLExists = "select * from allissues where ordernumber =$value";

$rsExists = db_query($strSQLExists,$conn);

$data1=db_fetch_array($rsExists);

if($data1)
$row[$col."Issue_value"]="Yes";
else $row[$col."Issue_value"]="No";
Thank in advance!

T
tototoo 1/7/2008

I think you need a couple sets of curly braces in that If statement. Without them, the Else condition is always being executed.

J
Jane 1/9/2008

Hi,
try to use this code:

// Issue -

$value="";

$value = ProcessLargeText(GetData($data,"Issue", ""),"field=Issue".$keylink,"",MODE_LIST);

global $conn;

$strSQLExists = "select * from allissues where ordernumber =$value";

$rsExists = db_query($strSQLExists,$conn);

if($data1=db_fetch_array($rsExists))

$row[$col."Issue_value"]="Yes";

else

$row[$col."Issue_value"]="No";

F
funkfish author 1/9/2008

Hi there,
I tried what you recommended and got the error "error in Syntax near " " so I fixed that by changing

$strSQLExists = "select from allissues where ordernumber =$value";
to
$strSQLExists = "select
from allissues where ordernumber ='$value' ";
but now everything is still coming up as "No".

I verified that there are values in allissues.ordernumber that match Issue.
So I hard coded the following:

$strSQLExists = "select * from allissues where ordernumber =47170127";
and everything comes up as "Yes".
Any thoughts?
Thank you!

Hi,

try to use this code:

J
Jane 1/11/2008

Hi,
it's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and post a URL to your pages here or send it to [email=support@xlinesoft.com]support@xlinesoft.com[/email] along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.