Hi, I've discovered why it isn't working, so I just need some help with solving the problem. The problem is that the everything after the php code is deleted, or so I thought.
Turns out that it's because of an exit command, which causes the rest of the page to stop and so doesn't get displayed. Here's the code :
PHP Code:
<?
if ($trimmed == "")
{
echo "<p>Please enter a search...</p>";
exit;
}
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
if ($numrows == 0)
{
echo "<h4>Articles</h4>";
echo "<p>Sorry, your search: " . $trimmed . " returned zero results</p>";
}
if (empty($s))
{
$s=0;
}
$result = mysql_query($query) or die("Couldn't execute query");
if($numrows > 1){ $return = "results";}
else{ $return = "result"; }
$count = 1 + $s;
while ($r= mysql_fetch_assoc($result))
{
$id = $r["id"];
$header = $r["header"];
$image = $r["image"];
$excerpt = $r["excerpt"];
$count++;
?>
<a href="http://www.pwamm.com/articles.php?id=<? echo $id ?>"><br />
<? echo $header ?></a><br />
<? echo $excerpt ?><br />
<? } ?>
As you can see there is an exit command at the top. I've tried taking this out, but that cause all the contents of the database to be displayed, thinking that a search has been made when the page is first loaded.
So, I need to know how I can change the code in such a way that the rest of the script is loaded, by taking the exit out, and that the database contents are shown only when a search has been made!
Cheers!