Jump to content

monkeysaurus

Member
  • Posts

    104
  • Joined

  • Last visited

Posts posted by monkeysaurus

  1. Use an associative array, and asort instead of sort:

     

    <?php
    
    $options = array('http://google.com'=>'Google', 'http://www.yahoo.com'=>'Yahoo', 'http://www.hotmail.com'=>'Hotmail'); 
    asort($options);
    
    ?>
    
    <?php foreach($options as $k=>$v){ ?>
    <?php echo $v?>
    <?php } ?>
    
    
    

  2. Or a server side language.

     

    For example...

     

    PHP:

     

    <?php
    
    $options = array('John', 'Eric', 'Thelma'); // and 97 others
    sort($options);
    
    ?>
    
    <?php foreach($options as $k=>$v){ ?>
    <?php echo $v?>
    <?php } ?>
    
    
    

     

    Python:

     

    options = ["John", "Eric", "Thelma"]
    options.sort()
    # Gives you a sorted list, then do your HTML thing as above
    

     

    This could be done in javascript, but I wouldn't recommend it. Javascript might be switched off, and if you're injecting 100 elements into the DOM, that would be awfully slow. The best way to do it would be to put all 100 elements into an array, sort it, build the HTML in a string, then inject the string into the select list's innerHTML.

     

    But really, server side is the way to go.

  3. It looks like Dreamweaver is performing some black magic behind the scenes. This thread should really be in the Dreamweaver section of the forum, by the looks of it.

     

    (By the way, your database won't be PHP, it will likely be MySql. PHP is one programming language that can be used to connect to databases.)

  4. It will be hidden on a web server that supports ASP, but your's clearly doesn't since the code is showing.

     

    What you are trying to do is straightforward using straight PHP; I would recommend that's what you do.

  5. It looks like you have both ASP and PHP running in the same script. It isn't usually possible to do this without a lot of difficulty.

     

    Is your server Windows or Linux based? If it's Linux, you won't be able to use ASP. If it's windows based, you might be able to use either php or asp, but probably not both.

     

    Also, the code you're seeing in Firefox is being sent to the other browsers - view the source to see. Opera is also displaying the code.

     

    I would suggest that you need to look over the basics again - try Tizag or Killer PHP to start with, if you decide to go PHP.

  6. stripos ? Returns the numeric position of the first occurrence of needle in the haystack string.

     

    Unlike strpos(), stripos() is case-insensitive.

  7. Hi Andre,

     

    You need to remove the following line:

     

    $result = mysql_fetch_array($result);
    

     

    There's no need for it to be there with the second while($row = mysql_fetch_array($result)). Let me know if that works for you.

  8. What are you using to sort the table? Without seeing any code it's a little difficult to guess why your table is being hidden on sort.

     

    If you're hoping to track the open/closed status of the table across page refreshes etc, you'll need to track persistence somehow - cookies would probably be the way to go.

  9. According to the W3C Spec, the only officially supported elements are a, area, button, input, object, select, and textarea; navigation and form elements.

     

    Unfortunately, support for this attribute on other elements is at the discretion of browser manufacturers.

     

    The more I think about this, why would you want the user to be able to tab to a piece of inanimate text anyway?

×
×
  • Create New...