<?
// this is a simple way of doing what you are doing.
// you look as if you could use a easy beginner book
// the one I use in my introduction to PHP - Mysql class is:
// PHP Fast&Easy Web Development by: Julie C. Meloni
// The contents of the lognfo.php file
// globals_sql_all.php3
$sqlusername = "username";
$sqlpassword = "password";
// database name
$databasename = "databasename";
// sql table names
$tablename_1 = "table_main";
// end of logonfo.php file
include("includes/lognfo.php");
// connect to database
mysql_connect($lhost,$user,$pwd);
@mysql_select_db($dbname) or die("Unable to connect to database!");
// start retreiving data form the database
// since you are obtaining the variables from the same table do it all at once.
$sql_0 = mysql_query("SELECT datemain, messagesnew, messagesold
FROM $tablename_1 ORDER BY LAST, FIRST ");
// display an error message if query does not work
if(!$sql_0) {
print mysql_errno(). ": ".mysql_error(). "<br />Can't execute sql_0 query.";
exit();}
// I am assuming that you may have more than one row of data to retreive.
// this method lets you set the variable names to be used,
// when no using the variable names in the database.
while (list($main_date, $main_new, $main_old) = mysql_fetch_row($sql_0)) {
// using this method you can set up blocks of code to display each row of data
// that will be reterived from the database.
// notice the dot in front of the "=", equal sign, means to repeat.
$option_block_1 .= "
<div align=\"center\" style=\"left: 232px; top: 167px; width: 450px; height: 259px;\">
<table bordercolor=\"#333333\" class=\"FormTABLE\" width=\"110%\" height=\"268\" border=\"1\">
<tr bgcolor=\"#ABD1C2\" class=\"columTDA\" >
<td height=\"23\" ><strong> News as of
<? echo \"$main_date\"; ?>:</strong></td>
</tr>
<tr class=\"cloumTD\">
<td valign=\"top\"><? echo \"$main_results\"; ?></td>
</tr>
<tr class=\"columTD\">
<td valign=\"top\"><? echo \"$main_results_old\"; ?>
</td>
</tr>
</table></div>\";
}
mysql_close();
$display_block_1 = "
$option_block_1
"; // end Display_block
?>
<!-- datacollection stops here -->
<html>
<head>
<title>Sample Script</title>
</head>
<body>
<?php echo ("$display_block_1"); ?>
</body>
</html>