Jump to content

retrieving data from MySQL table


thunderbox

Recommended Posts

hey guys.. im having a little trouble getting data from my database to the script... i realy dont know how to do it..

im making a very simple blog site, which is more like a bulletin site in which people can leave comments but only after they register

i have been successful in getting both the user to register and getting the blog they post into the database, but i don't know how to display the database on the main page..

how would i do this?

btw. my database has 4 fields that need displaying

username, date, title and content.. and im not sure if i should put the unique ID in there.. so if someone could figure out how to put those details into variables.

i had a small idea of how to do this but im not sure on how to do it for every post, i think it is done through looping but i am not sure.

thanks for your help, im a complete newbie (4 days of programming)
Link to comment
https://forums.phpfreaks.com/topic/28969-retrieving-data-from-mysql-table/
Share on other sites

You can do this in a couple of ways.  I would probably issue a select command "select * from blog_entries where..." and then loop through the entries in php:

$query = "select * from blog_entries where...";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result)){
  //html format code here
}

Anyone have a more eloquent solution?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.