Hi Experts, below is my data file and I want to create form the basis of data returned by the following code.

getdata.php

<?php

include ("dbConnect.php");

$examID = $_POST['examID'];
 $sql= mysql_query("select * from examsub where examID='1');
         if(mysql_num_rows($sql)>0)
         {
             while($row=mysql_fetch_array($sql3))
            {
                               echo $row['examID'].$row['subject'].$row['thrymarks'].$row['pracmarks'].$row['subjectID'];
            } 

         }

?>

Below is the code from where when I press a button a form is create on the basic for rows returned by the above code.

$("#examID").change(function(){
     $.post("getdata.php", {examID: from.examID.value},
         function(str){
                        /*
                          // code here
                         */



            });
   });

Please help.

Recommended Answers

All 3 Replies

I don't see any html for your php rows.You should concatenet php with html using echo like this

 echo'<table id="grades_table">'.'<tr>'.'<td>' .$row['examID'].
 '</td>'.'</tr>'.'<tr>'.'<td>'.$row['subject'].'
 </td>'.'</tr>'.'<tr>'.'<td>'.$row['thrymarks'].'</td>'.'</tr>'.'<tr>'.'<td>'
 .$row['pracmarks'].'</td>'.'</tr>' .'<tr>'.'<td>'.$row['subjectID'].'</td>'.'</tr>'.'</table>';

Happy codding

Below is the code from where when I press a button a form is create on the basic for rows returned by the above code.

??

Yes it creates a table that puts every row of yours in a html table and if you want to create a button that will make you a form you will have to create a html form and in that form you have to create a button form there you will have to call the php to that file

something like this

<?php require_once(''aexternalphpfile); // use this if you have an external php form my point of view is a best practice?>
<form method="POST" action="yourphpfile">
<button name="create" value="create"></button>
</form>

// and in the external php file you will have an

   if(isset($_POST['create'])){

//run some code


}
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.