SitePoint Sponsor

User Tag List

Page 2 of 4 FirstFirst 1234 LastLast
Results 26 to 50 of 76
  1. #26
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    return (isset($_POST[$_index])) ? $_POST[$_index] : ''
    I had missed a parenthese.

    Your select box markup is a bit messed up. Do you want to let the user choose more then the current entry, which hasn't even got a name in your code?

  2. #27
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I simply want the previous selected option to be selected once again. If no option is selected, then it be blank (again) so they can select it.

    The original code for that part was:
    PHP Code:
    <td><select name="createdby_select" id="createdBy">
          <OPTION SELECTED VALUE="">---------------</OPTION>
          <?php
      
    while ($createdby_q mysql_fetch_array($createdby_query)) {
      
    $createdby_id $createdby_q["createdbyID"];
      
    $createdby_name $createdby_q["createdbyName"];
      echo(
    "<OPTION VALUE='$createdby_id'>$createdby_name<BR>\n");
       }
           
    ?>
        </select></td>
    So I was just wondering how to adjust this using your code.

    Thanks.

    Mak

  3. #28
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    /* Ignore this line */ ?>
    <td>
        <select name="createdby_select" id="createdBy">
            <option value="">---------------</option>
            <?php
                $preselection 
    safe_post('createdby_select');
                while (
    $createdby_q mysql_fetch_array($createdby_query)) {
                    
    $selected = ($preselection == $createdby_q['createdbyID']) ? 'selected' '';
                    echo 
    '<option '.$selected.' value="'.$createdby_q['createdbyID'].'>'.
                          
    $createdby_q['createdbyName'].'<br>'."\n";
               }
            
    ?>
        </select>
    </td>

  4. #29
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I tried that but something odd happens.

    The options I can select are:

    1. Myself
    2. Parent
    3. Guardian
    4. Other family member
    5. Friend

    When I select 'Myself' and post the form with the rest blank, it brings up the appropriate error messages and I would expect it to have 'Myself' selected again. Instead, it has:

    "--------------
    Parent
    Other family member
    Forename"

    Equally, similar odd stuff happens when I select any other option. What I don't understand is where it is getting 'Forename' from? Is something wrong with the way I am accessing the $_POST array?

    Thanks.

    Mak

  5. #30
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the while loop echo out $createdby_q['createdbyName'], $createdby_q['createdbyID'] and $selected after the echo please.

  6. #31
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Sorry for being thick but do you mean:
    PHP Code:
    <?php 
                $preselection 
    safe_post('createdby_select'); 
                while (
    $createdby_q mysql_fetch_array($createdby_query)) { 
          
    $selected = ($preselection == $createdby_q['createdbyID']) ? 'selected' ''
                   
    //echo '<option '.$selected.' value="'.$createdby_q['createdbyID'].'>'.$createdby_q['createdbyName'].'<br>'."\n"; 
                   
    echo '<option '.$selected.' value="">'\n"; 
                   
               } 
            ?>
    ?

    Thanks.

    Mak

  7. #32
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    echo 'Name: ' $createdby_q['createdbyName'] , ' ID: ' $createdby_q['createdbyID'] , ' Selected: ' $selected' , ' Preselection' , $preselection , '<br />'; 
    after the echo of the option tag. This is for debugging reasons, to know that is fetched from the database and what the data generates.

  8. #33
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    With that I get:

    Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';'

    Any ideas?

    Thanks.

    Mak

  9. #34
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry one quote to much.
    PHP Code:
    echo 'Name: ' $createdby_q['createdbyName'] , ' ID: ' $createdby_q['createdbyID'] , ' Selected: ' $selected ' Preselection: ' $preselection '<br />'

  10. #35
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Then I get (in the re-displayed select box):

    ->Parent Name: Parent ID: 2: Preselection: 1
    ->Other family member Name: Other family member ID: 4 Selected: Preselection: 1
    ->Forename

    Those are the three options it shows. What's odd is the 'Forename' as that is, as yet, just the next field:
    PHP Code:
    <tr>
        <
    td width="223">Forename</td>
        <
    td width="241">
         <
    input name="mForename" type="text" id="mForename" size="25" maxlength="25">
        </
    td>
    </
    tr
    Hope that helps?

    Oh, btw, the database code is:
    Code:
    # Table structure for table `createdby`
    #
    
    CREATE TABLE `createdby` (
      `createdbyID` int(1) NOT NULL auto_increment,
      `createdbyName` varchar(20) default NULL,
      PRIMARY KEY  (`createdbyID`)
    ) TYPE=MyISAM AUTO_INCREMENT=6 ;
    
    #
    # Dumping data for table `createdby`
    #
    
    INSERT INTO `createdby` VALUES (1, 'Myself');
    INSERT INTO `createdby` VALUES (2, 'Parent');
    INSERT INTO `createdby` VALUES (3, 'Guardian');
    INSERT INTO `createdby` VALUES (4, 'Other family member');
    INSERT INTO `createdby` VALUES (5, 'Friend');
    Thanks.

    Mak

  11. #36
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can I have the full source, I would need everything to be able to successfully debug it. Thanks.

  12. #37
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    It was a bit long to post so I have PM'd you it in sections.

    Thanks.

    Mak

  13. #38
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I will look into it tommorrow.

  14. #39
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Look foward to your reply

    Thanks.

    Mak

  15. #40
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I attached the PHP file, I hope it helps you.
    Attached Files Attached Files

  16. #41
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Where is the attached PHP file?

    Thanks.

    Mak

  17. #42
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to wait till it is approved.

  18. #43
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I still can't see anything.. either here or in private messages.. and it has been a couple of days?

    Thanks.

    Mak

  19. #44
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see it now.

  20. #45
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Thanks for that!

    I just tried it and get this:

    Parse error: parse error, unexpected ';' in d:\inetpub\wwwroot\site\join_form.php on line 6

    I think it is referring to this line:
    PHP Code:
    return (isset($_POST[$_index]) ? $_POST[$_index] : ''
    Thanks.

    Mak

  21. #46
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Should be
    PHP Code:
    return (isset($_POST[$_index])) ? $_POST[$_index] : ''

  22. #47
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I fixed that but then I get:

    Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in d:\inetpub\wwwroot\site\join_form.php on line 39

    PHP Code:
    $selected     = ($preselected == $createdby_id'selected' ''
    I thought it may be some missing parentheses but that didn't work.

    Any ideas?

    Thanks.

    Mak

  23. #48
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Must be
    PHP Code:
    $selected     = ($preselected == $createdby_id) ? 'selected' ''

  24. #49
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    What about:

    Parse error: parse error, unexpected '=' in d:\inetpub\wwwroot\site\join_form.php on line 84
    PHP Code:
    $preselection safe_post('day_select'); 
    Thanks.

    Mak

  25. #50
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I hopefully cleared out some of the errors, see the attached file.
    Attached Files Attached Files


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
  •