Announcement

Collapse
No announcement yet.

Select damn you.. SELECT!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Select damn you.. SELECT!

    hey all, im trying to customize this links script to fit my website, and what I wanna do is have the language field have a language selected when you load the page (ie. english) and not have it as "--select a language--" the category field below it auto selects the first category added.. so basically the bottom ones does what I want the top one to do. I played with this since 9am this morning, and not being a coder or any sort (I know html, lol) any help would be appreciated!!

    thanks guys!
    PHP Code:
    <tr>
     <td><?=ADD_HP_LANG?></td>
     <td align='center'>
     <? //get languages from db
     
    $res MYSQL_QUERY("SELECT * FROM $table_languages order by lang"); // get lang. from db
     
    echo "<select name='lang' onmouseover='this.focus()'>\n";
     echo 
    "<option value=''>".ADD_HP_CAT_SELECT."\n";
     while (
    $row MYSQL_FETCH_ARRAY($res))  // render lang-selection
     
    {
         if(
    $lang == $row[lang]) {  //render <select> for lang and select a lang, if set
         
    echo "<option value='$row[lang]' selected>$row[lang]\n";
         } else {
         echo 
    "<option value='$row[lang]'>$row[lang]\n"; }

     }
     
    MYSQL_FREE_RESULT($res); // give memory free
     
    echo "</select>\n"?>
     </td>
     </tr>


     <tr>
     <td><?=ADD_HP_CAT?></td>
     <td align='center'>
     <? //generate select-field with cat's
     
    $result MYSQL_QUERY("SELECT * FROM $table_cat order by $catorder");  // get cats from db

     // generate cat-selection <select>
     
    echo "<select name='add_cat' onmouseover='this.focus()'>\n";
     echo 
    "<option value=''>".ADD_HP_CAT_SELECT."\n";
     while (
    $row MYSQL_FETCH_ARRAY($result))
     {
         if(
    $row[id] == $from) {        // render <select> for cats and select a cat, if redirected from there
         
    echo "<option value='$row[id]' selected>$row[name]\n";
         } elseif(
    $add_cat == $row[id]) { echo "<option value='$row[id]' selected>$row[name]\n";
         } else { echo 
    "<option value='$row[id]'>$row[name]\n";     }

     }
     
    MYSQL_FREE_RESULT($result); // give memory free

     
    echo "</select>\n"?>
     </td>
     </tr>
    -Myles
    (sorry dbl posted @ vb.org cuz im itchin for help)
    MSN: [email protected] | MAIL: [email protected] | FOLIO: mholman.com

  • #2
    so you want it to show what the current language is, in the drop down menu?

    or do you want to just exclude the selected language from the list?

    -Dimava
    NXSupport Admin

    Comment


    • #3
      its an required field so I just wanted it to show; language ID1 from db, for example.

      -myles
      MSN: [email protected] | MAIL: [email protected] | FOLIO: mholman.com

      Comment


      • #4
        ehhhh...it already looks like it's set up to work correctly...maybe $lang isn't set?

        edit: i don't know if this matters, but try switching this around:

        PHP Code:
         // try switching this to if ($row['lang'] == $lang) {
         
        if($lang == $row[lang]) {  //render <select> for lang and select a lang, if set
             
        echo "<option value='$row[lang]' selected>$row[lang]\n";
             } else {
             echo 
        "<option value='$row[lang]'>$row[lang]\n"; } 

        Comment


        • #5
          cool thx, I will try that when get some free time tomrrow
          and I will check the db to see if $lang is set

          -myles
          MSN: [email protected] | MAIL: [email protected] | FOLIO: mholman.com

          Comment


          • #6
            where is $lang coming from ? also I don't see any <form> tags and close you <option> tags as well.

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...
            X