In PHP/MySQL 5 loops, to appear qeuries results, well can I nest queries ? What solutions exist ? This is due to the fact that, I need data from first query to input continuously to second query ?
In PHP/MySQL 5 loops, to appear qeuries results, well can I nest queries ? What solutions exist ? This is due to the fact that, I need data from first query to input continuously to second query ?
place a while loop inside a while loop... If u place an example code, then it will easy to tell you how to input data from first query to second query
Select * From $affTable;
$AID=row['AID'];
Select SUM(total) AS TOTAL From $bookingTable Where AID='$AID';
// HOW I GET EACH AFFID(=AID) FROM FIRST QUERY AND RUN SECOND QUERY TO LIST TOTAL EARNINGS(=TOTAL) ?
Hope this helps
Code:$query = mysql_query("Select * From $affTable "); while ($row = mysql_fetch_array($query)) { $AID = $row['AID']; $query2 = mysql_query("Select SUM(total) AS TOTAL From $bookingTable Where AID='$AID' "); while ($result = mysql_fetch_array($query2)) { \\do whatever you want to do with the values here } }
The:
while ($row = mysql_fetch_array($query))
may be like:
$count = @mysql_num_rows($result);
while ($i < $count) {
???
Bookmarks