Go Back   Novahq.net Forum > phphq.Net > phphq.Net Forums
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-12-2004, 02:27 PM
bw
Unregistered

Posts: n/a

please help

hi, i have just recently started trying to learn php. i have made a little form that will place information in my database for me, the fields are : pcid , player name , stat link. i have gotten as much figured out as i can but now i am completely stuck, and i tried reading / finding tutorials. what i want to do is make a page called search.php and have it be able to search the database, but the only part of the database i want it to search is the pcid column and also have it display the other 2 sections as well. i just dont seem to be able to understand what to do, any help is greatly appreciated.

i asked for help in another forum and someone replied and said :

$sql = "SELECT pcid FROM table WHERE pcid='searchsample'";
$result = mysql_query($sql) or die(mysql_error());
?>

and another :

$sql = "SELECT * FROM tablename WHERE `pcid` = $id";

but i have no clue what to do with this.
any tutorials or anything would help..
Reply With Quote
  #2  
Old 11-12-2004, 04:46 PM
bw
Unregistered

Posts: n/a

ok nevermind helping me make a script for it... i found a good tutorial that i learned and changed 2 make my own. all i need now is help with figuring out how to get it to show my other 2 columns of data next to the column that you search for. i have 3 columns in the database, pcid, playername, statlink and i have it set so it searches for pcid in the row. the only problem now is it wont show the playername or statlink column and i cant seem to figure out what part to make it work change
here is my code for it :

[code:1:6702b885f6]<?php

$var = @$_GET['q'] ;
$trimmed = trim($var);

$limit=1000;

if ($trimmed == "")
{
echo "<p>Enter a PC-ID</p>";
exit;
}

if (!isset($var))
{
echo "<p>We dont seem to have a search parameter!</p>";
exit;
}

mysql_connect("localhost","username ","password");

mysql_select_db("test") or die("Unable to select database");

$query = "SELECT * FROM cheaterlist where pcid like \"%$trimmed%\"
order by pcid";

$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);

if ($numrows == 0)
{
echo "<p>No PC-ID found matching "" . $trimmed . "" in the database.</p>";
}

if (empty($s)) {
$s=0;
}

$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");

$s ;

while ($row= mysql_fetch_array($result)) {
$title = $row["pcid"];

echo "<br>$title" ;
$count++ ;
}

$currPage = (($s/$limit) + 1);

$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<p>Showing results $b to $a of $numrows</p>";

?>[/code:1:6702b885f6]
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:45 AM.




Powered by vBulletin®