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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.