Forum Moderators: coopster
Aaron
take a look at the following:
this forum's lib
[webmasterworld.com ]
"Basics of extracting data from MySQL using PHP" thread
[webmasterworld.com ]
PHP/MySQL Tutorial
[webmonkey.com ]
MySQL Functions (in PHP)
[php.net ]
MySQL Documentation
[dev.mysql.com ]
HTH
<?php
$title = "Todays report for host1";
include("header.inc");
$result = mysql_query("SELECT report_id, report_text, report_date FROM host1",$db);
echo "<table border=0>\n";
echo "<tr><td>report results</td><td>date</tr>\n";
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s %s</td><td>%s</tr>\n", $myrow[0], $myrow[1], $myrow[2], $myrow[3]);
}
echo "</table>\n";
include("footer.inc");
?>
<html>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
Enter date in format yyyy-mm-dd:<input type="text" size="12" maxlength="10" name="mydate">:<br />
Select host to query:<br />
<select name="host">
<option value="host1">host1</option>
<option value="host2">host2</option>
<option value="host3">host3</option></select>:<br />
Select which report you wish to view::<br />
report1:<input type="radio" value="report 1" name="reportnum">:<br />
report2:<input type="radio" value="report 2" name="reportnum">:<br />
<?php
//this is hard coded but will really just be the value returned from host combo box above
$title = "Report for ms-lnx-s08";
include("header.inc");
//select a table to use based upon value returned from host combo box above
$mytable='MS_LNX_S08';
//select a report to view for the day, this will also be retrived from above
$repnum='1';
//get todays date for the report
//$mydat1=date("Y-m-d");
$mydat1='2006-04-10';
//query for our data
$result = mysql_query("SELECT report_text FROM $mytable WHERE report_date='$mydat1' AND report_num='$repnum'",$db);
$mydatr = mysql_query("SELECT * FROM $mytable WHERE report_date='$mydat1' AND report_num='$repnum'",$db);
printf("report query ran for %s<br>\n", mysql_result($mydatr,0,"report_date"));
echo "<table border=0>\n";
echo "<tr><td>report results</td><td></tr>\n";
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s %s</td><td>%s</tr>\n", $myrow[0], $myrow[1], $myrow[2], $myrow[3]);
}
echo "</table>\n";
include("footer.inc");
?>
</body>
</html>
<html>
<body>
<?php
if ($submit) {
// process form
//this is hard coded but will really just be the value returned from host combo box above
$title = "Report for host1";
include("header.inc");
//select a table to use based upon value returned from host combo box above
$mytable='host1';
//select a report to view for the day, this will also be retrived from above
$repnum='1';
//get todays date for the report
//$mydat1=date("Y-m-d");
$mydat1='2006-04-11';
//$mydat1='$mydate'
//query for our data
$result = mysql_query("SELECT report_text FROM $mytable WHERE report_date='$mydat1' AND report_num='$repnum'",$db);
$mydatr = mysql_query("SELECT * FROM $mytable WHERE report_date='$mydat1' AND report_num='$repnum'",$db);
printf("report query ran for %s<br>\n", mysql_result($mydatr,0,"report_date"));
echo "<table border=0>\n";
echo "<tr><td>report results</td><td></tr>\n";
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s %s</td><td>%s</tr>\n", $myrow[0], $myrow[1], $myrow[2], $myrow[3]);
}
echo "</table>\n";
//include("footer.inc");
} else{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<form method="post" action="<?php echo $PHP_SELF;?>">
Enter date in format yyyy-mm-dd:<input type="text" size="12" maxlength="10" name="mydate">:<br />
View report for server:<br />
<select name="host">
<option value="host1">host1</option>
<option value="host2">host2</option>
<option value="host3">host3</option>
<option value="host4">host4</option></select>:<br />
Select which report you wish to view::<br />
report1:<input type="radio" value="report 1" name="reportnum">:<br />
report2:<input type="radio" value="report 2" name="reportnum">:<br />
<input type="submit" value="submit" name="submit">
</form>
<?php
} // end if
?>
</body>
</html>