PHP/MySQL query ?
- Started
- Last post
- 10 Responses
- YourClient
Can somebody steer me on the right way to query multiple data from a MySQL database using PHP:
I want to give some records multiple values, like for example:
I have a portfolio divided into three categories:
Flash
Static
Data SourcesSome sites belong to two or all three of this categories, how can I build my database so I can add multiple categories to each site?
Just give me some terminology for this to Google it, or a site with a tutorial.
Thanks a lot!!!
- Nematoth0
in your 'type of site' table just list the 3 three entries for the site if it is in 3 different categories.. one after the other..
- ********0
Very basically, I would set up the fields like isFlash, isStatic, etc, and populate those with true and false for each record.
Retrieve with like...
eg for just static projects...
SELECT * FROM tablename WHERE isStatic='true'
or for multiple...
SELECT * FROM tablename WHERE isFlash='true' AND isStatic='true'.Doing something similar at the moment..
- YourClient0
Woa, now I have some good ideas, thanks guys!!!!!!!!!!!!
- Nematoth0
yup mito.. thats another way of doing it.. :)
(prob better)
*runs back to do some designing
- ********0
lol- yeah, better then trying to officially 'relate' tables and so on, I've found.
What with not really being able to do that properly.
- unfittoprint0
create a table named categories [4 ie], each record should have unique ID [1,2,3,4]. Add a 'name' field to the table, to identify each category [ID1's name = Flash, ID2's name = Static...]...
Then create a table with your work items [ie. folio]. Each record should contain [besides of an auto-increment unique ID, like in the example above], a name, description and a number relating to the cateogory it belongs: in table folio, a record for a flash site should have as categoryID the same number used in by the category Flash in the categories table.
NT's PVN forum uses the same logic. Connections between tables are the core of complex database driven sites.
A good read: http://www.amazon.com/exec/obido…
- ********0
thats a good read, that..
I bought it a couple of weeks back and sat outside a coffee shop inthe mall necking double-shot white chocolate moccacinos.
The time flew by and not one cute girl disturbed me as I read.Girls dont like php round here.
- ********0
They also seem to 'glaze over' when you rant on about non-compliant browsers, tabbed browsing, Opera's quirky interpretation of 'float:right' and the intricacies of dynamically creating and styling text fields in MX.
Sure you'll call me again.
Pah.
- unfittoprint0
C++ girls are hot.
not a myth.
- ********0
I've got that book, and while it's good, it's got some inexcusable errors in it which really threw me as a newbe to php/sql...