I am not exactly an expert and not a newbie either. I have been working with MySQL lately and am trying to figure something out.
Here's an example of what I am trying to do.
I have a table with 3 columns (name,occupation,email). I want to pull the data from the database and list it in a table. I can do this easily with multidimensional arrays, but can't figure out how to get the data from the database to the array. Below is an example of the code that I have with the array:
<head>
<title>Test</title>
</head>
<body>
<?php
$users = array (
array ( name=>"Joe User",
occupation=>"Web Developer",
email=>"joeuser@mydomain.com" ),
array ( name=>"Jane User",
occupation=>"Photographer",
email=>"janeuser@mydomain.com" ),
array ( name=>"Susie Homemaker",
occupation=>"Home Maker",
email=>"susie@homemaker.com" )
);
echo "
<table border=1 cellpadding=2>
<tr>
<td>Name</td>
<td>Occupation</td>
<td>E-mail Address</td>
</tr>
";
foreach ( $users as $val )
{
echo("<tr>");
foreach ( $val as $key=>$final_val )
{
echo "<td>$final_val</td>";
}
echo "</tr>";
}
echo "</table>";
?>
</body>