I'm trying to create a webpage where by I have the questions in the database instead of it being hard code which is writing it down in php. How do i go about that. Just a simple page which will have a question and a blank box where the answer is meant to be written and the answer would also be stored in the database. Please any help would be really appreciated. I hope you understand what i'm trying to say
dami06
0
Junior Poster in Training
Recommended Answers
Jump to PostSimple. Fetch all the questions from the table and print it as follows.
$query="Select question from question_table"; $result=mysql_query($query); $i=1; echo "<form method=\"post\" action=\"questionpaper.php\">"; while($row=mysql_fetch_array($result)){ $question=$row['question']; echo $i."." $question."<br />"; // to print 1. What is your name ? echo "<input type=\"text\" name=\"answer$i\" /><br />"; \\ to have …
Jump to PostCreate a table with all the questions. You need another table to store the answers. question_id would be the foreign key in answers table. If you are doing this question-answer script for multiple users, you need another table users, whose 'user_id' would be a foreign key for table answers.
So, …
All 7 Replies
nav33n
472
Purple hazed!
Team Colleague
Featured Poster
dami06
0
Junior Poster in Training
nav33n
472
Purple hazed!
Team Colleague
Featured Poster
dami06
0
Junior Poster in Training
nav33n
472
Purple hazed!
Team Colleague
Featured Poster
dami06
0
Junior Poster in Training
nav33n
472
Purple hazed!
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.