Jump to content

How to add numbers on a checkbox


xxreenaxx1

Recommended Posts

Hey,

 

I have checkbox and with these I am setting an exam. I want the questions to contain numbers. So for each question a number would be displayed. So far I am Only getting the question and the choices to display.

 

 

<html>

<?php
session_start();
include '../Database/connection.php';

$Value22 = mysql_real_escape_string(trim($_POST['myselects'])); 

$_SESSION['myselect23'] = $Value22;

//echo $_SESSION['myselect23'];
?>
<body>
<form action="Staff_Menu.php" method="post">
<?php

include '../Database/previous_q.php';

while($info = mysql_fetch_array( $sql ))
{

echo "{$info['Que_Question']} <br />\n";
echo "<input type=\"checkbox\" name=\"choice1[]\" value=\"{$info['Que_Choice1']}\" /> ";
echo "{$info['Que_Choice1']} <br />\n";
echo "<input type=\"checkbox\" name=\"choice2[]\" value=\"{$info['Que_Choice2']}\" /> ";
echo "{$info['Que_Choice2']} <br />\n";
echo "<input type=\"checkbox\" name=\"choice3[]\" value=\"{$info['Que_Choice3']}\" /> ";
echo "{$info['Que_Choice3']} <br />\n";
echo "<input type=\"checkbox\" name=\"choice4[]\" value=\"{$info['Que_Choice4']}\" /> ";
echo "{$info['Que_Choice4']} <br />\n";


}


?>
<input type="submit" value="submit"/>
</body>

</html>

</body>

</html>

Link to comment
Share on other sites

<html>

<?php
session_start();
include '../Database/connection.php';

$Value22 = mysql_real_escape_string(trim($_POST['myselects'])); 

$_SESSION['myselect23'] = $Value22;

//echo $_SESSION['myselect23'];
?>
<body>
<form action="Staff_Menu.php" method="post">
<?php

include '../Database/previous_q.php';
$intNumber = 1;
while($info = mysql_fetch_array( $sql ))
{

echo "[$intNumber] {$info['Que_Question']} <br />\n";
echo "<input type=\"checkbox\" name=\"choice1[]\" value=\"{$info['Que_Choice1']}\" /> ";
echo "{$info['Que_Choice1']} <br />\n";
echo "<input type=\"checkbox\" name=\"choice2[]\" value=\"{$info['Que_Choice2']}\" /> ";
echo "{$info['Que_Choice2']} <br />\n";
echo "<input type=\"checkbox\" name=\"choice3[]\" value=\"{$info['Que_Choice3']}\" /> ";
echo "{$info['Que_Choice3']} <br />\n";
echo "<input type=\"checkbox\" name=\"choice4[]\" value=\"{$info['Que_Choice4']}\" /> ";
echo "{$info['Que_Choice4']} <br />\n";
$intNumber++;

}


?>
<input type="submit" value="submit"/>
</body>

</html>

</body>

</html>

Link to comment
Share on other sites

Now that I have my choices. How do I display the checked checkbox according to the answer.

My table contains

Question

Choice 1

Choice 2

Choice 3

Choice 4

Answer 1

Answer 2

Answer 3

Answer 4

If Answer 1 was a 0 then the checkbox shouldnt be ticked, and if it was a 1 then the text box should be ticked.

 

I am NOT asking for the code can you just help me out. Direct me in the right direction and Ill get there.

 

Thank you

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.