PHP question
- Started
- Last post
- 7 Responses
- Diaz
Hi!
I'm searching for a way to have a list that is being fetched from a database, display the headline for each row.
Simple example:
(Lets say we table named Cars)
USA
- Ford
- Mustang
France
- Citroen
England
- MiniHow do I in a single table have the respective headlines appear for each car brand?
Thanks in advance,
Alonso Diaz
- Lillebo0
// Connect to server
$connection = mysql_connect(host, username, password);// Select database
mysql_select_db('db_name', $connection);// Query database for table data
$query = "SELECT * FROM table_name";
$query_result = mysql_query($query);// Output data
while ($row = mysql_fetch_assoc($query_result... {
echo $row['headline'];
}// Close connection
mysql_close($connection);- Typo on 12th line. The three dots should be a closing parenthesis.Lillebo
- Diaz0
The answer above only gives me the headlines... I still want the rows to appear. They should appear in this order:
Headline
- Row detail
- Row detail
Headline
- Row detail
- Row detailI guess I have to do some for loop inside or something.
- Lillebo0
"Hi, how do I build a website? Thanks xD"
Try www.stackoverflow.com. Over there users at least get points for holding your hand...
- 3030
exit();
- spraycanII0
yes and dont post code here , because iT does NOT WORK FFS
- welded0
You might want to start with the basics. What you want is easy to do but you have a few things to learn first.
http://www.tizag.com/mysqlTutori…If you're feeling brave, keep the countries in a separate table than the manufacturers and use a join to connect them. If it *needs* to be a single table for whatever reason, it's not a huge deal, but joins are a powerful tool if you're learning SQL.
- section_0140
That's php 101 dude. Get a book or google "php mysql basics"