Hi
I’m developing a web site, there is one php page wich displays a series of input text, the input text amount displayed depends on the number of rows found in a db
e.g:
If there were 5 matches from a query, the php file shows me 5 input text
The next code, I wrote it to create input text with diferent names
$i=1;
While($row=mysql_fetch_object($result)) {
..........................
<td>
<p align= 'center'><input type='text' name='newO".$i++."'size='1' value=0 maxlength='2'></p>
</td>";
}
Note the detail : 'newO".$i++
While the ‘while’ sentence run, the input text created will have diferent names. E.g:
the first one will be called newO1, next newO2,3,4,5, and so on.
My intention is to insert numbers in these input text, when it’s done, I press a submit button and I wish to run a SQL UPDATE using the numbers I wrote.
Thise UPDATE will be in the table called “imagen”, in the column “orden”
This is the code I wrote to achieve this (I dosen’t work as I want):
if($_POST['submit']){
$k=1;
$result=mysql_query("SELECT * FROM imagen") or die("wrong1");
while($row=mysql_fetch_object($result)){
$n = $_POST['newO'.$k];
mysql_query("UPDATE imagen SET orden = $n WHERE PicNum LIMIT 1") or die ("wrong2 ".mysql_error());
$k++;
}
}
I just can change a value, and not all the values I wrote before I do the submit
I hope someone can help me
Thanks
Alvaro