passing variables to other pages

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • julian maisano

    passing variables to other pages

    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($qu ery);
    $i=0;
    while($row = mysql_fetch_arr ay($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="detallear ticulo.php?id_a rticulo=' . $row['id_articulo']
    .. '">';
    echo '<img width="150" border="0" src="images/' . $row['id_articulo']
    .. '.jpg" >';
    echo '</a>';
    echo "<br>";
    echo "id_articul o :{$row['id_articulo']} <br>";
    echo "descripcio n :{$row['descripcion']} <br>";
    echo "precio : {$row['precio']} <br><br>";
    }


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

    detallearticulo .php?id_articul o=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

    #2
    Re: passing variables to other pages


    "julian maisano" <julianmaisanoX YZ@gmail.com> wrote in message
    news:db9m1e$iq8 $1@domitilla.ai oe.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($qu ery);
    > $i=0;
    > while($row = mysql_fetch_arr ay($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="detallear ticulo.php?id_a rticulo=' . $row['id_articulo'] .
    > '">';
    > echo '<img width="150" border="0" src="images/' . $row['id_articulo'] .
    > '.jpg" >';
    > echo '</a>';
    > echo "<br>";
    > echo "id_articul o :{$row['id_articulo']} <br>";
    > echo "descripcio n :{$row['descripcion']} <br>";
    > echo "precio : {$row['precio']} <br><br>";
    > }
    >
    >
    > ***** an example of the the link created (in AllProducts.php )is:
    >
    > detallearticulo .php?id_articul o=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


    Comment

    • julian maisano

      #3
      Re: passing variables to other pages

      Shelly wrote:[color=blue]
      > "julian maisano" <julianmaisanoX YZ@gmail.com> wrote in message
      > news:db9m1e$iq8 $1@domitilla.ai oe.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
      >>articulodetal le.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($qu ery);
      >>$i=0;
      >>while($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
      >>{
      >>if($i==$publi c_numero_de_ite ms_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="detallear ticulo.php?id_a rticulo=' . $row['id_articulo'] .
      >>'">';
      >>echo '<img width="150" border="0" src="images/' . $row['id_articulo'] .
      >>'.jpg" >';
      >>echo '</a>';
      >>echo "<br>";
      >>echo "id_articul o :{$row['id_articulo']} <br>";
      >>echo "descripcio n :{$row['descripcion']} <br>";
      >>echo "precio : {$row['precio']} <br><br>";
      >>}
      >>
      >>
      >>***** an example of the the link created (in AllProducts.php )is:
      >>
      >>detallearticu lo.php?id_artic ulo=xyz325
      >>
      >>
      >>The problem i'm having is that I've an empty variable value in
      >>detallearticu lo.php
      >>
      >>$id_articul o (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

      Comment

      • Dave

        #4
        Re: passing variables to other pages

        julian maisano (julianmaisanoX YZ@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($qu ery);
        > $i=0;
        > while($row = mysql_fetch_arr ay($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="detallear ticulo.php?id_a rticulo=' . $row['id_articulo']
        > . '">';
        > echo '<img width="150" border="0" src="images/' . $row['id_articulo']
        > . '.jpg" >';
        > echo '</a>';
        > echo "<br>";
        > echo "id_articul o :{$row['id_articulo']} <br>";
        > echo "descripcio n :{$row['descripcion']} <br>";
        > echo "precio : {$row['precio']} <br><br>";
        > }
        >
        >
        > ***** an example of the the link created (in AllProducts.php )is:
        >
        > detallearticulo .php?id_articul o=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_global s is on in php.ini then that
        is what will happen, however register_global s 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@REMOVEbun dook.com>
        (Remove REMOVE for email address)

        Comment

        • Shelly

          #5
          Re: passing variables to other pages

          "julian maisano" <julianmaisanoX YZ@gmail.com> wrote in message
          news:dba2ch$3d7 $1@domitilla.ai oe.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&t hing2=value2

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

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

          Shelly


          Comment

          • Peter van Schie

            #6
            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_global s 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.

            --

            Comment

            Working...