
xxreenaxx1
Members-
Posts
167 -
Joined
-
Last visited
Never
Everything posted by xxreenaxx1
-
How do I post the values that are in a while loop and add them to mysql table? <form action="Test_Completed.php" method="post"> include '../Database/take_an_exam.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>
-
Hey I have checkbox and when the user tick one or more box these should be stored as 0 or 1 but since its while loop, I am not sure how to work that out. So far I have <html> <?php session_start(); include '../Database/connection.php'; $Value24 = mysql_real_escape_string(trim($_POST['myselect'])); $_SESSION['smodule'] = $Value24; ?> <body> <form action="Test_Completed.php" method="post"> <?php $query = mysql_query(" SELECT * FROM Test WHERE Tes_ID = '{$_SESSION['smodule']}' "); while( $query1 = mysql_fetch_array($query) ) { echo "Test Name: {$query1['Tes_Name']}"; } ?> <br> <?php $query = mysql_query(" SELECT * FROM User WHERE Use_ID = '{$_SESSION['ssubject']}' "); while( $query1 = mysql_fetch_array($query) ) { echo "User Name: {$query1['Use_Name']}"; } ?> <br> <?PHP include '../Database/take_an_exam.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> <?PHP $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("Examination", $con); //Get & clean value from POST data $choice1 = mysql_real_escape_string(trim($_POST['choice1'])); $choice2 = mysql_real_escape_string(trim($_POST['choice2'])); $choice3 = mysql_real_escape_string(trim($_POST['choice3'])); $choice4 = mysql_real_escape_string(trim($_POST['choice4'])); $user = mysql_real_escape_string(trim($_SESSION['username1'])); //Create and run INSERT query $query = "INSERT INTO Answer (`Ans_Answer1`, `Ans_Answer2`, `Ans_Answer3`, `Ans_Answer4`, `Que_ID`, `Use_ID`) VALUES ('{$choice1}', '{$choice2}', '{$choice3}', '{$choice4}', '{$query1}', '{$user}')"; $result = mysql_query($query) or die (mysql_error()); $_SESSION['Ans_ID'] = mysql_insert_id(); header("location:check.php"); ?>
-
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
-
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>
-
I have created a query in order for sub_name to be displayed but I need to show all the field and DISTINCT only Sub_Name field. Is that possible? If Yes, How? $query=("SELECT DISTINCT * FROM User u, Subject s, Test t WHERE u.Use_ID = 3 AND s.Sub_ID=t.Sub_ID
-
Get Values for the subject that has been selected
xxreenaxx1 replied to xxreenaxx1's topic in PHP Coding Help
My Subject ID wont show These are my code. <Html> <?php session_start(); include '../Database/connection.php'; ?> <body> <form action="Previousq_Module1.php" method="post"> <?PHP include '../Database/subject_exsitsql.php'; $result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() ); echo '<select name="mselect">'; while( $row=mysql_fetch_assoc($result) ) { echo "<option value=\"{$row['Sub_ID']}\">{$row['Sub_Name']}</option>"; } echo "</select>"; ?> <input type="submit" value="submit"/> </form> </body> </html> This is to get the subject The query for this is <?PHP $query=("SELECT Sub_Name FROM User u, Subject s, Test t WHERE u.Use_ID = '{$_SESSION['ID']}' AND s.Sub_ID=t.Sub_ID AND t.Sub_ID= t.Tes_ID "); ?> This form then send to the one shown below <html> <body> <?php session_start(); include '../Database/connection.php'; $Value1 = mysql_real_escape_string(trim($_POST['mselect'])); $_SESSION['mselect'] = $Value1; echo $Value1; ?> <form action="Previousq_Module2.php" method="post"> <?PHP include '../Database/Module_Exsit.php'; $result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() ); echo "<select name=select>"; while($row=mysql_fetch_array($result)){ echo "<OPTION VALUE=".$row['Tes_ID'].">".$row['Tes_Name']."</OPTION>"; } echo "</select>"; ?> <input type="submit" value="submit"/> </form> This drop down box shows me nothing. the query for this is <?PHP $query="(SELECT Tes_Name FROM User u, Subject s, Test t WHERE u.Use_ID = '{$_SESSION['ID']}' AND s.Sub_ID = '{$_SESSION['mselect']}' AND s.Sub_ID = t.Sub_ID ) "; echo $query; $query1 = mysql_query($query); ?> Now where is the fault. I seriously cant fix this. I dont know whats wrong with this. help me out The echo gives me (SELECT Tes_Name FROM User u, Subject s, Test t WHERE u.Use_ID = '3' AND s.Sub_ID = '' AND s.Sub_ID = t.Sub_ID ) -
Get Values for the subject that has been selected
xxreenaxx1 replied to xxreenaxx1's topic in PHP Coding Help
Subject Id is NOT showing. So I am assuming something wrong with my subject drop box <Html> <?php session_start(); include '../Database/connection.php'; ?> <body> <form action="Previousq_Module1.php" method="post"> <?PHP include '../Database/subject_exsitsql.php'; $result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() ); echo "<select name=myselect>"; while($row=mysql_fetch_array($result)){ echo "<OPTION VALUE=".$row['Sub_ID'].">".$row['Sub_Name']."</OPTION>"; } echo "</select>"; ?> This is used as session on the next page which I HAVE ALREADY SHOWN ON MY FIRST POST. -
Get Values for the subject that has been selected
xxreenaxx1 replied to xxreenaxx1's topic in PHP Coding Help
Yeh when I echo the session, it says Array and when i tried to run the query in mysql it worked. I tired to work with the session that was collected from myselect but it gives me nothing. $query=("SELECT Tes_Name FROM User u, Subject s, Test t WHERE u.Use_ID = '{$_SESSION['ID']}' AND t.Sub_ID = '{$_SESSION['myselect']}' AND t.Sub_ID = s.Sub_ID "); -
Get Values for the subject that has been selected
xxreenaxx1 replied to xxreenaxx1's topic in PHP Coding Help
I need to compare with the subjejct chosen. For now its showing all the module that the staff provides ,since I am using $_SESSION['ID'] to get the staff details. Now I want to use $_SESSION['myselect'] to get the subject which has been submited through the drop box. But when I try to do this, it shows me nothing.. -
I have created a query to show the subject name as a drop down box now I would like to you use value to compare what module available in the database. For now I can disaplyed all the module that is avilable for all the subject. But i would like to use the drop down box to gather which subject they have chosend then use this information to gather the module $query=("SELECT Tes_Name FROM User u, Subject s, Test t WHERE u.Use_ID = '{$_SESSION['ID']}' AND s.Sub_ID=t.Sub_ID "); <Html> <?php session_start(); $Value1 = mysql_real_escape_string(trim($_POST['myselect'])); $_SESSION['myselect'] = $Value1; //echo $Value1; include '../Database/connection.php'; ?> <body> <form action="Previousq_Module2.php" method="post"> <?PHP include '../Database/Module_Exsit.php'; $result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() ); echo "<select name=select>"; while($row=mysql_fetch_array($result)){ echo "<OPTION VALUE=".$row['Tes_ID'].">".$row['Tes_Name']."</OPTION>"; } echo "</select>"; ?> <input type="submit" value="submit"/> </form> </body> </html>
-
I am using sprintf( mysql_insert_id()); to print primary key but I can save this in a varible and echo this. But I would like to know how to save this in to a session and use this one another page.
-
Howwould you do that with a printf? I dont know how so help me out please
-
Yes. That works but can I use this printf to save it in a session and use it on a different page.
-
I have a form that ask user to enter other details but the primary key as this is automated and when they click on Submit button it takes the user to different form. now on this form I would like to retreive the primary that has just been added to the table. How can I do this?
-
Yeh sort of. I need to insert Use_ID from a session as well. and then enter other details from a new form. But I want to be able to add all these to one table. <table border="0"> <form method="POST" action="try2.php"> <tr><td>Tes_Name</td><td>:</td><td><input type="text" name="Tes_Name" size="20"></td></tr> <tr><td>Tes_Description</td><td>:</td><td><input type="text" name="Tes_Description" size="20"></td></tr> <tr><td> </td><td> </td><td><input type="submit" value="Submit"></td></tr> </form> </table>
-
I dont want you to write the program. I just want help... direct me to correct tutorial or what ever.. And I will do it.. I dont know how to post that dropbox and use the subject which is being chosen to be compared with Subject ID and insert that into a different table.
-
Hey I created a drop box and got a form for that. Now when I click on submit I want the data to be compaired with the data inside the mysql. For example: Subject name = Subject id the drop down list contains subject names. And this should be compaired with the subject id and store the id into a new table called test. <Html> <?php session_start(); include '../Database/connection.php'; ?> <body> <form action="try1.php" method="post"> <?PHP include '../Database/subject_sql.php'; $result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() ); echo "<select name=myselect>"; while($row=mysql_fetch_array($result)){ echo "<OPTION VALUE=".$row['Sub_ID'].">".$row['Sub_Name']."</OPTION>"; } echo "</select>"; ?> <input type="submit" value="submit"/> </form> </body> </html>
-
Hey guy <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("Examination", $con); $sql="INSERT INTO Test (Tes_Name, Tes_Description) VALUES ('$_POST[Tes_Name]','$_POST[Tes_Description]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> This is my code and I can enter Tes_Name on to mysql but nothing is shown for Tes_Description. The form is <html> <body> <h3>Test</h3> <table border="0"> <form method="POST" action="try2.php"> <tr><td>Tes_Name</td><td>:</td><td><input type="text" name="Tes_Name" size="20"></td></tr> <tr><td>Tes_Description</td><td>:</td><td><input type="Tes_Description" name="password" size="20"></td></tr> <tr><td> </td><td> </td><td><input type="submit" value="Submit"></td></tr> </form> </table> </body> </html>
-
I am getting an error message. But the program works Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\Exam_Online\try.php:3) in C:\xampp\htdocs\Exam_Online\Staff_login_process.php on line 4 Wrong Username or Password my code is <Html> <?php //session_start(); include 'Staff_login_process.php'; MYSQL_CONNECT(localhost,'root','') OR DIE("Unable to connect to database"); @mysql_select_db(Examination) or die( "Unable to select database"); ?> <body> <form action="try1.php" method="post"> <?PHP $query=("SELECT * FROM User u, User_X_Subject us, Subject s WHERE u.Use_Name = '{$_SESSION['username']}' AND u.Use_ID= us.Use_ID AND s.Sub_ID=us.Sub_ID"); $result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() ); echo "<select name=myselect>"; while($row=mysql_fetch_array($result)){ echo "<OPTION VALUE=".$row['Sub_ID'].">".$row['Sub_Name']."</OPTION>"; } echo "</select>"; ?> <input type="submit" value="submit"/> </form> </body> </html>
-
Can you use session to retrieve mysql data
xxreenaxx1 replied to xxreenaxx1's topic in PHP Coding Help
my query is sort of messed up. But when I try it on mysql it works. Not sure how to implement that on to PHP. so far I have <Html> <?php MYSQL_CONNECT(localhost,'root','') OR DIE("Unable to connect to database"); @mysql_select_db(Examination) or die( "Unable to select database"); ?> <form action="try1.php" method="post"> <? //$query=("SELECT * FROM subject"); $query=("SELECT DISTINCT * FROM User u, User_X_Subject us, Subject s WHERE u.Use_Name = '{$_SESSION['username']}' AND u.Use_ID= us.Use_ID AND s.Sub_ID=us.Sub_ID"); $result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() ); echo "<select name=myselect>"; while($row=mysql_fetch_array($result)){ echo "<OPTION VALUE=".$row['s.Sub_ID'].">".$row['s.Sub_Name']."</OPTION>"; } echo "</select>"; ?> <input type="submit" value="submit"/> </form> </html> but ofcourse its NOT going to work and its NOT working. Help me out -
I want to use session to do a query and will I be able to do this? I have a session that was gathered from login and now i was to use this session to do a query If Yes, How?
-
retrieve information from MYSQL through drop down list
xxreenaxx1 replied to xxreenaxx1's topic in PHP Coding Help
I know you can do something like that. I am not sure how to. Any tutorial site you can forward me to -
I have created a drop down list and it does retrieve information from mysql but now I want to use what is been selected to retrieve information. How Do I do this? <?php MYSQL_CONNECT(localhost,'root','') OR DIE("Unable to connect to database"); @mysql_select_db(Examination) or die( "Unable to select database"); $query=("SELECT * FROM subject"); $result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() ); echo "<select name=myselect>"; while($row=mysql_fetch_array($result)){ echo "<OPTION VALUE=".$row['Sub_ID'].">".$row['Sub_Name']."</OPTION>"; } echo "</select>"; ?>