|
|
bs0d |
Subject: "re: Search"
Posted: @ 3:11 am on Mar 17 2008
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
I think your
query may need
adjusting...
search google
for SQL and
LIKE condition.
I think it
would be
something like
this:
SELECT *
FROM `table`
WHERE
`column_name`
LIKE
'%chars%';
where the
%chars% would
be your search
term. Give that
a shot. I
haven't really
built any
search scripts
before so I
can't help too
much.
|
Viewed: 12,175 Times | |  |
Genius |
Subject: "re: Search"
Posted: @ 3:53 am on Mar 17 2008
|
|
|
 Member #: 582 Rank: user - (77) Since: 02/18/08 Posts: 76 From: kmmk
|
Ok, I got it
fixed. Most of
the part.
Getting this
error: You have
an error in
your SQL
syntax; check
the manual that
corresponds to
your MySQL
server version
for the right
syntax to use
near 'keys
(key, date,
game,
confirmed)
VALUES
('464819348713
1', now(),
'StarCraft',
'' at line 1
Line it accurs
is:
Code:
$insert =
"INSERT
INTO keys (key,
date, game,
confirmed)
VALUES
('$key',
now(),
'$game',
'no')";
$insert2 =
mysql_query($in
sert);
if(!$insert2)
die(mysql_error
());
$result =
"We could
not find $key
for $game in
our
database."
;;
header("L
ocation:
index.php?error
=".$resul
t.""
 ;
exit;
}
?>
EDIT:
Nevermind! Got
it working.
Edited at 02:36:30 am on 03/19/08
|
Viewed: 12,170 Times | |  |
Genius |
Subject: "re: Search"
Posted: @ 2:09 am on Mar 21 2008
|
|
|
 Member #: 582 Rank: user - (77) Since: 02/18/08 Posts: 76 From: kmmk
|
Ok, can someone
teach me how to
filter out
dashes from
search
query?
For example, I
want to have
php
automatically
remove the dash
or (-) from the
query. So if I
type in
38328-34324-342
324 the script
should
eliminate (-)
and should
search db with
383283432434232
4. Thanks.
|
Viewed: 12,101 Times | |  |
bs0d |
Subject: "re: Search"
Posted: @ 3:51 am on Mar 21 2008
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
you can
probably use
str_replace();
like this:
Code:
$var =
38328-34324-342
324;
$var =
str_replace(&q
uot;-",
"",
$var);
*Note that
str_replace();
is case
sensitive.
|
Viewed: 12,092 Times | |  |
Genius |
Subject: "re: Search"
Posted: @ 4:22 am on Mar 21 2008
|
|
|
 Member #: 582 Rank: user - (77) Since: 02/18/08 Posts: 76 From: kmmk
|
|
Viewed: 12,089 Times | |  |
boy |
Subject: "re: Search"
Posted: @ 3:24 am on May 13 2008
|
|
|
Member #: Rank: - () Since: 01/01/70 Posts:
|
I'm
trying to make
simple search
script that has
some search
options such as
search by
firstname or
search by
nickname,etc.
I used
selection
button in the
form to choose
search option,
and my question
is
"is there
any way that I
can only go in
one query that
only need to be
changed
conditoion
?"
===============
===============
I have form
like,
<form
name="sea
rch"
method="p
ost"
action="s
earchresults.ph
p">
Search for
<input
type="tex
t"
name="fin
d" />
By
<Select
name="fie
ld">
<Option
value="fn
ame">F
irst
Name</option
>
<Option
value="ln
ame">L
ast
Name</option
>
</Select>
;
<input
type="hid
den"
name="sea
rching"
value="ye
s" />
<input
type="sub
mit"
name="sea
rch"
value="Se
arch"
/>
</form>
---------------
----------
and in
searchresult.ph
p,
//After
connection to
DB
$find =
strtoupper($fin
d);
$find =
strip_tags($fin
d);
$find = trim
($find);
$query =
"select *
from profile
where
upper($field)
like
'%$find%'
";
$result =
mysql_query($qu
ery);
$a =
mysql_num_rows(
$result);
---------------
-------------
But in here $a
returns 0,
which means the
query seems not
working as I
expected.
Is anyone know
how to make
query in this
case???
Edited at 10:27:14 am on 05/13/08
|
Viewed: 11,610 Times | |  |
Viewing Page: 1 of 1 |
|
|
|