Formatting Data
Posted: Sat Oct 13, 2007 11:19 pm
Okay I am able to retrieve my SQL data, now I just need the information to be displayed in a collective chunk and then display it automatically:
The only thing I can accomplish at the moment is either:
But I have to manually enter $value into the news.php, every time someone updates the news database I don't want them to have to call me and tell me to add another $value to the page.
Or I can get this:
I want to tell it how to format the information once, and then the php repeat that process "x" amount of times.
Here is the php that controls the data:
Then on news.php I just call this script and place the following:
Please help!!
--
Greg
Code: Select all
Like this:
News Heading 1 - Date1
Description-1
---------------------------------
News Heading 2 - Date 2
Description 2
etc....Code: Select all
News Heading 1 - Date 1Or I can get this:
Code: Select all
News Heading 1
News Heading 2
News Heading 3
Date1
Date2
Date3
Description 1
Description 2
Description 3
etc.....Here is the php that controls the data:
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'];
}
foreach ($header as $value) {
}
mysql_close($dbh);
?>Then on news.php I just call this script and place the following:
Code: Select all
Heading: <?php $value ?>--
Greg