Jump to content

How to assign query results to input fields of a form and then echo them?


adrafa

Recommended Posts

What I need is to retrieve results from a database and use those results as input fields in a form. I was able to do that much but I can't figure out how to echo the results. Here is my code:

<?php

$result = mysql_query("SELECT * FROM table");

while($row = mysql_fetch_array($result))

{

echo $row['sub_class'];

echo '<input type="text" name="'.$row['sub_class'].'">'; 

}

?>

 

This code creates 5 input fields in my form, because the table has 5 rows created. What am I missing to be able to echo each of those 5 input fields?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.