Page 1 of 1

php,mysql, help

Posted: Wed Jul 18, 2007 8:52 pm
by newbie5050
hi guys,
For an assignment i need to randomly load 2 sets of information (name,phone,address) from a mysql database, so as to appear in boxs on a main page. e.g......

| name | | name2 |
| phone | | phone2 |
| address | | address2 |

the database that i have at the minute is just one table containing the above three variables
any help will be much appreciated as i have no idea where to start!!!
cheers!!!!

Posted: Wed Jul 18, 2007 8:55 pm
by Benjamin
The first step is to connect to the database server...

http://www.php.net/manual/en/function.mysql-connect.php

Posted: Wed Jul 18, 2007 11:04 pm
by newbie5050
Hi! thanks for your reply, sorry i should have mentioned that everything regarding connecting to the database with php is working, i just dont know how to go about acheiving what i mentioned above
cheers!!

Posted: Wed Jul 18, 2007 11:16 pm
by Benjamin
This will work, although not very well...

Code: Select all

select * from tablename order by rand() limit 2;