Hi you there, I tring to develop a system wich prints pics from a databa base, with a description of the pics too.And you can input in a series of input text fields values that they are submited to change the order of the pics display in a php file (file.php). I print a table with these pics, text description and an input text area, with the intention to input integer values. These values are handle by a script, to update the order of the pics in the database.
Next the html code wich output the table:
$i=1;
While($row=mysql_fetch_object($result)) {
$des1=mysql_fetch_object($result2);
$orden= mysql_fetch_object($result3);
print "<td>
<IMG SRC=\"header.php?PicNum=$row->PicNum\" border=\"0\" high=\"200\" width =\"100\">
</td>
<td>
<p align='center'>$des1->des1</p>
</td>
<td><p align='center'>$orden->orden</p>
</td>
<td>
<p align= 'center'><input type='text' name='newO".$i++."'size='1' value=0 maxlength='15'></p>
</td>";
$counter += 1;
print"</tr></table><input type='submit' name='orden' value='gogo'></form>";
}
Plase, look at line 14, while this script finds objects (pics) in the db, it prints a serie of html tags to bild a table, and more important, prints input areas with the names "newO1, newO2,newO3", and so on, in these fields I'll put diferent integer values
Now see line 17, when I press the submit button I reload this file (file.php)
while($row=mysql_fetch_object($result)){
mysql_query("UPDATE imagen SET orden = $newO1 WHERE PicNum = PicNum LIMIT 1") or die ("wrong ".mysql_error());//here is the problem
}
I use a $_POST['orden'] to execute the code above, my problem resides in line 20, I can“t find a way to take all the values I put in newO$i++, as you can see, in this query I wrote "$newO1", and it works with the first field but not with others, and I wish to update all the values.
this is the table "imagen":
Code:
PicNum int(11) auto_increment Primary
imagen blob BINARY
des1 varchar(25)
des2 varchar(255)
seccion varchar(10)
precio int(11)
orden int(11) //orden=order
I hope you can help me.
Alvaro