SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2002
    Location
    london
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP, MySQL & checkboxes

    Hi all

    +--------------+-------------------+
    | Product_id | Product_image |
    +--------------+-------------------+

    I have a table with two columns as in the above diagram.

    I have a page with 5 checkboxes like this:

    <input type='checkbox' name='Prod_chk' value="<?= $array['Product_id']">

    I want to run a query on my table to select the relevant products when a user checks some of the boxes but I'm stuck.

    Is there some way of selecting the checked boxes something like (I know this syntax doesn't actually work):

    PHP Code:
    $temp_arr = array() //boxes that were checked

    "SELECT Product_image FROM My_products WHERE Product_id IN ($temp_arr)" 

    Thanks
    L
    give me all your lentils

  2. #2
    SitePoint Addict Ramiro S's Avatar
    Join Date
    May 2003
    Posts
    321
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont get it... do you want some example to display the checkboxes selected depending on the database info

    or

    select from the database what the customer selected in the checkboxes?
    Quasar - Web Development - Free Avatars

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2002
    Location
    london
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey

    thanks for replying - its cool, I worked it out.

    I was trying to find a way of getting an array into the 'IN' part of the query. It wasn't working because I had some quotes missing.

    Cheers
    L
    give me all your lentils


Bookmarks

Posting Permissions

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