php request variables assigning $_GEt
Posted
by chris
on Stack Overflow
See other posts from Stack Overflow
or by chris
Published on 2010-04-22T15:36:54Z
Indexed on
2010/04/22
16:13 UTC
Read the original article
Hit count: 238
if you take a look at a previous question
http://stackoverflow.com/questions/2690742/mod-rewrite-title-slugs-and-htaccess
I am using the solution that Col. Shrapnel proposed- but when i assign values to $_GET in the actual file and not from a request the code doesnt work. It defaults away from the file as if the $_GET variables are not set
The code I have come up with is-
if(!empty($_GET['cat'])){
$_GET['target'] = "category";
if(isset($_GET['page'])){
$_GET['pageID'] = $_GET['page'];
}
$URL_query = "SELECT category_id FROM cats WHERE slug = '".$_GET['cat']."';";
$URL_result = mysql_query($URL_query);
$URL_array = mysql_fetch_array($URL_result);
$_GET['category_id'] = $URL_array['category_id'];
}elseif($_GET['product']){
$_GET['target'] = "product";
$URL_query = "SELECT product_id FROM products WHERE slug = '".$_GET['product']."';";
$URL_result = mysql_query($URL_query);
$URL_array = mysql_fetch_array($URL_result);
print_r($URL_array);
$_GET['product_id'] = $URL_array['product_id'];
The original variable string that im trying to represent is
/cart.php?Target=product&product_id=16142&category_id=249
And i'm trying to build the query string variables with code and including cart.php so i can use cleaner URL's
So I have product/product-title-with-clean-url/ going to slug.php?product=slug
Then the slug searches the db for a record with the matching slug and returns the product_id as in the code above.Then built the query string and include cart.php
© Stack Overflow or respective owner