...

View Full Version : How to get rid of error messages in dropdowns



bufhal
04-10-2004, 12:10 AM
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. :thumbsup:
Thank you
bufhal

bufhal
04-10-2004, 12:12 AM
Sorry, I forgot to add the link to the index.php homepage of the flu webpage.
http://www.immunizewny.org/index.php
Thanks

Nightfire
04-10-2004, 12:56 AM
And your code is...?

bufhal
04-10-2004, 01:06 AM
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.

bufhal
04-10-2004, 01:38 AM
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. :)

raf
04-10-2004, 08:20 AM
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);

bufhal
04-10-2004, 03:35 PM
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

raf
04-11-2004, 11:35 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum