Re: PHP & MySql if....
Dak
I'm pretty sure I get most of the picture, unfortunately you will need to alter your database structure to get the desired results. First you need to familiarize with the database syntax: Database, Table, Field, records, etc... Makes it easier for you to understand exactly what I am suggesting.
About the structure... You should never create table fields by "Guessing" how many vendors and orders you will have.
It sounds like you need two tables:
1. Vendors
2. Orders
The table Vendors should have these type of fields(columns):
vendor_id(auto-increment) Primary Key
vendor_name
vendor_description
etc...
The table Orders should have these types of fields(columns):
order_id(auto-increment) Primary Key
vendor_id (reference to the vendor_id in table Vendors)
order_date
order_time
order_total
etc...
When a vendor is logged in he/she should have a vendor id. When they hit the submit button a query should run in your database:
INSERT INTO `Orders` VALUES(' ',vendor_id,date,time,total, etc)
When you want to view the data you would run queries such as:
SELECT order_id, order_date, etc... FROM `Orders` WHERE vendor_id="any_id" ORDER BY time DESC LIMIT 3
This would return the newest three orders from the vendor you specify. LIMIT controls the MAX number of results.
Is this more along the lines of what you are looking to do?
Hope im getting warmer.
Derek
|