php,mysql, help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
newbie5050
Forum Newbie
Posts: 2
Joined: Wed Jul 18, 2007 8:32 pm

php,mysql, help

Post 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!!!!
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

The first step is to connect to the database server...

http://www.php.net/manual/en/function.mysql-connect.php
newbie5050
Forum Newbie
Posts: 2
Joined: Wed Jul 18, 2007 8:32 pm

Post 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!!
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

This will work, although not very well...

Code: Select all

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