petroz Posted October 1, 2009 Share Posted October 1, 2009 Hi Guys, I am having some trouble here... The last query in this script is failing to do what it I have intended..... 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()); } ?> Link to comment https://forums.phpfreaks.com/topic/176228-solved-storing-and-using-results-from-a-query-on-another-query/ Share on other sites More sharing options...
petroz Posted October 2, 2009 Author Share Posted October 2, 2009 Here was my solution... $getresp = "SELECT resp_uid FROM requests WHERE request = '$req'"; $result = mysql_query($getresp) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $respuid = ($row['resp_uid']); Link to comment https://forums.phpfreaks.com/topic/176228-solved-storing-and-using-results-from-a-query-on-another-query/#findComment-928810 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.