Jump to content

xxreenaxx1

Members
  • Posts

    167
  • Joined

  • Last visited

    Never

Everything posted by xxreenaxx1

  1. I want to use a session to get information from mySql. Say Username and use this to do a query SELECT DISTINCT u.Use_Name, u.Use_ID, u.Use_Name, us.Sub_ID, s.Sub_NameFROM user u, user_x_subject us, subject sWHERE u.Use_Name = '[b][size=14pt]$username' [/size] [/b] AND u.Use_ID = us.Use_ID AND s.Sub_ID = us.Sub_ID Now the code work <?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() ); while($row=mysql_fetch_array($result)){ echo "<OPTION VALUE=".$row['Sub_ID'].">".$row['Sub_Name']."</OPTION>"; } ?>
  2. How would you do a drop down box using session So far I have <?php $_SESSION['username']; $query="SELECT DISTINCT u.Use_Name, u.Use_ID, u.Use_Name, us.Sub_ID, s.Sub_Name FROM user u, user_x_subject us, subject s WHERE u.Use_Name = '$username' AND u.Use_ID = us.Use_ID AND s.Sub_ID = us.Sub_ID"; $result = mysql_query($query); while($nt=mysql_fetch_array($result)){ echo "<option value=$nt[sub_ID]>$nt[sub_Name]</option>"; } echo "</select>";// ?>
  3. but I am getting these echo's from another table. Can I do that?
  4. I am echo information from the database now I would like to insert these to different table. I am using checkbox to echo and when the user click on the one of these the result should be saved to a new table. So far I have <?php include 'Database/connection.php'; include 'Database/question_sql.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"; } ?>
  5. checkbox works. Now can I add these chosen checkbox on to mysql. Eg: if someone choose choice1 and I would like to save this onto answer1 on to my mysql if I confused you then I apologies.
  6. I am retrieving data from mysql and printing this as a table. Now I want to print this as a checkbox. But not sure how to? <?php mysql_connect("localhost", "root", "")or die("cannot connect"); mysql_select_db("Examination")or die("cannot select DB"); $sql=mysql_query("SELECT * FROM question") or die(mysql_error()); Print "<table border cellpadding=5>"; while($info = mysql_fetch_array( $sql )) { Print "<th>Question:</th> <td>".$info['Que_Question'] . "</td> "; Print "<th>Choice1:</th> <td>".$info['Que_Choice1'] . "</td> "; Print "<th>Choice2:</th> <td>".$info['Que_Choice2'] . "</td> "; Print "<th>Choice3:</th> <td>".$info['Que_Choice3'] . "</td> "; Print "<th>Choice4:</th> <td>".$info['Que_Choice4'] . "</td> "; } Print "</table>"; ?>
×
×
  • 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.