Connecting Tech Pros Worldwide Help | Site Map

passing variables to other pages

julian maisano
Guest
 
Posts: n/a
#1: Jul 17 '05
As you'll see, I'm a beginner php guy...

What i'm trying to achieve is:

1) List in AllProducts.php a set of products which are stored in a MySql
table. Each product has a picture. Each picture actually is a link to a
articulodetalle.php, where there will be greater pictures in, plus some
detailed text.


Code in AllProducts.php actually works fine:

$query = "SELECT * FROM articulos";
$result = mysql_query($query);
$i=0;
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
if($i==$public_numero_de_items_por_fila){ //acá cambia de columna
$i=0;
echo "<TR><TH>";
} else {
echo "<TH>";
}
$i+=1;
//here I set up the link to detallearticulo.php *******
echo '<a href="detallearticulo.php?id_articulo=' . $row['id_articulo']
.. '">';
echo '<img width="150" border="0" src="images/' . $row['id_articulo']
.. '.jpg" >';
echo '</a>';
echo "<br>";
echo "id_articulo :{$row['id_articulo']} <br>";
echo "descripcion :{$row['descripcion']} <br>";
echo "precio : {$row['precio']} <br><br>";
}


***** an example of the the link created (in AllProducts.php )is:

detallearticulo.php?id_articulo=xyz325


The problem i'm having is that I've an empty variable value in
detallearticulo.php

$id_articulo (in detallearticulo.php)should have the variable value
associated with the product (xyz325), but it's empty...

What's happening?
Any advice would be apreciated...

sdos - jm
Shelly
Guest
 
Posts: n/a
#2: Jul 17 '05

re: passing variables to other pages



"julian maisano" <julianmaisanoXYZ@gmail.com> wrote in message
news:db9m1e$iq8$1@domitilla.aioe.org...[color=blue]
> As you'll see, I'm a beginner php guy...
>
> What i'm trying to achieve is:
>
> 1) List in AllProducts.php a set of products which are stored in a MySql
> table. Each product has a picture. Each picture actually is a link to a
> articulodetalle.php, where there will be greater pictures in, plus some
> detailed text.
>
>
> Code in AllProducts.php actually works fine:
>
> $query = "SELECT * FROM articulos";
> $result = mysql_query($query);
> $i=0;
> while($row = mysql_fetch_array($result, MYSQL_ASSOC))
> {
> if($i==$public_numero_de_items_por_fila){ //acá cambia de columna
> $i=0;
> echo "<TR><TH>"; } else {
> echo "<TH>";
> }
> $i+=1;
> //here I set up the link to detallearticulo.php *******
> echo '<a href="detallearticulo.php?id_articulo=' . $row['id_articulo'] .
> '">';
> echo '<img width="150" border="0" src="images/' . $row['id_articulo'] .
> '.jpg" >';
> echo '</a>';
> echo "<br>";
> echo "id_articulo :{$row['id_articulo']} <br>";
> echo "descripcion :{$row['descripcion']} <br>";
> echo "precio : {$row['precio']} <br><br>";
> }
>
>
> ***** an example of the the link created (in AllProducts.php )is:
>
> detallearticulo.php?id_articulo=xyz325
>
>
> The problem i'm having is that I've an empty variable value in
> detallearticulo.php
>
> $id_articulo (in detallearticulo.php)should have the variable value
> associated with the product (xyz325), but it's empty...
>
> What's happening?
> Any advice would be apreciated...
>
> sdos - jm[/color]

in detallearticulo.php do you have line like?

$id_articulo = $_GET['id_articulo'];

Shelly


julian maisano
Guest
 
Posts: n/a
#3: Jul 17 '05

re: passing variables to other pages


Shelly wrote:[color=blue]
> "julian maisano" <julianmaisanoXYZ@gmail.com> wrote in message
> news:db9m1e$iq8$1@domitilla.aioe.org...
>[color=green]
>>As you'll see, I'm a beginner php guy...
>>
>>What i'm trying to achieve is:
>>
>>1) List in AllProducts.php a set of products which are stored in a MySql
>>table. Each product has a picture. Each picture actually is a link to a
>>articulodetalle.php, where there will be greater pictures in, plus some
>>detailed text.
>>
>>
>>Code in AllProducts.php actually works fine:
>>
>>$query = "SELECT * FROM articulos";
>>$result = mysql_query($query);
>>$i=0;
>>while($row = mysql_fetch_array($result, MYSQL_ASSOC))
>>{
>>if($i==$public_numero_de_items_por_fila){ //acá cambia de columna
>>$i=0;
>>echo "<TR><TH>"; } else {
>>echo "<TH>";
>>}
>>$i+=1;
>>//here I set up the link to detallearticulo.php *******
>>echo '<a href="detallearticulo.php?id_articulo=' . $row['id_articulo'] .
>>'">';
>>echo '<img width="150" border="0" src="images/' . $row['id_articulo'] .
>>'.jpg" >';
>>echo '</a>';
>>echo "<br>";
>>echo "id_articulo :{$row['id_articulo']} <br>";
>>echo "descripcion :{$row['descripcion']} <br>";
>>echo "precio : {$row['precio']} <br><br>";
>>}
>>
>>
>>***** an example of the the link created (in AllProducts.php )is:
>>
>>detallearticulo.php?id_articulo=xyz325
>>
>>
>>The problem i'm having is that I've an empty variable value in
>>detallearticulo.php
>>
>>$id_articulo (in detallearticulo.php)should have the variable value
>>associated with the product (xyz325), but it's empty...
>>
>>What's happening?
>>Any advice would be apreciated...
>>
>>sdos - jm[/color]
>
>
> in detallearticulo.php do you have line like?
>
> $id_articulo = $_GET['id_articulo'];
>
> Shelly
>
>[/color]

