473,624 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing more than one word variables to php page

i wrote a search page for my site (searching through a mysql database) but
when i type in more than one word (eg "item three") in the search field it
gets passed to the page as a single word ("item"). Are there any
workarounds for this? the code is below.( houseproudlancs .co.uk/search.php
)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<!-- background="./images/background.jpg" --> <body bgcolor="#64000 0">
<?php
$search_for = $_GET['for'];
$search_categor y = $_GET['category']; global $search_for;
global $search_categor y;
global $the_items_desc ription;
global $does_contain_t ext;
?>

<div align=center>
<form action="http://www.houseproudl ancs.co.uk/search.php"
method="GET"> <br><table bgcolor="#EBEB9 6" cellpadding=6>
<tr> <td> </td> </tr> <tr> <td> <div align=center> Search For:
</div></td> <td> <div align=center> Category: </div> </td> </tr>
<tr> <td>
<INPUT name=for value=<?php echo ("$search_for") ; ?>>
</td> <td>
<SELECT NAME=category SIZE=1>
<OPTION <?php if ($search_catego ry == "Search All
Categories") { echo ("SELECTED") ; } ?>>Search All Categories
<OPTION <?php if ($search_catego ry == "Floral Creations") {
echo ("SELECTED") ; }?>>Floral Creations <OPTION <?php if
($search_catego ry == "Decorative Lighting") { echo
("SELECTED") ; }?>>Decorative Lighting <OPTION <?php if
($search_catego ry == "Kitchenwar e & Crockery") { echo
("SELECTED") ; }?>>Kitchenware & Crockery <OPTION <?php if
($search_catego ry == "Fancy Goods & Furniture") { echo
("SELECTED") ; }?>>Fancy Goods & Furniture
</SELECT>
</td> <td>
<INPUT TYPE=submit VALUE="Search">
</td>
</form>
<tr> <td> </td> </tr>
</table>
</div>
<?php
switch ($search_catego ry) {
case "":
exit;
break;
case "Search All Categories":
$filter_categor y = "*" ;
break;
case "Floral Creations":
$filter_categor y = "floral";
break;
case "Decorative Lighting":
$filter_categor y = "lighting";
break;
case "Kitchenwar e & Crockery":
$filter_categor y = "kitchenwar e";
break;
case "Fancy Goods & Furniture":
$filter_categor y = "furniture" ;
break;
default:
echo ("<P>Error - The Selected Category Was Not Found</P>"); break;
}

$dbcnx = @mysql_connect( "server",
"username", "password") ; $select =
@mysql_select_d b("houseproudla ncs_co_uk1"); if ($filter_catego ry ==
"*") {
$command = "SELECT * FROM `stock` WHERE 1 ORDER BY `id`";
} else {
$command = "SELECT * FROM `stock` WHERE 1 AND `category` LIKE
\"$filter_categ ory\" ORDER BY `id`";
}

$qresult = mysql_query($co mmand);

$started_table = false;
while ($row = mysql_fetch_arr ay($qresult)) {
//text search
$the_items_desc ription = $row ["descriptio n"];

if ($search_for === '') $search_for = ":X:X::X:X::X:X :"; // hopefully
":X:X::X:X::X:X :" is something that is *never* in $the_items_desc ription
$Items_searchab le_text = ($row ["descriptio n"] . $row ["id"] . $row
["name"]);
$pos = stristr($Items_ searchable_text , $search_for);

//THIS IS FOR DEBUGGING THE TEXT SEARCH
//echo ("POS = ");
//echo ("$pos");
//echo ("<br>item description = ");
//echo ("$the_items_de scription");
//echo ("<br> search for = ");
//echo ("$search_for") ;
//echo ("<br>");
//END OF DEBUGGING TEXT SEARCH

if ($search_for == ":X:X::X:X::X:X :") {
$does_contain_t ext = true;
} elseif ($pos === false) {
$does_contain_t ext = false;
} else {
$does_contain_t ext = true;
}

// end text search
if ($does_contain_ text == true) {

if ($started_table == false) {
echo ("<center><tabl e width=80% cellpadding=5>" ); }

if ($tablebgcolor == "#1E8CDB"){ //blue
$tablebgcolor = "#EBEB96"; //green
} else {
$tablebgcolor = "#1E8CDB"; }
?>

<tr ><td> <table border=0 cellspacing=3 width=100% bgcolor=<?php
echo ("$tablebgcolor "); ?>> <tr><td> <table> <tr>
<?php
switch ($row ["category"]) {
case "lighting":
$item_category = "Decorative Lighting"; break;
case "floral";
$item_category = "Floral Creations";
break;
case "kitchenwar e":
$item_category = "Kitchenwar e & Crockery"; break;
case "furniture" :
$item_category = "Fancy Goods & Furniture"; break;
default;
$item_category = "Unknown Category";
break;
}
?>
<td><pre>Name : </pre></td> <td><b><div align=left><?ph p
echo ($row ["name"]); ?> </b></div></td></tr><tr>
<td><pre>Descri ption: </pre></td> <td><div align=left><?ph p echo
($row ["descriptio n"]); ?></div> </td></tr><tr> <td><pre>Catego ry:
</pre></td> <td><div align=left><?ph p echo ($item_category ); ?>
</div> </td></tr><tr> <td><pre>Pric e:
</pre></td><td><div align=left><?ph p echo ("£" . $row ["price"]);
?> </div> </td></tr><tr> <td><pre>P&P:
</pre></td><td><div align=left><?ph p echo ("£" . $row ["pandp"]);
?> </div> </td></tr><tr>
<?php $quantity = $row ["quantity"];
if ($quantity != "0") { ?>
<td><pre>Quanti ty: </pre></td> <td><div align=left><?ph p echo
($row ["quantity"]); ?> </div></td></tr><tr><?php } ?>
<td><pre>Produc t ID: </pre></td> <td><div align=left> <?php
echo ($row ["id"]); ?></div></td></tr><tr><td>
<?php if ($quantity == "0") { ?>
<td><b> <font color=#DD0000> <div align=center>Te mporarily Out
Of Stock </b></div></font></tr><tr>
<?php } ?>
</td></tr></table>
</td><td width=30%>
<?php $pictureid = $row ["id"]; ?>
<?php $picturepath = "./images/" . $pictureid . ".jpg"; ?>
<?php
if (file_exists($p icturepath)) {
echo ("<div align=\"center\ "><a href=\"$picture path\"
target=LargeIma ge><img src=$picturepat h height=200 alt='Image
Of Product'></a><font size=2><br>Clic k The Image To See It Full
Size In A New Window</font></div>");
} else {
echo ("<div align=\"center\ "><img src=\"/images/nopic.png\"
height=200 alt='No Picture Available'></a><font
size=2><br>Sorr y, There Is No Available Picture For This
Item</font></div>");
}
?>
</td></tr></table></td></tr>
<?php
}
}
?>
</table></center>

<?php

?>
Jul 17 '05 #1
1 2604
Matthew Robinson wrote:

i wrote a search page for my site (searching through a mysql database) but
when i type in more than one word (eg "item three") in the search field it
gets passed to the page as a single word ("item"). Are there any
workarounds for this? the code is below.( houseproudlancs .co.uk/search.php
) <INPUT name=for value=<?php echo ("$search_for") ; ?>>


This is your problem. You need to put quotes around your value. Check the HTML
code that is produced. You'll see something like:

<INPUT name=for value=item three>

Your browser interprets that as value = "item", with an attribute called "three"
that it doesn't know what to do with, and therefore ignores.

Regards,
Shawn
--
Shawn Wilson
sh***@glassgian t.com
http://www.glassgiant.com

I have a spam filter. Please include "PHP" in the
subject line to ensure I'll get your message.
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1694
by: JA | last post by:
I have this little tell-a-friend script that will send out a link back to the site. I want to put a link on my product pages that will go to the script, and have the script display the product name, and have the product name in the email that goes out, along with a link back to the product page, instead of just to the general site, and then have the Thank You page include a link back to the product. I put it up as a project on a...
2
2527
by: Richard | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** HI, I am working on a project where I need to input data to a (local) HTML page using multiple form elements, such as text, radio, checkbox, and dropdown. When the form Submit button is clicked, I then need the input data either written to another location on the same page, or written to another page (a different frame would be fine)
5
6682
by: Jack | last post by:
Hi, I need to pass multple variables in a link in order to go to a asp page with the two varables. The following are the values of the variables using response.write: <%'Response.Write Mypage & "<br>"%> Exp <%'Response.Write GrantID & "<br>"%>
4
1957
by: Doruk | last post by:
The problem that we are experiencing is simple: We want to pass certain parameters from a page with several server controls to another page. We want to do this in a dotnet compliant manner, but we can't seem to find a good and clean solution anywhere. The options we looked into are as follows. Comments following the options are why we did not want to go with them:
7
2782
by: Khai | last post by:
First off, yes, I understand the crapload of tutorials out there, (well, rather, I understand there /are/ a crapload of tutorials out there), the problem is my comprehension. I'm trying to pass variables, and can do so just fine with a URL, and $_GET. What I would like to learn, and be very adept at using is the Form functions and how you pass through that. The problem in my comprehending this, is how does the original page know how...
28
3117
by: Skeets | last post by:
i'm passing session and hidden variables between pages. not to mention post values. i'm a little concerned that someone with sufficient knowledge could spoof these vlaues and manipulate the program. is this a valid concern? i'm thinking i can check the submitting page setting up something around the following the following code... $base_name = basename($_SERVER);
4
2885
by: allanrodkin | last post by:
Hi, I'm designing a website in dreamweaver and I'm using JavaScript to slide text across the page. The text is contained in <div> tags. I have designed a function which can move two of the div tags across the screen. I use the timer to manage the movement of the text across the screen. I would like redesign that function so that it can move any amount of div blocks across the screen. To do this, I need to pass a parameter to the...
5
1371
by: nickm687 | last post by:
Hi i have this code below and i need to modify it so i can pass more than one text file to it. any ideas? i am new to this. thanks in advance. Nick int main(int argc, char *argv) { FILE *f; int i;
2
4429
by: luis | last post by:
I'm using ctypes to call a fortran dll from python. I have no problems passing integer and double arryas, but I have an error with str arrys. For example: ..... StringVector = c_char_p * len(id) # id is a list of strings Id_dat=StringVector() for i in range(len(Id)): ....Id_dat=id
0
8238
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8174
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1485
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.