belmon Posted November 6, 2011 Share Posted November 6, 2011 Hi, I want to loop out data from DB in <input> and change and update several posts at the same time. Can you give me a short example, how <input> and maybe foreach could look like? Thanks Link to comment https://forums.phpfreaks.com/topic/250569-updating-the-looped-data/ Share on other sites More sharing options...
xyph Posted November 6, 2011 Share Posted November 6, 2011 Perhaps if you started with some code you've attempted. Link to comment https://forums.phpfreaks.com/topic/250569-updating-the-looped-data/#findComment-1285610 Share on other sites More sharing options...
belmon Posted November 6, 2011 Author Share Posted November 6, 2011 My example: <FORM ACTION="edit_price.php" METHOD="POST"> <? include "db.php"; $sql = mysql_query("select * FROM prices", $conn); while ($rs= mysql_fetch_array($sql)){ $priceid = $rs['price_id']; $price = $rs['price']; ?><input type="text" name="pprice['.$priceid.']" value="<? echo $price; ?>"> <input type="submit"> </FORM> And the updating code: if ($pprice) { foreach ($ ????????) if ($price>0) { include "db.php"; $sql = mysql_query("UPDATE prices SET price = '$pprice' WHERE price_id = '$priceid'"); } } ------------------------------------- This code is hypothetical and completely wrong. But maybe something like this. Link to comment https://forums.phpfreaks.com/topic/250569-updating-the-looped-data/#findComment-1285625 Share on other sites More sharing options...
xyph Posted November 6, 2011 Share Posted November 6, 2011 You're on the right track, keep attempting on your own, and fix up a few parse errors. Link to comment https://forums.phpfreaks.com/topic/250569-updating-the-looped-data/#findComment-1285642 Share on other sites More sharing options...
belmon Posted November 6, 2011 Author Share Posted November 6, 2011 Thanks for your reply! I already have tried a bit. I appreciate if you correct the code quickly and I promis to learn it for the life. Link to comment https://forums.phpfreaks.com/topic/250569-updating-the-looped-data/#findComment-1285666 Share on other sites More sharing options...
xyph Posted November 6, 2011 Share Posted November 6, 2011 I'm not here to program for you. If you don't understand the basic syntax, you should learn that first. Link to comment https://forums.phpfreaks.com/topic/250569-updating-the-looped-data/#findComment-1285677 Share on other sites More sharing options...
belmon Posted November 6, 2011 Author Share Posted November 6, 2011 I try to get help at other forums. But I propse to do not answer so to anyone Thanks and goodbye Link to comment https://forums.phpfreaks.com/topic/250569-updating-the-looped-data/#findComment-1285679 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.