hi
I have a table in my database that look like this:
id - name - orderno

the table has data in the fields of id and name but orderno is empty.
I made a html form based on the data of this field, in front of each name field there is an text input field. when the user submits the data I want every value in the text input field to be inserted in the orderno of the relevant id.

is this possible?

Yeah, possible. Have a hidden field in the form to store the id. When the user clicks submit, update the table :)

update table set orderno='".$_POST['orderno']."' where id='".$_POST['id']."'";

thanks for the reply, that is what I did.
However, I was wondering how would I do it for more than one field. I tired to name the text input "orderno[]" and then use foreach loop to extract the values, but I could not assign each of the values to its related id.

Okay.. This is a sloppy example, just to give you an idea.

<?php
if(isset($_POST['submit'])) {
	print "<pre>";
	print "Id array => <br />";
	print_r($_POST['id']);
	print "Order no array => <br />";
	print_r($_POST['orderno']);
	print "</pre>";
       for($i=0;$i< count($_POST['orderno']); $i++) { //there will be equal number of elements in both id array and orderno array. 
		echo $_POST['id'][$i]." -> ".$_POST['orderno'][$i]."<br />";
	}
}
?>
<html>
<body>
<form method="post">
<?php 
for($i=0;$i<5;$i++) {
?>
<input type='hidden' name='id[]' value='<?php echo $i; ?>'> 
Order <?php echo $i; ?>:<input type="text" name="orderno[]"><br />
<?php 
}
?>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

Instead of for loop, you will have while($row = mysql_fetch_array($result)) . Instead of assigning $i as value to the hidden field, you will have the counter/id field of the table.
You can then map the values of the array entered by the user in the orderno field to id field.

thank you very much. worked after some modifications.

You are welcome :) Cheers!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.