Jump to content

[SOLVED] storing and using results from a query on another query


Recommended Posts

Hi Guys,

 

I am having some trouble here... The last query in this script is failing to do what it I have intended..... :confused:

 

I would like this query to take the results/$row from the query directly above and then use $row as a variable in the final UPDATE SELECT query.... Any help would be greatly appreciated.

 

Thanks,

P

 

 <?php

$request = $_GET['req'];
$requid = $_GET['requid'];

include "db.php";

$status = '2';

$connection = mysql_connect($host,$user,$password) 
or die ('Couldn?t connect to server.');

$db = mysql_select_db($database,$connection) 
or die ('Cannot Find DB'); 

$introduce = sprintf("SELECT name, organization, email, phone, url, im, address, image FROM users WHERE uid='$requid'",
mysql_real_escape_string($requid));

$contactinfo = mysql_query($introduce);

if (!$contactinfo) {
die("Invalid contactinfo query: " . mysql_error());
}

while($row = mysql_fetch_array($contactinfo))

{

$stringData = $row['name'];
printf($stringData . "«");

$stringData = $row['organization'];
printf($stringData . "«");

$stringData = $row['email'];
printf($stringData . "«");

$stringData = $row['phone'];
printf($stringData . "«");

$stringData = $row['url'];
printf($stringData . "«");

$stringData = $row['im'];
printf($stringData . "«");

$stringData = $row['address'];
printf($stringData . "«");

$stringData = $row['image'];
printf("https://mydomain.com" . $stringData . ".png");

}

$getresp = "SELECT resp_uid FROM requests WHERE request = '$req'";	

$result = mysql_query($getresp) or die(mysql_error());

while($row = mysql_fetch_array($result)){

//print_r($row);

$accept = "UPDATE requests2 SET `status` = '$status', `resp_name` = (SELECT `name` FROM `users` WHERE `uid` = '$row'), `resp_organization` = (SELECT `organization` FROM `users` WHERE `uid` = '$row'), `resp_email` = (SELECT `email` FROM `users` WHERE `uid` = '$row'), `resp_phone` = (SELECT `phone` FROM `users` WHERE `uid` = '$row'), `resp_url` (SELECT `email` FROM `users` WHERE `uid` = '$row'), `resp_im` = (SELECT `im` FROM users WHERE `uid` = '$row'),  `resp_address` = (SELECT `address` FROM `users` WHERE `uid` = '$row')"; 

$acceptresult = mysql_query($accept) or die(mysql_error());

}

?>

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.