CodeMama Posted March 2, 2009 Share Posted March 2, 2009 I need to use the results of one query in the WHERE parameters of another..JOIN? $query = "SELECT `UserName`, `AdminID` FROM admin WHERE Key1 = 'YES' "; $result = mysql_query ($query) ; $row = mysql_fetch_assoc($result); //Reveal Variables for Debugging // include("VariableReveal2.php"); echo ("Hello <br>"); //echo $row['AdminID']; echo ($row); if ($row['Key1_PM'] == "NO") { header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do not have access to that page."); } if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy = 'WorkOrderID DESC';} if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;} $PerPage = 30; $StartPage = ($Page - 1) * $PerPage; $sql= "SELECT * FROM workorders WHERE AdminID = '$row' "; // $sql .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage"; $result = mysql_query ($sql); $row2 = mysql_fetch_assoc($result); $Total = ceil(mysql_num_rows($result)/$PerPage); Thanks in Advance Link to comment https://forums.phpfreaks.com/topic/147644-help-with-joining-or-getting-my-syntax-right-on-this-query-of-two-tables/ Share on other sites More sharing options...
dreamwest Posted March 3, 2009 Share Posted March 3, 2009 Not sure if this is what your after... Just name each query with a different name and the rows consecutively $query = (blablabla); $row ['bla']; //new query with 1st query results $includes = $row ['bla']; $query2 = (blablabla $includes); $row2 ['blabla']; Link to comment https://forums.phpfreaks.com/topic/147644-help-with-joining-or-getting-my-syntax-right-on-this-query-of-two-tables/#findComment-775343 Share on other sites More sharing options...
fenway Posted March 3, 2009 Share Posted March 3, 2009 Not sure if this is what your after... Just name each query with a different name and the rows consecutively $query = (blablabla); $row ['bla']; //new query with 1st query results $includes = $row ['bla']; $query2 = (blablabla $includes); $row2 ['blabla']; Um, no. SELECT * FROM admin AS a INNER JOIN workorders USING ( AdminID ) WHERE a.Key1 = 'YES' But I realy hope you're not doing all of that just for a count! Link to comment https://forums.phpfreaks.com/topic/147644-help-with-joining-or-getting-my-syntax-right-on-this-query-of-two-tables/#findComment-775350 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.