Re: update more "same" fields at the same time

From: Date: Wed, 15 Jan 2003 11:50:29 +0000
Subject: Re: update more "same" fields at the same time
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-131678@lists.php.net to get a copy of this message
Simon wrote:
What do you mean with "update more "same" fields at the same time"?Can you give us an example? Gvre
<form name="form1" method="post" action=""> <? $query1 = "SELECT * FROM table where subcat = $_GET[a]"; $result1 = mysql_query($query1); while($row = mysql_fetch_object($result1)) { ?> <p> <input name="textfield" type="text" value="<? echo $row->oid; ?>"> <input name="textfield1" type="text" value="<? echo $row->url; ?>"> </p> <? } ?> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> now i want to change values of texfields and update them back to mysql. If you want to update all the records that have subcat = $_GET[a] with
the same values then you can do somethink like this: $subcat = $_POST['a']; $qsubcat = $_POST['subcat']; "update tables set field1=$_POST['textfield'],field2='$_POST['textfield1']' where subcat='$qsubcat'" I don 't know if this query will execute correctly because i don 't know the datatypes of your table fields. I prefer writing update and insert php scripts independed from select pages.It 's easier to read.

« previous php.general (#131678) next »