I'm doin a project using php and mysql. i have 2 tables in my database namely: question & answer. the question table can b accessed by teacher and answer table can be accessed by student... the teacher can all or delete questions frn d question table... i want to create a page wherein when a student logs in, all the questions in the question table will b displayed and a text box will b placed after each question where the student can put in his answers. whn d student clicks submit, all the values entered by the student is passed to the next page and is entered to the answer table.
I dont kno how to create text boxes dynamically and send the values to the next page... cud someone suggest a way by which the values can b received in the next page using post method... please put a small code if possible... thanking u in anticipation.

Recommended Answers

All 2 Replies

You can have a naming convention for the texboxes such as Box_$i where $i is a counter.

first initialize $i to be 0 i.e. $i=0;
then create a variable for the textbox name such as $textboxname = "Box"
as you retrieve data from the database, increase $i and then change the name of the textbox i.e. $textboxname = "Box_" . $i;

<html>
<body>

<?php 
$i = 0;
while (record is not empty){
    $textboxname = "Box_" . $i;  
    ?>
    <input type = "text" name = "<?php echo $textboxname ?>" id = "php echo $textboxname ?>" />

<?php
    $i++;
}

?>

I'm doin a project using php and mysql. i have 2 tables in my database namely: question & answer. the question table can b accessed by teacher and answer table can be accessed by student... the teacher can all or delete questions frn d question table... i want to create a page wherein when a student logs in, all the questions in the question table will b displayed and a text box will b placed after each question where the student can put in his answers. whn d student clicks submit, all the values entered by the student is passed to the next page and is entered to the answer table.
I dont kno how to create text boxes dynamically and send the values to the next page... cud someone suggest a way by which the values can b received in the next page using post method... please put a small code if possible... thanking u in anticipation.

i can create a system like that for you if you need it. just let me know.

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.