www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: multiple select box values

  1. #1
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,901

    multiple select box values

    I have a multiple select box with contact names and phone numbers. When you select a name that has "Investors" in front of it, I want it to display all the Names and phone numbers, but only show the word Investors once. For example, I want it to look like this:

    Invesors: Name Phone Number, Name2, Phone Number 2

    Here is the code I am using to seperate the value by a comma:

    <? foreach($contacts as $value) {
    list ($id, $info) = split (",", $value);
    echo "<input type=hidden name=contacts[] value=$id,$info>\n";
    }?>

    Then here is the code I am using to display the data:

    <?
    echo "Contacts:";
    foreach($contacts as $value) {
    list ($id, $info) = split (",", $value);
    $info = str_replace("~", "&nbsp;", $info);
    $inv = substr("$info", 0, 9);
    //while ($inv == "Investors") {
    // echo "<p>" . $info . ",&nbsp;";
    //}
    if ($inv == "Investors") {
    echo "<p>" . $info . "&nbsp;or <a href=mailto:investor@riteaid.com>investor@riteaid.com</a></p>";
    } else {
    echo "<p>" . $info . "</p>";
    }
    }
    ?>

    But this gives me the following result:

    Investors: Name Phone Number
    Investors: Name2 Phone Number

    Any help would be greatly appreciated

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    What does $contacts look like? If it is the contents of a file, post what the file looks like.

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  3. #3
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,901
    $contacts is an array that looks like this:

    Contacts:Array ( [0] => 1,Investors:~Jason~Roscoe~717-761-2633 [1] => 5,Investors:~Doug~Silvis~717-761-2633 [2] => 2,Media:~Jason~Kasper~717-761-2633 )

  4. #4
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Not the cleanest, but I would read/write the file differently, which would mean we could do this differently... Anyway, with what you've got:

    PHP Code:
    <?PHP

    $x 
    0;

    echo 
    "Contacts:"
    foreach(
    $contacts as $value) { 
        list (
    $id$info) = split (","$value); 
        
    $info str_replace("~"" "$info); 
        
    $invinfo substr($info11, -1);
        
    $inv substr("$info"09); 
        if (
    $inv == "Investors") {
            if (
    $x == 0) { 
                echo 
    "<p>Investors: " $invinfo " or <a href=mailto:investor@riteaid.com>investor@riteaid.com</a></p>"
                
    $x 1;
            }
            else {
                echo 
    "<p>" $invinfo " or <a href=mailto:investor@riteaid.com>investor@riteaid.com</a></p>"
            }
        } 
        else { 
            echo 
    "<p>" $info "</p>"
        } 


    ?>

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  5. #5
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,901
    Ok, we're close. This is what the page looks like now:

    Investors: Jason Roscoe 777-777-263 or investor@riteaid.com

    Doug Silvis 777-777-263 or investor@riteaid.com

    Media: Jason Kasper 777-777-2633

    But what I want it to look like is:

    Investors: Jason Roscoe 777-777-2633, Doug Silvis 777-777-2633 or investor@riteaid.com

    Media: Jason Kasper 777-777-2633

    Also, it is cutting off the last number in the phone number??

    P.S. - I got the phone number to show all numbers by doing this:

    $invinfo = substr($info, 11);
    Last edited by jrthor2; 06-10-2003 at 11:21 AM.

  6. #6
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    PHP Code:
    if ($inv == "Investors") {
        if (
    $x == 0) { 
            echo 
    "<p>Investors: " $invinfo " or <a href=mailto:investor@riteaid.com>investor@riteaid.com</a>,"
            
    $x 1;
        }
        else {
            echo 
    " " $invinfo " or <a href=mailto:investor@riteaid.com>investor@riteaid.com</a>,"
        }

    else { 

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  7. #7
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,901
    Ok, now I have this:

    Investors: Jason Roscoe 777-777-2633 or investor@riteaid.com, Doug Silvis 777-777-2633 or investor@riteaid.com,

    But, I want the "or investor@riteaid.com" to only show up at the end of that line like this:

    Investors: Jason Roscoe 777-777-2633, Doug Silvis 777-777-2633 or investor@riteaid.com,

    Thanks

  8. #8
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Is it possible for you to re-work the way the file looks? (I'm assumbing this data is being pulled from a file) It would be much easier if you were able to split it up differently....

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  9. #9
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,901
    Yes, it is possible. the select box is being pulled from a database. The info I am showing is just being passed from the form to this page. I will try anything right now.

    Thanks

  10. #10
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Actually... let's go the easy way, and just keep what you've already got. Try this:

    PHP Code:
    <?PHP

    $invvals 
    "";
    $infovals "";
    $contacts file("array.txt");

    echo 
    "Contacts:"
    foreach(
    $contacts as $value) { 
        list (
    $id$info) = split (","$value); 
        
    $info str_replace("~"" "$info); 
        
    $invinfo substr($info11, -1);
        
    $inv substr("$info"09); 
        if (
    $inv == "Investors") {
            
    $invvals .= $invinfo." "
        } 
        else { 
            
    $infovals .= $info
        } 


    echo 
    "<p>Investors: $invvals <a href=mailto:investor@riteaid.com>investor@riteaid.com</a></p>";
    echo 
    "<p>$infovals <a href=mailto:investor@riteaid.com>investor@riteaid.com</a></p>";

    ?>

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  11. #11
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,901
    Actuall, I had to modify it a little, but it looks to be working. here is what I used:

    <?PHP

    $invvals = "";
    $infovals = "";

    echo "Contacts:";
    foreach($contacts as $value) {
    list ($id, $info) = split (",", $value);
    $info = str_replace("~", " ", $info);
    $invinfo = substr($info, 11);
    $inv = substr("$info", 0, 9);
    if ($inv == "Investors") {
    $invvals .= $invinfo.", ";
    }
    else {
    $infovals .= $info;
    }
    }

    echo "<p>Investors: $invvals or <a href=mailto:investor@riteaid.com>investor@riteaid.com</a></p>";
    echo "<p>$infovals </p>";

    ?>

    Although, is it possible to not show the comma after the last person listed as an investor??

  12. #12
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Add this right after your foreach loop (before the echo's):

    PHP Code:
    $invvals substr($invvals0, -2); 

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  13. #13
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,901
    YEEEEEEEHAWWWW, it's finally working the way I need it to. Thanks so much. Now I have another issue. After putting this info away into a database, I need to retrieve it and display it the same way. Here is my code now, but it lists the investors in a new row:

    <?
    $sql="SELECT EVT.ITEM_NBR, EVT.TITLE_TXT,
    EVT.BODY_TXT, REF.ID, INF.FIRST_NME, INF.LAST_NME, INF.PHONE_NBR,
    INF.DEPARTMENT
    FROM SYSADM.INDYH_DYNCONTENT_HTML EVT,
    SYSADM.INCOR_CONTACT_REF REF,
    SYSADM.INCOI_CONTACT_INFO INF
    WHERE EVT.ITEM_NBR = $item_nbr
    AND EVT.ITEM_NBR = REF.ITEM_NBR
    AND REF.ID = INF.ID
    ORDER BY DEPARTMENT, INF.LAST_NME";
    $D->my_sel($sql);
    //print $sql;

    if ($D->numrows > 0) {
    echo "<p>Contacts:</p>";

    for($i=0; $i< $D->numrows; $i++) {
    $first_nme=$D->results["FIRST_NME"][$i];
    $last_nme=$D->results["LAST_NME"][$i];
    $phone_nbr=$D->results["PHONE_NBR"][$i];
    $department=$D->results["DEPARTMENT"][$i];
    if ($department == "Investors") {
    if ($first_nme == "0") {
    $contact_info = "<p>" . $department . ":&nbsp;" . $phone_nbr . "&nbsp;or <a href=mailto:investor@riteaid.com>investor@riteaid.com</a></p>";
    } else {
    $contact_info = "<p>" . $department . ":&nbsp;" . $first_nme . "&nbsp;" . $last_nme . "&nbsp;" . $phone_nbr . "&nbsp;or <a href=mailto:investor@riteaid.com>investor@riteaid.com</a></p>";
    }
    } else {
    $contact_info = "<p>" . $department . ":&nbsp;" . $first_nme . "&nbsp;" . $last_nme . "&nbsp;" . $phone_nbr;
    }
    }
    ?>

    Thanks for all your help!!!

  14. #14
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,901
    Can anyone please help?

  15. #15
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Could you explain your problem/question better?

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.32055 seconds
  • Memory Usage 3,037KB
  • Queries Executed 13 (?)
More Information
Template Usage (36):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (15)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (15)postbit
  • (15)postbit_onlinestatus
  • (15)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates