I am making an application for people to sell items and make product offers. If a user views their product offers, it must contain each offers information, as well as details of each user for that offer.
First tell the database which offers need to be queried, activated by an ajax onclick function. (ive got that)
Second, query the OFFERS table for offers with status 'o' and a PID equal to the $_GET['pid']
(5).
OFFERS
------------------------------
| uid | pid | status | price |
------------------------------
| 5 | 5 | o | 49 |
| 7 | 5 | o | 45 |
------------------------------
Then query the USERS table for information based on each offer? After that, for each result, based on the the UID, query the users table for information related to the user.
USERS
-------------------------------------
| uid | fname | lname | rating |
-------------------------------------
| 5 | John | Jan | 4.3 |
| 7 | Mark | Mull | 4.2 |
-------------------------------------
Here is a snippet of my PHP statement to the database.
$stmt = $conn->prepare('SELECT offerdate,price FROM offers WHERE pid=? AND status=?');
$o = 'o';
$stmt->bind_param('is', $_POST['pid'],$o);
$stmt->execute();
$stmt->bind_result($offerdate,$price);
The other statement I need
$stmt = $conn->prepare('SELECT fname,lname,rating, FROM users WHERE uid=?');
$stmt->bind_param('i', );
$stmt->execute();
$stmt->bind_result($fname,$lname,$rating);
Any help would be awesome, thank you!