Page 1 of 1
Simple prob, Pulling data from MySQL
Posted: Wed Jan 21, 2004 3:23 am
by seeker2921
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
Posted: Wed Jan 21, 2004 3:27 am
by twigletmac
First you need to decide what data you want to display and write a SQL statement that will gather that data from the database. Then it's a case of looping through the result and outputting it into HTML tags. Have you made a start on the code because we can then help you a bit better.
Mac
Posted: Wed Jan 21, 2004 3:01 pm
by seeker2921
All I have is the connection to the Database, I wasn't sure on what I needed to do in order to get the data out of the database..
Posted: Thu Jan 22, 2004 3:07 am
by twigletmac
First thing you need is an SQL SELECT statement, something like:
Code: Select all
SELECT field1, field2, field3 FROM my_table
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