0
#
<form name="Item Search" method="post" action="search1.php">
#
Item Search:<br>
#
<label>
#
<input name="swords" type="text" size="30" maxlength="30">

</label>

<br>

<label>

<input name="search" type="submit" id="search" value="Search">

</label>

<a href="logout.php">Logout</a>

</form>

<?php

if(isset($_POST['submit'])||isset($_POST['swords'])||isset($_GET['swords'])){

if (isset($_POST['swords']))

{

$search=$_POST['swords'];

}else

{

$search=$_GET['swords'];

}
$newurl = "search.php?swords=";

$searchwords = addslashes(htmlspecialchars($_POST['swords']));

{

$words = explode(' ',$searchwords);

$totalwords = count($words);

$i = 0;

$searchstring = "";

while ($i != $totalwords){

if ($i != 0 and $i != $wordcount){

$searchstring .= " and ";;

}

$searchstring .= "b_name LIKE '%$words[$i]%'";

$searchstring1 .= "b_author LIKE '%$words[$i]%'";

$i = $i + 1;

when i search "the" it's show all the "the" first words but if i type "the giver"
it dont show anything how can i search in the database if i have space above is my code i use can anybody modify it?

Edited by yamot47: wla

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by yamot47
0

Your use of like clause is perfect as this is the way to search the values in such case. I think the problem is cause by the following line
$searchwords = addslashes(htmlspecialchars($_POST));

Remove addslashes and htmlspecialchars and then try

0

Your use of like clause is perfect as this is the way to search the values in such case. I think the problem is cause by the following line
$searchwords = addslashes(htmlspecialchars($_POST));

Remove addslashes and htmlspecialchars and then try

I know the problem the closing tags is the problem but by the way thank you for your help

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.