Jump to content

Recommended Posts

i seem to be having a lot of difficulties using this feature.

 

What i want to do is "GET" the category from title bar to use with my query. the weird thing is. when the value of 'category' is written text like the word "aftershave" it comes up with --unknown column 'aftershave' in 'where clause' however this does work when the value is a numeric sequence like "2007"

 

is there some clause or something i have to declare to change this? it's driving me crazy! lol

Link to comment
https://forums.phpfreaks.com/topic/68656-_get-query/
Share on other sites

how exactly would i integrate that into the following code? lol.  know i'm taking the long way around by the way...  :o

 

$limit=20;

 

$startrow = $_GET['startrow'];

 

$qry = mysql_query("SELECT * FROM fragrances WHERE fragrances.avail='true' AND fragrances.browse='.$_GET[browse].' UNION SELECT * FROM skincare WHERE skincare.avail='true' AND skincare.browse='.$_GET[browse].' UNION SELECT * FROM shaving WHERE shaving.avail='true' AND shaving.browse='.$_GET[browse].' UNION SELECT * FROM bodycare WHERE bodycare.avail='true' AND bodycare.browse='.$_GET[browse].' UNION SELECT * FROM haircare WHERE haircare.avail='true' AND haircare.browse='.$_GET[browse].' UNION SELECT * FROM suncare WHERE suncare.avail='true' AND suncare.browse='.$_GET[browse].' ORDER BY title LIMIT $startrow, $limit")or

die(mysql_error());

 

PS. you need to imagine the 'browse' is actually the 'category'

Link to comment
https://forums.phpfreaks.com/topic/68656-_get-query/#findComment-345142
Share on other sites

First of all you have multiple table with your product so this is not a proper normalize data.

 

You may follow like this

 

table 1 : Master products items

product_item_id product_item_name

  1           fragrances

  2           skincare

  3           shaving

 

table 2 : Product table

product_id product_item_id   product_name avail browse

  1   1 (fragrances) prd1 true 1

  2   1 (fragrances) prd2 true 1

  3   2 (skincare)   prd3 true   2

 

So for above case you have only one query

if(isset($_GET['browse']) and !empty($_GET['browse']) and is_integer($_GET['browse'])){

 

  select * from product where avail = 'true' and browse = '"$_GET['browse']."'";

}else{

 

echo "Invalid input for browse";

 

}

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/68656-_get-query/#findComment-345151
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.