jshaw3
02-21-2008, 11:04 PM
Hi,
I am having problems working with forms and drop down menus being submitted between IE and Firefox.
I am working on dynamic graphs allowing the user to select the number of bars displayed in the graph. All of the information is being stored in a MYSQL database. The graphs are being created with the GD Library. The users select the location (this works) than selects the number of bars to be displayed. ex. 7 bars. I am using GET for the form and passing the variable to the same page. When the form is submitted the graph is drawn and saved to the server. When the form is submitted the page relodes and the newest graph is displayed on the page. This works fine in FF but in IE what i suspect is happining is the browser is not reconixing the passed variable and is not drawing and saving the new graph. I suspect this because in IE when i submit the form it doesn't work, however if i refresh the newly reloaded page the proper graph shows.
Is there a reason why in firefox the variable is awknowledged and creates than displayes the proper graph automatically but not in IE? Is there a way to solve the issue with IE? The code is below.
I know there are still a lot of other bugs but this is my main concern at the moment.
if (!isset($_REQUEST['display'])){
$display = 5;
}elseif(isset($_REQUEST['display'])){
$display = $_REQUEST['display'];
}
$now = time();
date_default_timezone_set('EST5EDT');
$date = strftime('%H_%M_%S_%b%d%y',$now);
if(isset($_COOKIE['city']) && isset($_COOKIE['country'])){
$localCity = $_COOKIE['city'];
$localCountry = $_COOKIE['country'];
}
$loc = $_REQUEST['loc'];
echo $loc;
$allCities = @mysql_query("SELECT DISTINCT city FROM webEmotion GROUP BY city ORDER BY `city` DESC");
$numCities=mysql_numrows($allCities);
if ((!isset($_REQUEST['loc'])) || ($loc ==glob)) {
$totalEmo = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion GROUP BY emotion ORDER BY `num_times` DESC");
$totalNum=mysql_numrows($totalEmo);
$emotionOrdered = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion GROUP BY emotion ORDER BY `num_times` DESC LIMIT 0, $display");
$num=mysql_numrows($emotionOrdered);
}
elseif ($loc == $localCity) {
$totalEmo = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$localCity' GROUP BY emotion ORDER BY `num_times` DESC");
$totalNum=mysql_numrows($totalEmo);
$emotionOrdered = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$localCity' GROUP BY emotion ORDER BY `num_times` DESC LIMIT 0, $display");
$num=mysql_numrows($emotionOrdered);
} else{
$totalEmo = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$loc' GROUP BY emotion ORDER BY `num_times` DESC");
$totalNum=mysql_numrows($totalEmo);
if($display<=$totalNum){
$emotionOrdered = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$loc' GROUP BY emotion ORDER BY `num_times` DESC LIMIT 0, $display");
$num=mysql_numrows($emotionOrdered);
}else{
$emotionOrdered = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$loc' GROUP BY emotion ORDER BY `num_times` DESC LIMIT 0, $totalNum");
$num=mysql_numrows($emotionOrdered);
}
}
echo "<br /> $display <br />";
$i=0;
while($i<$display){
$emotion_[$i] = mysql_result($emotionOrdered, $i, 'emotion');
$num_test_[$i] = mysql_result($emotionOrdered, $i, 'num_times');
$num_test_[$i] = 500-(($num_test_[$i]/$totalNum)*500);
$i++;
}
$image = ImageCreate(500, 500);
$background_color = ImageColorAllocate($image, 255, 255, 255); //white
$pink = ImageColorAllocate($image, 255, 51, 204); //pink
// blue text
$textcolor = imagecolorallocate($image, 0, 0, 0);
$j = 0;
$barSpace = 10;
while ($j<$display){
$barWidth = (500-($display*10))/$display;
ImageFilledRectangle($image, $barSpace, $num_test_[$j], $barSpace+$barWidth, 500, $pink);
imagestring($image, 5, $barSpace, 480, $emotion_[$j], $textcolor);
$barSpace += ($barWidth+10);
$j++;
}
$url_1 = "image/$loc_$date.png";
$url_2 = "image/image_Graph.png";
ImagePNG($image, $url_1);
ImagePNG($image, $url_2);
?>
<form id="****" name="****" method="get" action="draw.php">
<label>location
<select name="loc" id="loc">
<option value="<? echo $loc; ?>"><? echo $loc; ?></option>
<option value="<? echo $localCity; ?>"><? echo $localCity; ?></option>
<option value="glob">Global</option>
<?
$c=1;
while ($c < $numCities) {
$listCities=mysql_result($allCities,$c,'city');
echo "$emoD: $num_times<br>";
?>
<option value="<? echo $listCities;?>"><? echo $listCities;?></option>
<?
$c++;
}
?>
</select>
</label>
<label>display
<select name="display" id="display">
<?
$d=0;
while ($d < $totalNum) {
$listCities=mysql_result($totalEmo,$d,'city');
?>
<option value="<? echo $d;?>"><? echo $d;?></option>
<?
$d++;
}
?>
</select>
</label>
<input type="submit" id="submit" value="Submit" />
</form>
<img src="image/image_Graph.png" />
Thank you in advanced for the help.
I am having problems working with forms and drop down menus being submitted between IE and Firefox.
I am working on dynamic graphs allowing the user to select the number of bars displayed in the graph. All of the information is being stored in a MYSQL database. The graphs are being created with the GD Library. The users select the location (this works) than selects the number of bars to be displayed. ex. 7 bars. I am using GET for the form and passing the variable to the same page. When the form is submitted the graph is drawn and saved to the server. When the form is submitted the page relodes and the newest graph is displayed on the page. This works fine in FF but in IE what i suspect is happining is the browser is not reconixing the passed variable and is not drawing and saving the new graph. I suspect this because in IE when i submit the form it doesn't work, however if i refresh the newly reloaded page the proper graph shows.
Is there a reason why in firefox the variable is awknowledged and creates than displayes the proper graph automatically but not in IE? Is there a way to solve the issue with IE? The code is below.
I know there are still a lot of other bugs but this is my main concern at the moment.
if (!isset($_REQUEST['display'])){
$display = 5;
}elseif(isset($_REQUEST['display'])){
$display = $_REQUEST['display'];
}
$now = time();
date_default_timezone_set('EST5EDT');
$date = strftime('%H_%M_%S_%b%d%y',$now);
if(isset($_COOKIE['city']) && isset($_COOKIE['country'])){
$localCity = $_COOKIE['city'];
$localCountry = $_COOKIE['country'];
}
$loc = $_REQUEST['loc'];
echo $loc;
$allCities = @mysql_query("SELECT DISTINCT city FROM webEmotion GROUP BY city ORDER BY `city` DESC");
$numCities=mysql_numrows($allCities);
if ((!isset($_REQUEST['loc'])) || ($loc ==glob)) {
$totalEmo = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion GROUP BY emotion ORDER BY `num_times` DESC");
$totalNum=mysql_numrows($totalEmo);
$emotionOrdered = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion GROUP BY emotion ORDER BY `num_times` DESC LIMIT 0, $display");
$num=mysql_numrows($emotionOrdered);
}
elseif ($loc == $localCity) {
$totalEmo = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$localCity' GROUP BY emotion ORDER BY `num_times` DESC");
$totalNum=mysql_numrows($totalEmo);
$emotionOrdered = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$localCity' GROUP BY emotion ORDER BY `num_times` DESC LIMIT 0, $display");
$num=mysql_numrows($emotionOrdered);
} else{
$totalEmo = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$loc' GROUP BY emotion ORDER BY `num_times` DESC");
$totalNum=mysql_numrows($totalEmo);
if($display<=$totalNum){
$emotionOrdered = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$loc' GROUP BY emotion ORDER BY `num_times` DESC LIMIT 0, $display");
$num=mysql_numrows($emotionOrdered);
}else{
$emotionOrdered = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$loc' GROUP BY emotion ORDER BY `num_times` DESC LIMIT 0, $totalNum");
$num=mysql_numrows($emotionOrdered);
}
}
echo "<br /> $display <br />";
$i=0;
while($i<$display){
$emotion_[$i] = mysql_result($emotionOrdered, $i, 'emotion');
$num_test_[$i] = mysql_result($emotionOrdered, $i, 'num_times');
$num_test_[$i] = 500-(($num_test_[$i]/$totalNum)*500);
$i++;
}
$image = ImageCreate(500, 500);
$background_color = ImageColorAllocate($image, 255, 255, 255); //white
$pink = ImageColorAllocate($image, 255, 51, 204); //pink
// blue text
$textcolor = imagecolorallocate($image, 0, 0, 0);
$j = 0;
$barSpace = 10;
while ($j<$display){
$barWidth = (500-($display*10))/$display;
ImageFilledRectangle($image, $barSpace, $num_test_[$j], $barSpace+$barWidth, 500, $pink);
imagestring($image, 5, $barSpace, 480, $emotion_[$j], $textcolor);
$barSpace += ($barWidth+10);
$j++;
}
$url_1 = "image/$loc_$date.png";
$url_2 = "image/image_Graph.png";
ImagePNG($image, $url_1);
ImagePNG($image, $url_2);
?>
<form id="****" name="****" method="get" action="draw.php">
<label>location
<select name="loc" id="loc">
<option value="<? echo $loc; ?>"><? echo $loc; ?></option>
<option value="<? echo $localCity; ?>"><? echo $localCity; ?></option>
<option value="glob">Global</option>
<?
$c=1;
while ($c < $numCities) {
$listCities=mysql_result($allCities,$c,'city');
echo "$emoD: $num_times<br>";
?>
<option value="<? echo $listCities;?>"><? echo $listCities;?></option>
<?
$c++;
}
?>
</select>
</label>
<label>display
<select name="display" id="display">
<?
$d=0;
while ($d < $totalNum) {
$listCities=mysql_result($totalEmo,$d,'city');
?>
<option value="<? echo $d;?>"><? echo $d;?></option>
<?
$d++;
}
?>
</select>
</label>
<input type="submit" id="submit" value="Submit" />
</form>
<img src="image/image_Graph.png" />
Thank you in advanced for the help.