I am creating a very simple cms (This is my first), and so far I can connect to mySQL, connect to the Table, Retrieve and display data.
Here is where my problem lies, I want the user to be able to enter as many new items as they want and I want each of them to be formatted the same way:
News Header - Date
Description
Here is the PHP Code:
Code: Select all
<?php
$username = "root";
$password = "";
$hostname = "localhost";
$select = "SELECT header,date,description FROM news";
$dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
print ("Connected to MySQL<br>");
$selected = mysql_select_db("biglakebaptist",$dbh) or die("Could not select biglakebaptist");
print ("Selected biglakebaptist<br>");
$result = mysql_query($select) or die("Could not select news");
print ("Selected news table<br>");
while($col=mysql_fetch_assoc($result))
{
$header[] = $col['header'];
$date[] = $col['date'];
}
print($header);
foreach ($header as $value) {
echo "Value: $value<br />\n";
}
mysql_close($dbh);
?>Thanks, I hope that makes sense.
Greg