Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to get rid of error messages in dropdowns

    Hello;
    I have added dropdown menus to a flu clinic clinic schedule website for a user to be able to choose 1) Agency 2) Date 3) City
    I have a data.dat file with test data,a testview.php file and a results.php file. I receive error messages when I use any of the dropdowns. I think I did something wrong numbering the array elements.
    I want each choice a user makes to return the entire delimited record from the data file, but I am not quite sure how to do it and get rid of errors
    Any suggestions are greatly appreciated.
    Thank you
    bufhal

  • #2
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry, I forgot to add the link to the index.php homepage of the flu webpage.
    http://www.immunizewny.org/index.php
    Thanks

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    And your code is...?

  • #4
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for responding, Nightfire.
    I cannot add the zip file to the server. I can either post the code here (it is a bit lengthy) or email it--don't want to break the house rules...
    Let me know.

  • #5
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    response to Nightfire

    Here is test_view.php

    <FORM action=results.php name=form>
    <?
    $content_array = file('data.dat');
    $Total_records = count($content_array);

    For ($RecCount = 0; $RecCount < $Total_records; $RecCount++)
    {
    $elements = explode("<|>", $content_array[$RecCount]);
    $dates[$RecCount]=$elements[6];
    $cities[$RecCount]=$elements[3];
    $agencies[$RecCount]=$elements[5];
    }
    $Udates=array_values(array_unique ($dates));
    $Ucities=array_values(array_unique ($cities));
    $Uagencies=array_values(array_unique ($agencies));
    $Dcount=count($Udates);
    $Ccount=count($Ucities);
    $Zcount=count($Uagencies);

    print '<select name=date onChange="form.submit();">';
    print "<option value=null><i>Select a Date</i></option>";
    for ($i=0; $i<$Ccount; $i++)
    print "<option value=$Udates[$i]>$Udates[$i]</option>";
    print "</select>";

    print '<select name=city onChange="form.submit();">';
    print "<option value=null><i>Select a City</i></option>";
    for ($i=0; $i<$Ccount; $i++)
    { print "<option value=";
    print '"';
    print "$Ucities[$i]";
    print '"';
    print ">$Ucities[$i]</option>";
    }
    print "</select>";

    print '<select name=agency onChange="form.submit();">';
    print "<option value=null selected><i>Select an Agency</i></option>";
    for ($i=0; $i<$Zcount; $i++)
    print "<option value=$Uagencies[$i]>$Uagencies[$i]</option>";
    print "</select></form>";

    print "<BR><BR><BR><table><tr><td colspan=7>There are actually $Total_records Events</td></tr>";
    For ($RecCount = 0; $RecCount < $Total_records; $RecCount++)
    {
    $elements = explode("<|>", $content_array[$RecCount]);
    print "<tr><td>$elements[0]</td><td>$elements[1]</td><td>$elements[2]</td><td>$elements[3]</td><td>$elements[4]</td>
    <td>$elements[5]</td><td>$elements[6]</td><td>$elements[7]</td></tr>";
    }

    ?>
    </table>

    Here is results.php:

    <html>
    <head>
    <title>Results of Search</title>
    </head>
    <body>
    <h1>Search Results</h1>

    <?PHP

    if ($date!=="null")
    Fdate($date);
    if ($city!=="null")
    Fcity($city);
    if ($agency!=="null")
    Fagency($agency);
    if ($viewAll!=="0")
    Fall();


    function Fdate ($date)
    {
    $content_array = file('data.dat');
    $Total_records = count($content_array);

    Print " These are results for <b>$date</b><br><br>";
    For ($RecCount = 0; $RecCount < $Total_records; $RecCount++)
    {
    $elements = explode("<|>", $content_array[$RecCount]);
    if ($elements[6] == $date)
    print "$elements[1]-$elements[2]-$elements[3]<br>";
    }

    }

    function Fagency ($agency)
    {
    $content_array = file('data.dat');
    $Total_records = count($content_array);

    Print " These are results for Agency <b>$agency</b><br><br>";
    For ($RecCount = 0; $RecCount < $Total_records; $RecCount++)
    {
    $elements = explode("<|>", $content_array[$RecCount]);
    if ($elements[5] == $agency)
    print "$elements[1]-$elements[2]-$elements[5]<br>";
    }


    }

    function Fcity ($city)
    {
    $content_array = file('data.dat');
    $Total_records = count($content_array);

    Print " These are results for <b>$city</b><br><br>";
    For ($RecCount = 0; $RecCount < $Total_records; $RecCount++)
    {
    $elements = explode("<|>", $content_array[$RecCount]);
    if ($elements[3] == $city)

    print "<b>$elements[1]</b><br>$elements[2]<br>$elements[3],$elements[4] $elements[5]<br><b>$elements[6] - $elements[7]</b><br><br>";
    }


    }
    function Fall ()
    {
    $content_array = file('data.dat');
    $Total_records = count($content_array);

    Print " These are all the results <br><br>";
    For ($RecCount = 0; $RecCount < $Total_records; $RecCount++)
    {
    $elements = explode("<|>", $content_array[$RecCount]);
    print "$elements[1]-$elements[2]-$elements[3]<br>";
    }
    }

    ?>
    </body>
    </html>

    And the data.dat:

    This is a typical record...

    1<|>14001<|>St. Theresa Avila<|>Akron <|>Parish Hall <|>Catholic Health System<|>08/15/2003<|>8:00AM - 5:00PM<|>542-9109

    These 11 entities below need to be returned (even if there are no entries for some of them like example above...there are only eight above) This needs to happen with every query by the user when they click on one of the options on the index.php homepage for Agency, Date or City.

    City Date Day Time Agencyname Location Building/room Street Zip Phone#
    contact person

    Thank you for any help, Nightfire.

  • #6
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Welcome here!

    To help us help you, please include your code in [ph p] and [/ph p] tags (without the spaces) and indent it --> much easier for us to read + also post the exact errormessages you get and highlight the lines of code they point to.

    looking briefly at your code, i would try changing
    $Udates=array_values(array_unique ($dates));
    into
    $Udates=array_unique ($dates);
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #7
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    offset problem...

    Search Results
    These are results for North Tonawanda


    Notice: Undefined offset: 3 in E:\www\immunizewny_org\results.php on line 60

    Notice: Undefined offset: 3 in E:\www\immunizewny_org\results.php on line 60

    Notice: Undefined offset: 3 in E:\www\immunizewny_org\results.php on line 60

    Notice: Undefined offset: 3 in E:\www\immunizewny_org\results.php on line 60

    Notice: Undefined offset: 3 in E:\www\immunizewny_org\results.php on line 60

    Notice: Undefined offset: 3 in E:\www\immunizewny_org\results.php on line 60
    14225
    Rite Aid
    North Tonawanda,7:00AM - 4:00PM Univera
    08/15/2003 - 544-9103


    Notice: Undefined offset: 3 in E:\www\immunizewny_org\results.php on line 60

    Notice: Undefined offset: 3 in E:\www\immunizewny_org\results.php on line 60

    Notice: Undefined offset: 3 in E:\www\immunizewny_org\results.php on line 60

    Notice: Undefined offset: 3 in E:\www\immunizewny_org\results.php on line 60

    Notice: Undefined offset: 3 in E:\www\immunizewny_org\results.php on line 60

    Notice: Undefined offset: 3 in E:\www\immunizewny_org\results.php on line 60

  • #8
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    these are notices an not erromessages. 2 fixes : change the errolevel reporting (run a search here --> been at least 2 recent threads about erroreporting) or define all variables before assigning values to them.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


  •  

    Posting Permissions

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