SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Duplicate records

    Hello, can anyone help me with the question: I have a looping form:
    PHP Code:
    [...] 
    for ($ 
    0; $ <$ _POST ['NUM_IMAGES'], $ + +) { 
    / / 
    Determine alternate row colors 
    if ($ i== 0) { 
    Style "bgcolor = \" # FFFFFF \ ""; 
    $ Bottomstyle = "
    bgcolor = \" # FFFFFF \ ""; 
    Else {} 
    $ Style = "
    bgcolor = \" # EFEFEF \ ""; 
    $ Bottomstyle = "
    bgcolor = \" # EFEFEF \ ""; 

    echo ("
    <tr> \ <td $style width='15%'Image # '. ($ i + 1)." </ td> \ n <td $style> <input type =' file 'name =' image []'></ td> \ n </ tr> "); 
    echo ("\ n <tr> \ n <td $style width='15%'> Image Title: </ td> \ n <td $style> <input type='text' name='photo_title[]'> </ td> \ n </ tr> "); 
    echo (
    "\ n <tr> \ n <td $style valign=\"top\"> Photo Description: </ td> \ n <td $style> <textarea name = 'photo_desc []' cols = '30 ' rows = '6 'wrap =' default '> </ textarea> </ td> \ n </ tr> "); 
    echo (
    "\ n <tr> \ n <td $style valign=\"top\"> Album Cover </ td> \ n <td $style> <input type = \" radio \ "name = \" album_cover \ "value = \" $ i \ ">"); 

     [...] 
    In another php file I insert in the database:
    PHP Code:
    [More code ...] 
    foreach ($ 
    _POST ['photo_title'] as $ value) { 
    Sql &#8203;​= "INSERT INTO photos VALUES (0, '$ value', '$ _POST [photo_desc]', NOW (), '$ image_location', '$ thumb_location', $ _POST [album_id])," [... more code] 
    But the record is saved duplicate and confused.
    Someone could help me? Thanks in advanced!

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,501
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    But the record is saved duplicate and confused.
    Confused?

  3. #3
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry my bad English, with the code above the records are duplicated, if I insert one picture it saves two, if I insert two are four give the names blend together, how to solve? Help me Sr. guido2004!


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
  •