Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2005
    Posts
    15

    Unanswered: Passing values - radiobutton - $_SESSION

    Hi all,

    I've got this script that collects information from a postgres database. I need to pass the values(cod) of the product choosen by the user into another webpage, and later insert in into another table. I think I'll need to use $_SESSION or $_POST to pass the values, but I don't know how. Can anyone help me pleeeeeaaaaase???????????!!!!!!!!!!!!!!!!!


    <?php

    session_start();
    include("header.php");

    //Let's connect to the database
    $db = ADONewConnection('postgres');
    $db->debug = true;
    $db -> PConnect("host=localhost
    port=5200
    dbname=TEST
    user=test
    password=1111") or die("Bum");



    $result = pg_query("select Cod,product,flavour, price
    from icecream");

    for($i=0; $i < pg_num_fields($result); $i++)
    {
    echo "<form action=\"ice.php\" method=post >";

    echo "<th width='5%'>" . pg_field_name($result, $i) . "</th>";
    }
    echo "</tr>";


    while ($row = pg_fetch_array($result)) {
    $COD=$row['Cod'];
    $product_t=$row['product'];


    echo "<tr>";
    echo "<td width='2%'>";
    echo $row["Cod"];
    echo "</td>";
    echo "<td width='3%'>";
    echo $row["product"];
    echo "<td width='2%'>";
    echo $row["flavour"];
    echo "</td>";
    echo "<td width='2%'>";
    echo $row["price"];
    echo "</td>";
    echo "<td width='10%'> <input name=\"$product\" type=\"radio\" value=\"$row[Cod]\" />";
    echo"</td>";
    echo "</tr>";
    }
    echo "</table>";
    echo "</table>";
    echo "<tr><td colspan=1 align=center>";
    echo "<input type=submit value=\"Buy\">";
    echo "</form>";



    // close database connection
    $db->close();
    ?>

  2. #2
    Join Date
    Aug 2004
    Location
    San Antonio, TX
    Posts
    84

  3. #3
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    Also, you may want to remove that <form> declaration from your for loop. It shouldn't really matter with how you have things written now, but it should be before the loop.

    And make sure you're giving the radio buttons the correct name. Buttons with different names are in different button groups. So if you want just one big group, make sure the names are all the same. Then you access the values on 'ice.php' by calling $_POST[$radio_group_name];

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •