Forum Moderators: coopster
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Budgets Report</title>
</head>
<body class="oneColFixCtr">
<div id="container">
<h2>Budget Report</h2>
<form name="search" method="post" style="background-color:#FFF" action="<?php $PHP_SELF?>">
<span id="search">Search for</span>:
<input type="text" name="find" /> in <Select NAME="field">
<Option VALUE="rundate">rundate</option>
<Option VALUE="section">section</option>
<Option VALUE="reporter">reporter</option> </Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" />
</form>
<?php
// check to see if anything is posted
if (isset($_POST['find'])) {$find = $_POST['find'];}
if (isset($_POST['searching'])) {$searching = $_POST['searching'];}
if (isset($_POST['field'])) {$field = $_POST['field'];}
//This is only displayed if they have submitted the form
if (isset($searching) && $searching=="yes") {
echo "<h2>Results</h2><p>";
// If they did not enter a search term we give them an error
if (empty($find)) {
echo "<p>You forgot to enter a search term"; exit;
}
// Otherwise we connect to our Database
mysql_connect("localhost", "root", "root") or die(mysql_error());
mysql_select_db("budgets") or die(mysql_error());
// We preform a bit of filtering
$find = strtoupper($find);
$find = strip_tags($find); $find = trim ($find);
// Now we search for our search term, in the field the user specified
$data = mysql_query("SELECT * FROM daily_budget WHERE upper($field) LIKE'%$find%' ORDER BY section ASC");
// And we display the results
while($result = mysql_fetch_array( $data )) {
echo '<strong>Section:$nbsp</strong>'.$result['section'].'<br>';
echo $result['slug'].' : '.$result['budgetInfo'].' / '.$result['reporter'].' '.$result['notes'].' '.$result['art_photos'].' '.$result['artDesc'].' '.$result['multimedia'].' '.$result['multimediaDesc'].'<br>';
echo 'Pickup : '.$result['pickup'].'<br>';
echo 'Sidebar : '.$result['sidebar'].'<br>';
echo $result['sSlug'].' '.$result['sBudget'].' '.$result['sArt'].' <a href="dbEdit.php"> EDIT</a> | <a href="dbDelete.php">DELETE</a> <br>';
echo '<hr>';
}
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($data);
if ($anymatches == 0) {
echo "Sorry, but we can not find an entry to match your query<br><br>"; }
//And we remind them what they searched for
echo "<b>Searched For:</b> " .$find;
}
?>
</div>
</div>
</body>
</html>
<a href="dbEdit.php?id=1234"> EDIT</a>