SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help in Adding Records in Database using Explode

    Hello frnds n expert i m new here

    I m not able to make this happend in php mysql

    i want to store records after getting it from user in database

    1. i m getting data in text box frm users like apple,orange,carrot
    2. now every data is comming from autocomplete list. whcih have a unique id.

    so wht i want is i to store tht id in database n then retrive it as seprate record using explode funcntion

    I hope i m clear
    Please help me out...

    Thanks

  2. #2
    SitePoint Evangelist
    Join Date
    May 2006
    Location
    Denmark
    Posts
    407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First select all the rows that have the name apple, orange or carrot. Using their IDs you can do new inserts.

  3. #3
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no no i have one text box where user adding multiple data like using comma " ," whole records get in one filed only like

    1=apple
    2=organe
    3=carrot
    Field name FRUITS. its saved like 1,2,3

    while retriving data

    i want to deal with 1,2,3 seprate

    like fruits_details.php?id=1
    so it will show whole detail of apple
    so no..

    how to do that...i m confused

  4. #4
    SitePoint Member webiz's Avatar
    Join Date
    Aug 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can do it in the following way:

    Code:
    <?php
    //get the text field value first
    $fruit = $_REQUEST['FRUITS'];
    
    //split it on the basis of comma by using explode in php and store them in an array
    $pieces = explode(",", $fruit);
    
    //Now you can iterate using foreach loop and use the sepearte ids stored in the array like this(it is an example only)
    foreach($pieces as $k=>$v)
    {
    	fruits_details.php?id=$v //i don't know what you are trying to do
    }
    ?>
    Visit me at www.inovasio.com


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
  •