#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    12
    Rep Power
    0
    I am using the following code to extract from mysql a users shopping basket. What i want to be able to do is to get all the information that is displayed by the while loop and be able to submit all that information in a hidden file:
    ie <input type="hidden" name="desc" value="$whatever">

    $whatever being the information generated by the while loop. Anyone got any ideas please?

    while ($row=mysql_fetch_array($sq1_result)){
    $code=$row["CODE"];
    $description1=$row["DESCRIPTION"];
    $cost=$row["COST"];
    $quantity=$row["QUANTITY"];
    $price=$row["PRICE"];
    $total=$row["TOTAL"];
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    You'll need to use an array to be able to use in the info in the target script.
    <code>

    while ($row=mysql_fetch_array($sq1_result))
    {
    $code=$row["CODE"];
    $description1=$row["DESCRIPTION"];
    $cost=$row["COST"];
    $quantity=$row["QUANTITY"];
    $price=$row["PRICE"];
    $total=$row["TOTAL"];
    ?>
    <input type=hidden name='code[]' value='<%= $code %>'>
    <input type=hidden name='description[]' value='<%= $description1 %>'>
    // etc
    <?
    }
    ?>
    </code>
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Location
    Alkmaar, The Netherlands
    Posts
    123
    Rep Power
    15
    Try this:

    echo "<FORM>";
    while ($row=mysql_fetch_array($sq1_result)){
    $code=$row["CODE"];
    $description1=$row["DESCRIPTION"];
    $cost=$row["COST"];
    $quantity=$row["QUANTITY"];
    $price=$row["PRICE"];
    $total=$row["TOTAL"];

    echo "<INPUT TYPE="HIDDEN" NAME="desc" VALUE="code=$code;description=$description;cost=$cost;quantity=$quantity;price=$price;total=$total;" >";
    }
    </FORM>

    The original values can be extracted with the split function.



    ------------------
    Good luck,
    Bas

    ------------------
    E-mail me at: b.vandermeijden@pecoma.nl
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    12
    Rep Power
    0
    Thanks for the ideas , but i need to be able to submit all the results generated by the while loop as 1 string in the hidden field
    eg while loop produces:

    product1 qty 3 value 4 total 12
    product2 qty 2 value 1 total 1
    product3 qty 5 value 8 total 40

    the hidden field then needs to be outside the loop

    <input type ="hidden" name="desc" value ="product1 qty 3 value 4 total 12
    product2 qty 2 value 1 total 1
    product3 qty 5 value 8 total 40"

    or whatever the string would be called to generate the information in the hidden field value

    thanks again
  8. #5
  9. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Your description doesn't contain the same number of fields as your query. Also, it appears you aren't passing descriptors, just space seperated values with new lines between records. If this is the case, then build it in a variable and use fetch_row to make it easier:

    $temp="";
    while ($row=mysql_fetch_row($sq1_result))
    {
    $temp.=implode(' ',$row)."n";
    }
    print "<input type=hidden name=desc value='$temp'>";
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    12
    Rep Power
    0
    Cool , thanks Rod K thats almost what i need , the only problem is that i don`t want to include the first 2 values of the array , can you tell me how to change your script to disregard the first 2 items?

    Thanks for the help
  12. #7
  13. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    The easiest way to exclude the first 2 is to not include them in the query. Only select those fields you want.

Similar Threads

  1. Replies: 3
    Last Post: February 11th, 2004, 08:30 AM
  2. Replies: 5
    Last Post: February 11th, 2004, 02:18 AM
  3. Replies: 0
    Last Post: February 10th, 2004, 11:44 PM
  4. Replies: 1
    Last Post: February 5th, 2004, 06:17 AM
  5. How do I extract data form multiple files?
    By cols2910 in forum Visual Basic Programming
    Replies: 1
    Last Post: January 21st, 2004, 06:44 AM

IMN logo majestic logo threadwatch logo seochat tools logo