Jump to content

Recommended Posts

I'm getting an array, and I want to use use each result in a subsequent query, but I'm not sure how to name the returned array to place it in the second query.  So I'm trying to get license to equal all the results echoed in $row5['License_Num'] and echo whatever the second query returns.  Stumped.

 

<?php
<?		if ($result["r_approved"] == "APPROVED")    // transaction processed successfully
	// check demo table if Initiator is reporter to see if they have a demo license:
{
$query5 = ("SELECT License_Num FROM demo_details WHERE ((RFirstName like '%$FName1%' AND RLastName like '%$LName1%') OR (REmail = '$billing_email') OR (SFirstName like '%$FName1%' AND SLastName like '%$LName1%') OR (SEmail = '$billing_email'))");
$result5 = mysql_query($query5) or die(mysql_error());
while($row5 = mysql_fetch_array($result5)){
echo $row5['License_Num'];
echo "<br />";

//check trial license table to see if any results from 1st query exist 
$query6 = ("SELECT license FROM triallics WHERE license = '???'");
$result6 = pg_query ($query6);
$row6 = pg_fetch_array ($result6);
echo $row6['license'];

}

echo "you have some rows";

}

?>

 

As always, any help is GREATLY appreciated!

Create a comma delimited string  like this:

<?php
$myString="";
while($row5 = mysql_fetch_array($result5)){
    $myString.="'".$row5['license_Num']."',";
}
?>

 

which will create a String like this: 'string1','string2',etc...

 

then in your SQL use the 'IN' command like so:

<?php
$query6 = ("SELECT license FROM triallics WHERE license IN (".$myString."));
?>

 

or, to get a single license, do the same this but as so:

<?php
$myString="";
while($row5 = mysql_fetch_array($result5)){
    $myString =$row5['license_Num'];
    $query6 = ("SELECT license FROM triallics WHERE license = $myString");
// echo as needed
}
?>

Still not getting any output for $license6 .  Wasn't sure how to use Ken's substring.  I know there's at least one value, because when I make license = 'value' , it spits it out.

 

<?php
$query5 = ("SELECT License_Num FROM demo_details WHERE ((RFirstName like '%$FName1%' AND RLastName like '%$LName1%') OR (REmail = '$billing_email') OR (SFirstName like '%$FName1%' AND SLastName like '%$LName1%') OR (SEmail = '$billing_email'))");
$result5 = mysql_query($query5) or die(mysql_error());
$myString="";
while($row5 = mysql_fetch_array($result5)){
    $myString.="'".$row5['License_Num']."',";
echo $row5['License_Num'];
echo "<br />";

//check trial license table to see that they're still in there
$query6 = pg_query("SELECT license FROM triallics WHERE license IN (".$myString.")");
$getarray = pg_fetch_assoc($query6);
$license6 = $getarray['license'];
echo $license6 ;
}
?>

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.