Absolutely not :(

I didn't know it was requeired. I'll look to php.net to see what the
hell is $_GET ...

By the way, I looked an example that didn't have $_GET and worked though

thanks - jm
Dave
Guest
 
Posts: n/a
#4: Jul 17 '05

re: passing variables to other pages


julian maisano (julianmaisanoXYZ@gmail.com) decided we needed to
hear...[color=blue]
> As you'll see, I'm a beginner php guy...
>
> What i'm trying to achieve is:
>
> 1) List in AllProducts.php a set of products which are stored in a MySql
> table. Each product has a picture. Each picture actually is a link to a
> articulodetalle.php, where there will be greater pictures in, plus some
> detailed text.
>
>
> Code in AllProducts.php actually works fine:
>
> $query = "SELECT * FROM articulos";
> $result = mysql_query($query);
> $i=0;
> while($row = mysql_fetch_array($result, MYSQL_ASSOC))
> {
> if($i==$public_numero_de_items_por_fila){ //acá cambia de columna
> $i=0;
> echo "<TR><TH>";
> } else {
> echo "<TH>";
> }
> $i+=1;
> //here I set up the link to detallearticulo.php *******
> echo '<a href="detallearticulo.php?id_articulo=' . $row['id_articulo']
> . '">';
> echo '<img width="150" border="0" src="images/' . $row['id_articulo']
> . '.jpg" >';
> echo '</a>';
> echo "<br>";
> echo "id_articulo :{$row['id_articulo']} <br>";
> echo "descripcion :{$row['descripcion']} <br>";
> echo "precio : {$row['precio']} <br><br>";
> }
>
>
> ***** an example of the the link created (in AllProducts.php )is:
>
> detallearticulo.php?id_articulo=xyz325
>
>
> The problem i'm having is that I've an empty variable value in
> detallearticulo.php
>
> $id_articulo (in detallearticulo.php)should have the variable value
> associated with the product (xyz325), but it's empty...
>
> What's happening?
> Any advice would be apreciated...
>
> sdos - jm
> [/color]

You seem to be assuming that $id_articulo will be set for you
automatically. If register_globals is on in php.ini then that
is what will happen, however register_globals is a potential
security risk (when not used correctly) and so its default
value is off since PHP 4.2

The "correct" way to access the variable passed from your first
script is to use $_GET['id_articulo'] instead of $id_articulo

--
Dave <dave@REMOVEbundook.com>
(Remove REMOVE for email address)
Shelly
Guest
 
Posts: n/a
#5: Jul 17 '05

re: passing variables to other pages


"julian maisano" <julianmaisanoXYZ@gmail.com> wrote in message
news:dba2ch$3d7$1@domitilla.aioe.org...[color=blue]
> Shelly wrote:[color=green]
>> in detallearticulo.php do you have line like?
>>
>> $id_articulo = $_GET['id_articulo'];
>>
>> Shelly[/color]
>
> Absolutely not :(
>
> I didn't know it was requeired. I'll look to php.net to see what the hell
> is $_GET ...
>
> By the way, I looked an example that didn't have $_GET and worked though
>
> thanks - jm[/color]

When you pass values in the caller page by:

calledpage,php?thing1=value1&thing2=value2

you get them in the called page, calledpage.php, by:

$variable1 = $_GET['thing1'];
$variable2 = $_GET['thing2'];

Shelly


Peter van Schie
Guest
 
Posts: n/a
#6: Jul 17 '05

re: passing variables to other pages


julian maisano wrote:
[color=blue]
> Absolutely not :(
>
> I didn't know it was requeired. I'll look to php.net to see what the
> hell is $_GET ...
>
> By the way, I looked an example that didn't have $_GET and worked though[/color]

It does when register_globals is set to On in php.ini (which is a bad
idea). Another way is to first call:

extract($_GET, EXTR_SKIP);

and then do what you used to do. I wouldn't use that though and stick
with using $_GET['xx'], because you'll see immediately that the variable
in question is a GET variable and it's safer.

--
http://www.phpforums.nl
Closed Thread