Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 08-17-2006, 02:23 AM   #1 (permalink)
 
True Techie

Join Date: May 2006

Posts: 128

WHWebSolutions

Send a message via ICQ to WHWebSolutions Send a message via AIM to WHWebSolutions Send a message via Yahoo to WHWebSolutions
Exclamation PHP code help

Hello all well I had a friend make some code for me and it works just like I want it to but I have 1 problem. The page looks just how I want it to in IE (questions are above and below each other) but in Firefox the questions are side by side. Can someone help me out? Below is the code. Please help me.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Version 2</title>
</head>
<body>

<form action="test.php" method="post">

<?php 
	$questionCounter = 0;
	$resultCounter = 0;
	testFor('Question 1?','1',$questionCounter,$resultCounter);
	testFor('Question 2?','2',$questionCounter,$resultCounter);
	testFor('Question 3?','3',$questionCounter,$resultCounter);
	testFor('Question 4?','4',$questionCounter,$resultCounter);
	getResult('Your cat is','mau',$questionCounter,$resultCounter);
?>

<input type="submit" value="Test">

</form>

</body>
</html>

<?php
 function testFor($question,$key,&$qc,&$rc) {
	 if (isset($_POST[$key])) {
		 $qc++;
		 $i=(int)$_POST[$key];
		 if ($i < 0) {$i=0;};
		 if ($i > 100) {$i=100;};
		 $rc=$rc+$i;
	 }
	 else {
		 createList($question,$key);
	 }

 }

 function createList($text,$name) {
	 echo htmlentities($text) . '' .
	 	'<select name="' . $name . '" size="1">' .
		//Yes, A little bit, Rather not, No, Not at all 
	 	'<option value="100">Yes</option>' .
	 	'<option value="80">A little bit</option>' .
	 	'<option value="50" selected="selected">Rather not</option>' .
		'<option value="20"> No</option>' .
	 	'<option value="0">Not at all</option>' .
		'</select></br>' . "\n";
 }

 function getResult($text,$property,$qc,$rc) {
	 if ($qc>0) {
		 $i=$rc/$qc;
		 echo htmlentities($text) . ' ' . $i . '% ' . htmlentities($property) . ' and ' . (100-(double)$i) . '% not ' .
		 htmlentities($property) . '.</br>' . "\n";
	 }
 }
?>

WHWebSolutions is offline  
Old 08-18-2006, 02:36 AM   #2 (permalink)
 
Monster Techie

Join Date: Apr 2005

Posts: 1,909

jcortes is on a distinguished road

Send a message via AIM to jcortes
Default

try inserting a break after each question echoed

__________________

AIM = jcortestechhelp
jcortes is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On