Simple prob, Pulling data from MySQL
Moderator: General Moderators
-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
Simple prob, Pulling data from MySQL
I need help on pulling my data from my database, I looked at all the functions for MySQL on the php.net site and found no help (mostly just confused me) I have a simple form that outs data into a table and I need to make a page that will display that data Thanks for your help
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
First thing you need is an SQL SELECT statement, something like:
would select information for field1, 2 and 3 from each row in my_table. I find phpMyAdmin useful for testing to see if the statement I'm writing works how I would expect. For more info on writing a SELECT statement (and lots of examples):
http://www.mysql.com/doc/en/SELECT.html
Once you've got that working then you can write your script, you start with [php_man]mysql_connect[/php_man](), then [php_man]mysql_select_db[/php_man]() and [php_man]mysql_query[/php_man](). Then you can use [php_man]mysql_fetch_assoc[/php_man]() to get the information for each row whilst looping through the result from mysql_query(). Finally you can add the HTML to format the display as needed.
If you make a start and have a go we'll help you as much as we can - a tutorial would likely be a good place to start (http://www.devshed.com).
Mac
Code: Select all
SELECT field1, field2, field3 FROM my_tablehttp://www.mysql.com/doc/en/SELECT.html
Once you've got that working then you can write your script, you start with [php_man]mysql_connect[/php_man](), then [php_man]mysql_select_db[/php_man]() and [php_man]mysql_query[/php_man](). Then you can use [php_man]mysql_fetch_assoc[/php_man]() to get the information for each row whilst looping through the result from mysql_query(). Finally you can add the HTML to format the display as needed.
If you make a start and have a go we'll help you as much as we can - a tutorial would likely be a good place to start (http://www.devshed.com).
Mac