emma57573 Posted October 13, 2008 Share Posted October 13, 2008 Im not quite sure how to handle the output of this loop $freetplquery="select * from mytable_sold where seller=".$userid." or buyer=".$userid.""; $sql=mysql_query($freetplquery); $rst=mysql_fetch_array($sql); ?> MY LEAVE FEEDBACK FORMS <table> <tr> <td> <? if ($rst) { ?> <FORM name="leavefeed" method="POST" action="updatefeedback.php" onsubmit="return Validate(this);"> <table> <? $cnt=0; while($rst){ $aid=mysql_fetch_array(mysql_query("select * FROM MYTABLE_products WHERE user=".$rst["pid"])); ?> <table> <tr> <td><? echo $aid["product_name"];?></td> </tr> <tr> <td><input name="feedbox<? echo $rst["pid"]; ?>" type="radio" value="" /><h2>Positive</h2></td> <td><input name="feedbox<? echo $rst["pid"]; ?>" type="radio" value="" /><h2>Neutral</h2></td> <td><input name="feedbox<? echo $rst["pid"]; ?>" type="radio" value="" /><h2>Negative</h2></td> <td><input name="feedbox<? echo $rst["pid"]; ?>" type="radio" value="" /><h2>Not Now</h2><br /></td> </tr> <tr> <td><b>Comments:</b><br /> <textarea name="comments<? echo $rst["pid"]; ?>"></textarea> </td> </tr> </table><br /> <? $rst=mysql_fetch_array($sql); $cnt++; }// end while ?> <input name="submit" type="submit" value="Submit your Feedback" /> </td> </tr> </table> </form> Ive tried to simplify this as much as possible so the code is watered down. When it gets to this page 'updatefeedback.php' The data is added to a mysql table. Thats where im stuck. How do I enter while loop details into a database? Do I need to create a simular loop in 'updatefeedback.php' that writes to mysql after every loop? and if so how do i pick up the form data as a loop. Or is there a simply way of doing this and im making life hard on myself (as usual!) Quote Link to comment https://forums.phpfreaks.com/topic/128187-solved-form-handling-in-a-loop-for-mysql/ Share on other sites More sharing options...
emma57573 Posted October 13, 2008 Author Share Posted October 13, 2008 The form works fine basically all I need to know is how to create an array from the form data onto the next submit page. So I can then put it into a loop and submit what I need to into mysql. Does that make sence? I just want to know if its possible to get the data into an array and how I would go about it? Im at a bit of a loose end with this. Quote Link to comment https://forums.phpfreaks.com/topic/128187-solved-form-handling-in-a-loop-for-mysql/#findComment-664103 Share on other sites More sharing options...
emma57573 Posted October 14, 2008 Author Share Posted October 14, 2008 Ok Ive written a bit of code that I thought would work! I dicided to use the same loop as the previous page in the same order and then do a mysql insert in the loop if ($rst) { $cnt=0; while($rst) { $pid=$rst["pid"]; $feed_score=$_POST["feedbox$pid"]; $feed_comm=$_POST["comments$pid"]; $insert= "INSERT INTO freetplclassified_feedback (user_id,score,comment,from_id,id,getdae,pro_id)VALUES('$userid','$feed_score','$feed_comm','$userid','','','$pid')"; mysql_query($insert); if(mysql_affected_rows()>0){ ?> Worked!! <? }else{ ?> Went wrong <? } $rst=mysql_fetch_array($sql); $cnt++; }// end while The loop is working but the insert to mysql isnt. Im not sure if im calling the $_POST right as it also has a variable in the name. I think this could be where im going wrong???? Quote Link to comment https://forums.phpfreaks.com/topic/128187-solved-form-handling-in-a-loop-for-mysql/#findComment-664792 Share on other sites More sharing options...
emma57573 Posted October 14, 2008 Author Share Posted October 14, 2008 forget that I know $_POST is working because I just tested it so thats something! it must be something to do with the way im trying to insert the data Quote Link to comment https://forums.phpfreaks.com/topic/128187-solved-form-handling-in-a-loop-for-mysql/#findComment-664798 Share on other sites More sharing options...
emma57573 Posted October 14, 2008 Author Share Posted October 14, 2008 FIXED ;D Just a silly capital letter in the database title Quote Link to comment https://forums.phpfreaks.com/topic/128187-solved-form-handling-in-a-loop-for-mysql/#findComment-664814 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.