I have two tables :: orders and order_details, in db mobile_phones. Let say somebody makes an order, all the information goes to:
order --> ID, user_ID, email, address, postal_code, province, country, date_stamp
order_detail--> ID, FK_order, brand, price, quantity, date_stamp
I wanna display them in a page. ID and FK_order are the FK. I'd like to ave 4-5 orders in 2 page, then there's button next or previous. How do I do that?
$query= sprintf("SELECT * FROM ........?");
Foreign Key with two tables
Moderator: General Moderators
Are you using MySQL? If so there is a LIMIT keyword you can attach to the query:
returns only the first 5 results
shows only results 6 to 15 (start at 5, return 10 records).
You can pass a parameter in the URL to use as the offset. (http://www.mysite.com/orders.php?start=10) for example.
Hope this helps
Code: Select all
SELECT * FROM table LIMIT 5;Code: Select all
SELECT * FROM table LIMIT 5,10;You can pass a parameter in the URL to use as the offset. (http://www.mysite.com/orders.php?start=10) for example.
Hope this helps
Code: Select all
SELECT *
FROM order o, order_detail d
WHERE o.id = d.fk_order