Hi,
I have a mysql query like this
select * from org_app where app_beg <= '2009-09-23 00:00:00' order by app_beg desc limit 10
I have no idea, how do I print all the 10 values into a page? Here is what I am doing. I have a index.php page in which, I am including this file which has this database script.
Any help will be appreciated.
Thank you,
how to print 10 records from mysql using php
Moderator: General Moderators
Re: how to print 10 records from mysql using php
You want to execute the query using mysql_query(). That'll give you a result set.
You want to iterate through that result set using mysql_fetch_array(), mysql_fetch_assoc(), or mysql_fetch_object() - pretty much your choice.
In the loop, output everything your mysql_fetch_*() function returned.
You want to iterate through that result set using mysql_fetch_array(), mysql_fetch_assoc(), or mysql_fetch_object() - pretty much your choice.
In the loop, output everything your mysql_fetch_*() function returned.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: how to print 10 records from mysql using php
Thank you for replying.
Yes, You are right I dont know how to iterate through mysql_fetch_array(). I know this might sound silly but I have not seen an example before, so have no idea.
Can you please show me a tutorial where this is done?
Thank you,
Yes, You are right I dont know how to iterate through mysql_fetch_array(). I know this might sound silly but I have not seen an example before, so have no idea.
Can you please show me a tutorial where this is done?
Thank you,
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: how to print 10 records from mysql using php
If you went to any those mysql_fetch_* pages you would see a plethora of examples.