SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 26
  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    simple drop down link

    Hi
    iam trying to get all users with a photo album to appear in a drop down list.

    here is the code

    PHP Code:
    $rime4 mysql_query("SELECT * from users   "
    or die(
    mysql_error());

    while(
    $row mysql_fetch_array($rime4)) {
    extract($row);
    $username $row["username"];
    $userid $row["userid"];


    echo 
    "<option  value='$userid'>  $username </option>"
    Iget the list of users but need to add the link below
    how do i add this link to the username this is the link http://www.$sitePath/index.php?username=$username

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code html4strict:
    <select name="username" onchange="location.href='http://www.$sitePath/index.php?username='+escape(this.options[this.selectedIndex].text)">
    Saul

  3. #3
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    no that didnt seem to work either
    thanks paul

  4. #4
    Non-Member
    Join Date
    Apr 2009
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not make another variable or do = '<a>' + $username + '</a>'; ?
    Sorry, I am bad at PHP and this is how I would have attempted it

  5. #5
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Frankly, I don't know what is it that you want to do exactly. I assumed you want to go to a certain link when user selects an oprion from the dropdown. Is that not the case?
    Saul

  6. #6
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    when a user clicks on a username it takes them to there photo album a link,

  7. #7
    Non-Member
    Join Date
    Apr 2009
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I am correct then you wanted my option?

  8. #8
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You can also try:
    PHP Code:
    echo "<option  value='$userid' onclick=\"location.href='http://www.$sitePath/index.php?username=$username'\">$username</option>"
    Saul

  9. #9
    Non-Member
    Join Date
    Apr 2009
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But wouldn't that be dependent on JavaScript?

  10. #10
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No way to do that with a dropdown box otherwise. Without JS a list of simple hyperlinks is the only way.
    Saul

  11. #11
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    just tried this
    echo "<option value='$userid' onclick=\"location.href='http://www.$sitePath/index.php?username=$username'\">$username</option>";
    but the link still didnt work

  12. #12
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No way, what's going on? Do you have it online?
    Saul

  13. #13
    Non-Member
    Join Date
    Apr 2009
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you click it? I tested it on my server with false values of course, and I got it working. There is no logical reason why that would not work

  14. #14
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    Iv tried everything but no joy, the link doesnt work no link at all

  15. #15
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    What do you mean by that? Do you expect to see a blue underlined text? That's not how it works.

    It's not a link per se, it's impossible to add links to dropdown box. Instead it mimics the behaviour in JS, by redirecting browser to the page when the user clicks on an option from the list.

    If you want it to appear like 'standard' hyperlinks, style them in CSS.
    Saul

  16. #16
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No i dont expect to see blue line with text, when a user clicks on the drop down list he sees a list of users they should be able to clck on the user which then takes them to there photo album page.

  17. #17
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Which is how it should work, and I've tested it...

    If you don't have it online (PM me the link if you don't want it be known in public), can you post the select box as it is output by the script in html?
    Saul

  18. #18
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the full code

    PHP Code:
    $rime4 mysql_query("SELECT * from users   "
    or die(
    mysql_error());

    while(
    $row mysql_fetch_array($rime4)) {
    extract($row);
    $username $row["username"];
    $userid $row["userid"];
    $description $row["description"];
    echo 
    "<select name='username' id='username'>
                        <option value= selected>Member Albums</option>
    <option  value='
    $userid' onclick=\"location.href='http://www.$sitePath/index.php?username=$username'\">$username</option>";} ?> 

  19. #19
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Other that it shold be:
    PHP Code:
    $rime4 mysql_query("SELECT * from users   "
    or die(
    mysql_error()); 

    echo 
    "<select name='username' id='username'> 
                        <option value= selected>Member Albums</option> "
    ;

    while(
    $row mysql_fetch_array($rime4)) { 
    extract($row); 
    $username $row["username"]; 
    $userid $row["userid"]; 
    $description $row["description"]; 
    echo 
    "<option  value='$userid' onclick=\"location.href='http://www.$sitePath/index.php?username=$username'\">$username</option>";
    ?> 
    If $sitePath is correct, I don't see anything that wouldn't work.

    Any JS errors?

    And I would really rather see the html output to see what exactly is going on.
    Saul

  20. #20
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here is the link to the site
    http://www.easynet4u.com/photoalbum/...username=westy

    the drop down list is on the side named Member albums

  21. #21
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Bingo!

    I won't steal the glory from PHP_Deamon though.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  22. #22
    Non-Member
    Join Date
    Apr 2009
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I will

    You have this link when you click the drop down

    http://www.http//www.easynet4u.com/i...username=westy

    Notice you have two http://www.'s in there?

  23. #23
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code html4strict:
    <option  value='1' onclick="location.href='http://www.http://www.easynet4u.com/imagehost/index.php?username=westy'">westy</option>

    Evidently your $sitePath has the full url and http://www. is redundant...

    PHP Code:
    echo "<option  value='$userid' onclick=\"location.href='$sitePath/index.php?username=$username'\">$username</option>"
    Edit:


    I will

    Saul

  24. #24
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    thats wierd i dont get any link just the username nothing else.

  25. #25
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Are we on the same page then? Perhaps you have it cached in the browser?
    Saul


Bookmarks

Posting Permissions

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