Forum Moderators: coopster
I'm new to PHP and I'm trying to get my head around databases at the moment. So far I have a page that kinda takes the mickey and takes a few details from you, it then creates a cookie that can be removed later. It also prompts you to add the data you gave to a database.
All this works perfectly, but when it comes to displaying the results of the database, all I can show is the first entry in the table. Can someone please tell me how I'm supposed to see all of them?
I've read other articles but they don't make much sense to me.
BTW, the database details are as follows:
Database name: visualanteorg
Table name: people
Fields: id, name, shoe_size, job
As you will see if you choose to look at the pages, getting the information out is not a problem, it's just formatting it how I want it, so each entry appears under the other in the table.
Thanks guys!
[edited by: jatar_k at 5:39 pm (utc) on July 13, 2004]
[edit reason] no urls thanks [/edit]
There's a very nice thread in the library [webmasterworld.com] here called Basics of extracting data from MySQL. [webmasterworld.com] Check that out. It shows you how to basically loop through the results and display them.
Tim
I'm sure it's really easy but I'm not grasping it yet!
maybe try this approach
Query Result Arrangement [webmasterworld.com]
basically all I did was this:
$host = "***.***.***.***";
$user = "**********";
$pass = "**********";
$dbname = "**********";
$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);
$sql = "SELECT id, name, shoe_size, job, lastvisit FROM people";
$query = mysql_query($sql);
?>
<table width="700" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>ID</td>
<td>Name</td>
<td>Shoe Size</td>
<td>Job Title</td>
<td>Time Visited</td>
<?php
while ($row = mysql_fetch_array($query)) {
echo "<tr><td>",$row['id'],"</td><td>",$row['name'],"</td><td>", $row['shoe_size'],"</td><td>",$row['job'],"</td><td>",$row['lastvisit'],"<tr>";
}
?>
</table>
All I did was drop </td><td> in between calling each entry from the database. I thought something like that would work. It may be crude but it works well in my head!
[edited by: jatar_k at 7:02 pm (utc) on July 13, 2004]
[edit reason] no personal urls thanks [/edit]
You lost me there!
BTW, I wouldn't stoop to IE's level! Check out the first page of the site and you'll see a link to my browser of choice!
Anyway, back to the point of the CSS... er, help! ;o)
[edited by: jatar_k at 8:28 pm (utc) on July 13, 2004]
[edit reason] no personal urls, thanks [/edit]