SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Nov 2007
    Fort Benning, GA
    0 Post(s)
    0 Thread(s)

    Select list not populating

    Hello all,
    I am relatively new to PHP so please bear with me. I have a site that I am rewriting from Coldfusion to PHP because I like PHP better and I am tired of using ColdFusion. Anyway, everything is going well except for this stupid select list that is not populating. Here is my code below:
    First, I query a table that joins two other tables together. If there is a result (there will be ONLY one result if there is), then I do this:

    PHP Code:
    $q2 "SELECT resort_id, gift_id FROM resort_gift WHERE gift_id = $id";

    $r2 = @mysqli_query($dbc$q2); 
    If there is a result of one record (again, there will be either one or no records as this is a one to many relationship:

    PHP Code:
    if (mysqli_num_rows($r2) == 1) {
    $q3 "SELECT Resort_ID, Resort_Name FROM Resorts";
    $r3 = @mysqli_query($dbc$q3);
    $row3 mysqli_fetch_array($r3MYSQLI_NUM);
    I then am creating an array to populate the <option> tag like so:
    PHP Code:
            while (
    $row=mysqli_fetch_array($r3)) {
    $options="<OPTION VALUE=\"$id\">".$rn.'</option>';
    Then in the form I am doing this:

    PHP Code:
     <?php if (mysqli_num_rows($r3) > 0) {
    ?> <select name="Resort_ID">
                    <?php ?> </select><br /><br />
    Now here is my question. One of the things that I need to do is, the resort that is tied to the gift certificate that I am editing should be automatically selected, but I still want to see all the resorts since the user could have selected the wrong resort by mistake.
    Can someone point out what I am doing wrong?


    Last edited by cpradio; Mar 6, 2013 at 06:03. Reason: Added [php] tags


Posting Permissions

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