Jump to content
Larry Ullman's Book Forums

sandari

Members
  • Posts

    29
  • Joined

  • Last visited

Posts posted by sandari

  1. When I run the following code it runs through the entire list of suburbs and only displays the last one rather than the selceted suburb.

     

    What am I doing wrong?

     

     

    <?php
     $query="select * from tblStaff where StaffID=$staffID";
    $result=@mysqli_query($dbc,$query);
    $row=mysqli_fetch_array($result,MYSQLI_ASSOC);
    
    $selected_suburb=$row['Suburb'];
    
    echo"<label>Suburb</label><br />";
    echo"<select name=\"Suburb\">";
    $query="select suburb_id, suburb, state, postcode
    from tblPostcodes
    order by suburb,state, postcode asc;";
    $result=@mysqli_query($dbc,$query);
    while($row=mysqli_fetch_array($result,MYSQLI_ASSOC)){
     	 $selected="";
     	 foreach($row as $suburb_id => $suburb){
     	 if($row['suburb_id']==$selected_suburb){
     	 $selected="selected";
     	 }
     echo"<option value={$row['suburb_id']}
     selected=$selected>
     {$row['suburb']} {$row['state']} {$row['postcode']}</option>";
     	 }
    }
    echo"</select>";
    ?>
    

  2. <p><p>What is wrong with this code?

    <?php
    $Available=1;
    ...
    <label>Currently Available?</label><br />
    <input type=\"radio\" name=\"Available\" value=(if($Available==1){echo'checked=\"checked\"'})>Yes
    <input type=\"radio\" name=\"Available\" value=(if($Available!=1){echo'checked=\"checked\"'})>No
    ?>
    

     

    Whatever I do I cannot get any value to display in either option.

×
×
  • Create New...