Re: Problem with simple update

From: Date: Fri, 24 Jan 2003 11:55:30 +0000
Subject: Re: Problem with simple update
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-132976@lists.php.net to get a copy of this message
remove the hidden field and use <input type='text' size='2' name='catorder[{$array["catid"]}]' value='{$array["catorder"]}'> in action script you do foreach($_POST['catorder'] as $catid => $catorder) { update categories set catorder=$catorder where catid=$catid } Steve Jackson wrote:
I am trying to set the order of a set of categories. Previously the catid field sorted the order of the categories. However I changed this to Order By catorder and then set about writing a simple update query to allow people to set the order. I can't see anything wrong with this: Basically I pull the details from the categories DB into an array and then display in a table. This works fine <? while ($array = mysql_fetch_array($mysql)) { echo "<tr><td width='150'><span class='adminisoleipa'>"; echo "<input type='hidden' name='categoryid' value='{$array["catid"]}'>"; echo "{$array["catname"]}"; echo "</td><td><input type='text' size='2' name='catorder' value='{$array["catorder"]}'>"; echo "</span></td></tr>"; } ?> Then using this to update it seems to work till you check the update. It sets the first two fields to one for some reason. $query = "update categories
            set catorder = '$catorder'
            where catid='$categoryid'";
Any suggestions? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com stephen.jackson@violasystems.com Mobile +358 50 343 5159


« previous php.general (#132976) next »