Okay, I've looked on google, but the tutorials I've tried were a bit confusing and some simply didn't work at all...
After some playing around, I finally got one to work. Though.. the only thing is... I know that when it retrieves the results.. it'll print out the information on a new page. So my question is... how do I combine the two parts.. and get the form to print out the results on the same page BELOW the form?
Here is what the form code looks like within the BODY:
<div id="listings">
<form method="get" action="./searchname.php">
<input maxlength="50" size="50" type="text" name="q"> <input type="submit" value="Search by Dragon Name!">
</form>
</div>
Here is the script that the form uses:
<?php
$var = @$_GET['q'] ;
$trimmed = trim($var);
$limit=1;
if ($trimmed == "")
{
echo "<p>Please enter a search...</p>";
exit;
}
if (!isset($var))
{
echo "<p>Dragon not found!</p>";
exit;
}
mysql_connect("localhost","gwynevere_blah","blah"); //(host, username, password)
mysql_select_db("gwynevere_landf") or die("Unable to select database"); //select which database we're using
$query = "select * from lostandfound where dragon like \"%$trimmed%\"
order by dragon";
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
if (empty($s)) {
$s=0;
}
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");
$count = 1 + $s ;
while ($row= mysql_fetch_array($result)) {
$dragon = $row["dragon"];
$code = $row["code"];
$owner = $row["owner"];
$forum = $row["forum"];
echo "$count.) Dragon Name: $dragon <br />";
echo "Code: <a href=http://dragcave.net/viewdragon/$code target=_blank>VIEW DRAGON</a><br />";
echo "Owner: <a href=http://dragcave.net/user/$owner target=_blank>$owner</a><br />";
echo "Forum Contact: $forum";
$count++ ;
}
?>
Here is the page I have the form on:
http://gwynevere.110mb.com/lostandfound.phpAs I mentioned, I want the results to be printed out BETWEEN the two forms.. but I haven't a single clue on how to use what I've learned in PHP to do that. If I could get some help, that'd be great! Thanks!!