Reputation: 626
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
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
Reputation: 9782
$query = "select url from user";
$result = mysql_query($query);
while( $row = mysql_fetch_assoc($result)){
echo $row['url'] . '<br>';
}
Upvotes: 1