Afficher un message
Vieux 28/09/2007, 05h15   #6
Aaron Saray
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Does PHP5 support dynamic variables?

On Sep 27, 7:35 pm, "peter" <sub...@flexiwebhost.com> wrote:
> > What I really need some with was understanding why $categoryvalue
> > would
> > be empty.

>
> Try echoing out $tempbox and see if it looks as expected. Ensure that a
> variable exists with the name of what it choes out. Another thing you could
> do is ensure you have all errors being reported (error_reporting(E_ALL).
> If $tempbox is not outputting what is expected then I would expect an error
> message stating an undefined variable such as:-
>
> Notice: Undefined variable: b in php-file on line 4
>
> This indicates that variable b has not been defined yet I am trying to use
> it.


Lets make the assumption that your categoryid is a numeric value...
and its going 1, 2, 3, etc... for all of your values and the
categories corresponding are dog, cat, fish

categoryid, category
1, dog
2, cat
3, fish



So the first time through, you're going to have this::

//1st iteration:
//categoryval lets say this is 'dogs'
$categoryval = $categoryrow["category"];

//categoryidval = 1
$categoryidval = $categoryrow["categoryid"];

//tempbox = 'box1'
$tempbox = "box" . $categoryidval;

//$tempbox = 'box1'... variable of that means we're looking for a
variable named $box1 now.
$categoryvalue = ${$tempbox};

Was $box1 defined? No? could be blank categoryvalue then.

As suggested above, turn up your error_reporting... also maybe paste
in any other relevant details - ie, where is $box1 being defined?

  Réponse avec citation
 
Page generated in 0,06492 seconds with 9 queries