Jump to content

Searching Database


supanoob

Recommended Posts

well, i have tried various codes and this is the one i have got now:

My Form (search.php):

[code]<HTML>
<HEAD></HEAD>
<BODY>
<FORM NAME="searchphone" METHOD="post" ACTION="searchres.php">
Enter Last Name: <input name="Array[user]" type="text" id="Array[user]"><BR>
<input type="submit" name="Submit" value="Submit">

</FORM>
</BODY>
</HTML>[/code]

and this is the php (searchres.php):

[code]<HTML>
<HEAD></HEAD>
<BODY>
<FORM NAME="searchphone" METHOD="post" ACTION="searchres.php">
Enter Last Name: <input name="Array[user]" type="text" id="Array[user]"><BR>
<input type="submit" name="Submit" value="Submit">

</FORM>
</BODY>
</HTML>

<HTML>
<HEAD></HEAD>
<BODY>
<?php
$Array["user"] =trim ($Array["user"]);

$Host="i dunt believe it";
$Username="damn";
$Password="hahaha";
$DBName="meh";
$TableName="yeah";
  
$Link = mysql_connect($Host, $Username, $Password);
$Query="SELECT * from $TableName Where user = $Array[user]";
$Result= mysql_db_query ($DBName, $Query, $Link);




echo "Results: <br>$Row[user] ($Row[playerid]) <BR> ";

mysql_close ($Link);
?>
</BODY>
</HTML>[/code]

now i get no errors when searching it just doesnt bring any results up :S

go here to see what i mean:

[a href=\"http://twottk.com/game\" target=\"_blank\"]HERE[/a]

and login using the following:

Username: testacc
password: test123
Link to comment
Share on other sites

Try this

[code]<HTML>
<HEAD></HEAD>
<BODY>
<FORM NAME="searchphone" METHOD="post" ACTION="searchres.php">
Enter Last Name: <input name="search_query" type="text"><BR>
<input type="submit" name="Submit" value="Submit">

</FORM>
</BODY>
</HTML>

<HTML>
<HEAD></HEAD>
<BODY>
<?php
$search_query = trim($_POST['search_query']);

$Host="i dunt believe it";
$Username="damn";
$Password="hahaha";
$DBName="meh";
$TableName="yeah";
  
$Link = mysql_connect($Host, $Username, $Password);
$Query="SELECT * from $TableName Where user = '$search_query'";
$Result= mysql_db_query ($DBName, $Query, $Link) or die(mysql_error());
$Row = mysql_fetch_array($Result);
$num = mysql_num_rows($Result);
$user = $Row['user'];
$playerid = $Row['playerid'];

if($num == "0"){
echo "Search for $search_query returned no results";
}
else{

echo "Results: <br>$user ($playerid) <BR> ";

}

mysql_close ($Link);
?>
</BODY>
</HTML>[/code]
Link to comment
Share on other sites

So lets say youre searching for "bob". Then is this what you are getting when you search?

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]The search for bob returned no results[/quote]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.