sm21guy
sm21guy

Reputation: 626

php get specific data from the same column in all row

i have a php question, how can i get all the data from the same column from all row in a mysql table.

Table name : user
Here's my table structure:
name
url

How can i use php to get all the data in URL column from each row? (P/S i have my connection to database established , just not sure the musql query for this)

Thanks and have a nice day.

Upvotes: 0

Views: 1457

Answers (2)

Derk Arts
Derk Arts

Reputation: 3460

This really is extremely basic stuff and you could have found this anywhere, it's even in the PHP manual. But alas, here you go.

$result = mysql_query("SELECT url FROM user");
while($row=mysql_fetch_assoc($result){
   echo $row['url'].'\n';
}

Please read up on some basic stuff to avoid asking these kind of questions: http://www.freewebmasterhelp.com/tutorials/phpmysql

Upvotes: 3

jogesh_pi
jogesh_pi

Reputation: 9782

$query = "select url from user";
$result = mysql_query($query);

while( $row = mysql_fetch_assoc($result)){
echo $row['url'] . '<br>';
}

Upvotes: 1

Related Questions