Posted by J.O. Aho on 06/07/06 11:54
jojo wrote:
> pls pls pls help
>
> I know a little php and am trying to do this...
>
> Build a form where the initial value is a certain value in a mysql
> table.
> The purpose of the form is to edit that value. Having the initial value
> already in there would make it easier.
>
>
> I already have a mysql table with 5 fields.
> Just 1 row of data. I will have to build 5 web pages, each page will
> have a form with 1 text box with the initial value from the msql table
> entered.
>
>
>
> Please can someone help I have tried searching but no luck.
$query="SELECT * FROM yourtable";
$result=mysql_query($query);
while($row=mysql_fetch_array($result)) {
echo "<form method=\"post\" action=\"update.php\">";
echo "<input name=\"ID\" value=\"".$row[$i]."\" type=\"hidden\">";
for($i=1;$i<count($row);$i++) {
echo "<input name=\"column$i\" value=\"".$row[$i]."\" type=\"text\">";
}
echo "<input value=\"Update\" name=\"Update\" type=\"submit\"></form>";
}
This would make a form for each line in the mysql table, with the value for
the column automatically filled. We assume that the first column is the ID
column, this one we don't allow to update.
Modify this for your liking.
//Aho
Navigation:
[Reply to this message]
|