PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > passing url parameter output limited to one value only
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
passing url parameter output limited to one value only

Réponse
 
LinkBack Outils de la discussion
Vieux 20/10/2007, 16h22   #1
J Adams
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut passing url parameter output limited to one value only


I have a link where I would to view products from 2 categories

<a
href="../productlist.php?&amp;id_product_categories=2&amp;i d_product_categories=4">Prdt
Cat 2 & Prdt Cat 4</a>

but on the results page I only get output from id_product_categories=4
and if I switch the id_product_categories=2 the results are displayed
reflecting that value only, but not both

$colname_rs_products = "-1";
if (isset($_GET['id_product_categories'])) {
$colname_rs_products = $_GET['id_product_categories'];
}

mysql_select_db($database_dbname, $dbname);
$query_rs_products = sprintf("SELECT id_products, part_number,
product_category_name, id_product_categories, product_title,
product_description_short FROM tbl_products WHERE
id_product_categories = %s ORDER BY part_number ASC",
GetSQLValueString($colname_rs_products, "int"));

$query_limit_rs_products = sprintf("%s LIMIT %d, %d",
$query_rs_products, $startRow_rs_products, $maxRows_rs_products);
$rs_products = mysql_query($query_limit_rs_products, $dbname) or
die(mysql_error());
$row_rs_products = mysql_fetch_assoc($rs_products);

By the way it may be obvious i'm a novice

Thanks
  Réponse avec citation
Vieux 21/10/2007, 01h09   #2
ZeldorBlat
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: passing url parameter output limited to one value only

On Oct 20, 11:22 am, J Adams <u...@yahoo.com> wrote:
> I have a link where I would to view products from 2 categories
>
> <a
> href="../productlist.php?&id_product_categories=2&id_produc t_categories=4">Prdt
> Cat 2 & Prdt Cat 4</a>
>
> but on the results page I only get output from id_product_categories=4
> and if I switch the id_product_categories=2 the results are displayed
> reflecting that value only, but not both
>
> $colname_rs_products = "-1";
> if (isset($_GET['id_product_categories'])) {
> $colname_rs_products = $_GET['id_product_categories'];
>
> }
>
> mysql_select_db($database_dbname, $dbname);
> $query_rs_products = sprintf("SELECT id_products, part_number,
> product_category_name, id_product_categories, product_title,
> product_description_short FROM tbl_products WHERE
> id_product_categories = %s ORDER BY part_number ASC",
> GetSQLValueString($colname_rs_products, "int"));
>
> $query_limit_rs_products = sprintf("%s LIMIT %d, %d",
> $query_rs_products, $startRow_rs_products, $maxRows_rs_products);
> $rs_products = mysql_query($query_limit_rs_products, $dbname) or
> die(mysql_error());
> $row_rs_products = mysql_fetch_assoc($rs_products);
>
> By the way it may be obvious i'm a novice
>
> Thanks


You can't assign two different values to the same variable. If you
could, which of the two values would you expect to get out of that
variable? How would you know which one you got?

You have two choices here. You can call them something different:

productlist.php?&id_product_categories1=2&id_produ ct_categories2=4

or you can pass them as an array:

productlist.php?&id_product_categories[]=2&id_product_categories[]=4

  Réponse avec citation
Vieux 21/10/2007, 01h57   #3
J Adams
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: passing url parameter output limited to one value only

On Sat, 20 Oct 2007 17:09:59 -0700, ZeldorBlat <zeldorblat@gmail.com>
wrote:

>On Oct 20, 11:22 am, J Adams <u...@yahoo.com> wrote:
>> I have a link where I would to view products from 2 categories
>>
>> <a
>> href="../productlist.php?&id_product_categories=2&id_produc t_categories=4">Prdt
>> Cat 2 & Prdt Cat 4</a>
>>
>> but on the results page I only get output from id_product_categories=4
>> and if I switch the id_product_categories=2 the results are displayed
>> reflecting that value only, but not both
>>
>> $colname_rs_products = "-1";
>> if (isset($_GET['id_product_categories'])) {
>> $colname_rs_products = $_GET['id_product_categories'];
>>
>> }
>>
>> mysql_select_db($database_dbname, $dbname);
>> $query_rs_products = sprintf("SELECT id_products, part_number,
>> product_category_name, id_product_categories, product_title,
>> product_description_short FROM tbl_products WHERE
>> id_product_categories = %s ORDER BY part_number ASC",
>> GetSQLValueString($colname_rs_products, "int"));
>>
>> $query_limit_rs_products = sprintf("%s LIMIT %d, %d",
>> $query_rs_products, $startRow_rs_products, $maxRows_rs_products);
>> $rs_products = mysql_query($query_limit_rs_products, $dbname) or
>> die(mysql_error());
>> $row_rs_products = mysql_fetch_assoc($rs_products);
>>
>> By the way it may be obvious i'm a novice
>>
>> Thanks

