The following code is how you should retrieve the data from mySQL... 
if you wanted to update all of the information through one button, 
though, I would do it in a slightly different way...


$sql = "SELECT whatever FROM.... whatever...";

$result = mysql_query($sql);

while ($row = mysql_fetch_array($result)){
        $domain = $row[0]; // first item in array
        $cancel = $row[1]; // second item in array

        <td><font size=2 face=Arial><?= $domain ?></font></td>
        <td><font size=2 face=Arial>Cancel This Domain?</font></td>
        <td><font size=2 face=Arial><input type=text name=confirm 
value='<?= $cancel ?>' size=3></font></td>

<?  }  ?>

as long as all these are from the same table... the update is easy...

I recently did the same thing with ASP (and I wish we had PHP at 
work), but I don't have it here at home. It was slightly more 
complicated, in the way that each value relating to each row 
presented to the user had to be put into different tables according 
to the values.

with the HTML form, you would put the fields like this (formatted 
without HTML for ease of viewing)
this method is for updating only one table

// start row
<input type="hidden" name="ID[]" value="<?= $row["ID"] ?>">
<input type="text" name="domain[]" value="<?= $row["Domain"] >">
<input type="text" name="cancel[]" value="<?= $row["Cancel"] ?>">
// end row

so basically you get the idea... what happens here is all the values 
are put into their respective arrays (when submitting the form) and 
you loop through the arrays on the next page on an insert query...

like so...


// connection information in here

for ($i=0;$i<count($ID);$i++){ // this will loop through as many 
records as you got and will put the correct information
        $sql = "UPDATE tablename SET Domain = '" . $domain[$i] . "' , 
Cancel = '" . $cancel[$i] . "' WHERE ID = " . $ID[$i] ;

all the above could should work, although its untested.... things to 
watch out for is making sure you have single quotes around the text 
fields but none around the ID (which should be a number)

if you have multiple tables to update, mail me and I'll tell you how 
to do that... its late and I don't want to explain unless u need 
it... also, I would probably also have a good look at how you are 
presenting the form to the user..... my example might not be how you 
want it to look, but i think its the data transfer that you were 
worried about...

any questions about the code?? just ask...


>I have a special set of information retrieved from a while loop that I would
>like a person to be able to edit and send back into a MySQL table.
>I know all of the basic MySQL commands for doing such, but the PHP side to
>get the input from the form to go in is really stumping me.
>This is what I have:
>$or = 0;
>while($or < $orderidrows) {
>       $orderinfo = mysql_fetch_row($orderidinfo);
>       $domain[$or] = $orderinfo[2];
>       $cancel[$or] = $orderinfo[3];
>       print "<tr><td><font size=2 
>size=2 face=Arial>Cancel This Domain?</font></td><td><font size=2
>face=Arial><input type=text name=confirm value='$cancel[$or]'
>       $or++;
>                                                  }
>The values I would normally insert into the MySQL from the form would be
>$confirm - however, in this case, I have a number of rows with the same
>name.  How do I distinguish one from another?  The [$or] doesn't work to do
>it (didn't think it would).
>Thanks for any help!

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to