Results 1 to 9 of 9
  1. #1

    Default need help sa drop down list in html & php


    balik nasad ko ask nnu mga master kani nlang jud

    unsaon man pag retrieve sa gender using <select optio> in php?

    form submit for registration is ing ani dba!

    gender

    <select name="gender">
    <option value="male">Male</option>
    <option value="female">Female</option>
    <select>

    so ang mag una sa list is ang male dba!

    nya inig view profile nako/user lets sat female sya so the ui would be like this

    IDEAL GUI / DISPLAY

    name:JANE
    age:18
    gender: FEMALE // imagina lang na ang female kay naa sa option value/drop down list hehe


    pero sa akoa ing ani ang mogawas

    name:JANE
    age:18
    gender: MALE // imagina lang na ang male kay naa sa option value/drop down list hehe

    UNSAON mani na if female iya gender ang mogawas sa profile is female dli male??

    salamat

  2. #2
    vague kaau imo g hatag na details bro.. peru if you queried your values from ur DB... ing-ani cguru imo gusto....



    $result = mysql_fetch_array($querystring);

    if( $result[Gender] == "male" )
    {
    <select name="gender">
    <option value="male">Male</option>
    <option value="female">Female</option>
    <select>
    }
    else
    {
    <select name="gender">
    <option value="female">Female</option>
    <option value="male">Male</option>
    <select>
    }
    sakto ba??

  3. #3
    salanat juuuuuuuuuuuuuuuuuudddddd kau sir ikaw ra juy tig ans. sa akong mga bugs heheheh php-man

    guru ka heeheh

    ge ign ani ra nko sir sayun raman d ay ni

    <label>Gender</label>';
    if($gender=='male'){
    echo'
    <select name="gender" >
    <option value="male">Male</option>
    <option value="female">Female</option>
    </select>';
    }
    else{
    echo'
    <select name="gender" >
    <option value="female">Female</option>
    <option value="male">Male</option>

    </select>';

    }



    pero dli lang sa gender ako purpose sa birthdate jud ni para man gud ni sa editprofile

    una view profile dayun f mo edit so parehas rag output sa view profile pero ang dperensya lng kay ma erase na sa view to edit dba!

    salamt kau sir apil ka sa Acknowledgement sa among thesis heheh

  4. #4
    to optimize, instead of using a string in gender value, it is wise to use a value of 0 and 1 (1-Male, 0-Female).

    so instead of using:

    if($gender == 'male')

    you can use

    if($gender) or if($gender==1)

    that saves a few bytes...

  5. #5
    No need to change the order but you need to add a default selection.
    This is done by adding 'selected="selected"' inside the <selection> tag.

    For example, to make "Male" the default displayed:
    <select name="gender" >
    <option value="female">Female</option>
    <option value="male" selected="selected" >Male</option>
    </select>

    Changing to make the default at to be first is counter-intuitive. For example you want to select a City which the case can display hundreds of choices and in sorted. Adding "selected" is the right way.

  6. #6
    taking consideration the inputs of tynum and cold_fusion, plus the optimization:

    Code:
    $result = mysql_fetch_array($querystring);
    
    echo "<select name="gender">";
    
    if( $result[Gender] == 1 ) {
       echo '<option value="1" selected="selected">Male</option>';
       echo '<option value="0">Female</option>';
    } else {
       echo '<option value="1">Male</option>';
       echo '<option value="0" selected="selected">Female</option>';
    }
    
    echo "</select>";

  7. #7
    case closed...

  8. #8

    Default optimized code

    sorry na open otro ha... hehehehehe

    Code:
    $result = mysql_fetch_array($querystring);
    $male_tag = '';
    $female_tag = '';
    
    if($result[Gender]) {
      $male_tag = ' selected="selected"';
    } else {
      $female_tag = ' selected="selected"';
    }
    
    echo "<select name="gender">";
    echo '<option value="1"'.$male_tag.'>Male</option>';
    echo '<option value="0"'.$female_tag.'>Female</option>';
    echo "</select>";

  9. #9
    final judgement...

    CASE CLOSED...


    hehehehe

  10.    Advertisement

Similar Threads

 
  1. need help sa linux be version 9
    By kermesh in forum Computer Hardware
    Replies: 3
    Last Post: 03-01-2013, 03:10 PM
  2. Guys need help sa business na carwash
    By mack0y in forum Business, Finance & Economics Discussions
    Replies: 7
    Last Post: 01-29-2013, 12:41 AM
  3. Replies: 23
    Last Post: 11-28-2012, 08:33 AM
  4. guys i need help sa mga famous in guitars & effects
    By casterTroy in forum Music & Radio
    Replies: 37
    Last Post: 08-27-2007, 06:43 PM
  5. need help sa C
    By chokobo in forum Programming
    Replies: 12
    Last Post: 02-25-2006, 08:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top