Ok I have a form that dynamically produces itself based on a query. Which sets the initial field values to the values returned from the query.
<input name="var1" type="text" value=<? print $row[3]; ?> size="5">
I want to then pass these values to a update sql, which updates the db. Then I want to reset the form to reflect these changes.
I want this to be done all in the same page, so i need to use php_self?
(also does it make any difference if the inputs are 'hidden' type)
<input name="var1" type="text" value=<? print $row[3]; ?> size="5">
I want to then pass these values to a update sql, which updates the db. Then I want to reset the form to reflect these changes.
I want this to be done all in the same page, so i need to use php_self?
(also does it make any difference if the inputs are 'hidden' type)
Code:
<?php
include_once("db.php");
include_once("property.php");
mysql_select_db($database_Jmx, $Jmx);
# make a query on required item
$query = "SELECT *
FROM s INNER JOIN u_s ON s.s_id =u_s.s_id;";
$query_result_handle = mysql_query ($query)
or die ('The item intially select statement has failed');
# make sure there is data
$num_of_rows = mysql_num_rows ($query_result_handle)
or die ("The query: '$query' did not return any data");
# use mysql_fetch_row to retrieve the results
for ($count = 1; $row = mysql_fetch_row ($query_result_handle); ++$count)
{
?>
<form action="<?php echo $PHP_SELF ?>">
<table width="100%" border="0">
<tr align="left">
<td><div align="left">v1</div>
</td>
<td> <? print $row[1];?>
<input name="v1" type="hidden" value=<? print $row[1];?>></td>
</tr>
<tr>
<td align="center"><div align="left">v2</div>
</td>
<td><? print $row[2] ?>
</td>
</tr>
<tr>
<td width="17%" align="center"><div align="left">v3</div>
</td>
<td width="27%"><? print $row[7] ?>
</td>
</tr>
<tr>
<td align="center"><div align="left">v4</div>
</td>
<td><? print $row[0]; ?>
</td>
</tr>
<tr>
<td align="center"><div align="left">v5</div>
</td>
<td><input name="v5" type="text" value=<? print $row[3]; ?> size="5">
</td>
</tr>
<tr>
<td align="center"><div align="left">v6</div>
</td>
<td><input name="v6" type="text" value=<? print $row[4]; ?> size="5">
</td>
</tr>
<tr>
<td align="center"><div align="left">v7</div>
</td>
<td><input name="v7" type="text" value=<? print $row[5]; ?> size="5">
</td>
</tr>
<tr>
<td align="center"><div align="left"></div>
</td>
<td> </td>
</tr>
</table>
<input type="submit" value="submit" name="submit">
<input type="reset" value="Reset" name="B2">
</form>
<?
}
/* Free resultset */
mysql_free_result($query_result_handle);
?>