>
>You can't assign two different values to the same variable. If you
>could, which of the two values would you expect to get out of that
>variable? How would you know which one you got?
>
>You have two choices here. You can call them something different:
>
>productlist.php?&id_product_categories1=2&id_prod uct_categories2=4
>
>or you can pass them as an array:
>
>productlist.php?&id_product_categories[]=2&id_product_categories[]=4


That makes sense. Sounds like the array solution would be the best
route. I plugged that in and received this error message:

Notice: Array to string conversion in
C:\wamp\www\lavender_coyote\productlist.php on line 6

the following code is on line 6

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) :
$theValue;

can't really see why that would cause the error. i do know i need to
do something more and i searched, but could not find anything. any
suggestions? i appreciate your input.

thanks
  Réponse avec citation
Vieux 21/10/2007, 02h01   #4
J Adams
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: passing url parameter output limited to one value only

On Sun, 21 Oct 2007 00:57:48 GMT, J Adams <ujsa@yahoo.com> wrote:

>On Sat, 20 Oct 2007 17:09:59 -0700, ZeldorBlat <zeldorblat@gmail.com>
>wrote:
>
>>On Oct 20, 11:22 am, J Adams <u...@yahoo.com> wrote:
>>> I have a link where I would to view products from 2 categories
>>>
>>> <a
>>> href="../productlist.php?&id_product_categories=2&id_produc t_categories=4">Prdt
>>> Cat 2 & Prdt Cat 4</a>
>>>
>>> but on the results page I only get output from id_product_categories=4
>>> and if I switch the id_product_categories=2 the results are displayed
>>> reflecting that value only, but not both
>>>
>>> $colname_rs_products = "-1";
>>> if (isset($_GET['id_product_categories'])) {
>>> $colname_rs_products = $_GET['id_product_categories'];
>>>
>>> }
>>>
>>> mysql_select_db($database_dbname, $dbname);
>>> $query_rs_products = sprintf("SELECT id_products, part_number,
>>> product_category_name, id_product_categories, product_title,
>>> product_description_short FROM tbl_products WHERE
>>> id_product_categories = %s ORDER BY part_number ASC",
>>> GetSQLValueString($colname_rs_products, "int"));
>>>
>>> $query_limit_rs_products = sprintf("%s LIMIT %d, %d",
>>> $query_rs_products, $startRow_rs_products, $maxRows_rs_products);
>>> $rs_products = mysql_query($query_limit_rs_products, $dbname) or
>>> die(mysql_error());
>>> $row_rs_products = mysql_fetch_assoc($rs_products);
>>>
>>> By the way it may be obvious i'm a novice
>>>
>>> Thanks

>>
>>You can't assign two different values to the same variable. If you
>>could, which of the two values would you expect to get out of that
>>variable? How would you know which one you got?
>>
>>You have two choices here. You can call them something different:
>>
>>productlist.php?&id_product_categories1=2&id_pro duct_categories2=4
>>
>>or you can pass them as an array:
>>
>>productlist.php?&id_product_categories[]=2&id_product_categories[]=4

>
>That makes sense. Sounds like the array solution would be the best
>route. I plugged that in and received this error message:
>
>Notice: Array to string conversion in
>C:\wamp\www\lavender_coyote\productlist.php on line 6
>
>the following code is on line 6
>
> $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) :
>$theValue;
>
>can't really see why that would cause the error. i do know i need to
>do something more and i searched, but could not find anything. any
>suggestions? i appreciate your input.
>
>thanks


OOPS almost forgot
Also, there were no values outputted from either category
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h52.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14763 seconds with 12 queries