PHP/MySQL Tutorial - PHP MySQL Connection
Step 5:
How to Select Individual Records
As well as showing the whole database, PHP can be used to select individual records, or records which match certain criteria. To do this you must use a variation of the SELECT query. To display the whole table you used the query:
SELECT * FROM tablename
If we just wanted to select ones which have value=1 in the field1-name row you would use the following query:
SELECT * FROM tablename WHERE fiels1-name='1'
As with other MySQL queries, it is almost like plain English text. In the same way you could select records based on any field in the database. You can also select ones with more than one field by adding more:
field='value'
sections onto the query.
For further reference you can visit the official websites of PHP and MySQL.
|