mike12255 Posted January 21, 2011 Share Posted January 21, 2011 So i got a table that looks somthing like this: File Name | Download | Suggested Catagory | Select Catagory | Approve -------------------------------------------------------------------------------------- test | Download | blah blah blah | Option menu | yes or no option menu test | Download | blah blah blah | Option menu | yes or no option menu test | Download | blah blah blah | Option menu | yes or no option menu what I want to do is in the file that processes this it only looks at the ones that have had the "approve column" submitted as a yes. Next it will to a mysql entry into verrified notes. Problem is with X amount of entries in that form I dont know how to look at only the ones that have said yes. Do I create a new form for each entry or put them all as one entry and after this what do I do next? Link to comment https://forums.phpfreaks.com/topic/225160-how-to-handle-this-form/ Share on other sites More sharing options...
freelance84 Posted January 21, 2011 Share Posted January 21, 2011 Do you want all the results where the "Approve == yes"? Link to comment https://forums.phpfreaks.com/topic/225160-how-to-handle-this-form/#findComment-1162939 Share on other sites More sharing options...
mike12255 Posted January 21, 2011 Author Share Posted January 21, 2011 yes because only the results where approve == yes need to have modifications made into the db Link to comment https://forums.phpfreaks.com/topic/225160-how-to-handle-this-form/#findComment-1162941 Share on other sites More sharing options...
freelance84 Posted January 21, 2011 Share Posted January 21, 2011 then simply select all from db where approve is equal to yes... $query_approved = mysql_query("SELECT * FROM table WHERE approve ='yes'"); Link to comment https://forums.phpfreaks.com/topic/225160-how-to-handle-this-form/#findComment-1162943 Share on other sites More sharing options...
mike12255 Posted January 21, 2011 Author Share Posted January 21, 2011 no sorry I must not have made myself clear that table that I drew is a real form on my webpage I want to get info from all of the ones on the webpage form that say yes to approve. Link to comment https://forums.phpfreaks.com/topic/225160-how-to-handle-this-form/#findComment-1162949 Share on other sites More sharing options...
freelance84 Posted January 21, 2011 Share Posted January 21, 2011 Ah ok, How is the table generated? Link to comment https://forums.phpfreaks.com/topic/225160-how-to-handle-this-form/#findComment-1162954 Share on other sites More sharing options...
mike12255 Posted January 21, 2011 Author Share Posted January 21, 2011 Its wrote through php echos but ill give you the view source html I have not added any forms or sumbit button yet so it is just a table because im not quite sure how to go about making a form with somthing like this: <table align="left" border="1" cellspacing="0" cellpadding="3"> <tr><td><b>Author</b></td><td><b>File name</b></td><td><b>Download</b></td><td><b>Suggested catagory</b></td><td><b>Select Catagory</b></td><td>Approve</td></tr> <td>MikeH</td> <td> A lot of my skills set back </td><td><a href= /uzEr%20Upl0ds/cache.zip > Download</a></td><td> 1001 Laws - Polceing </td><td><select name="scatagory"><option value="1"> Intro To Law </option><option value="2"> 1001 Laws - Police Foundations </option></select></td><td><select name = "approve"> <option value = "1"> Yes</option> <option value = "2"> no</option> </select></td></tr><td>MikeH</td> <td> MM </td><td><a href= /uzEr%20Upl0ds/Michael Heintzman.doc > Download</a></td><td> 1001 Laws - Polceing </td><td><select name="scatagory"><option value="1"> Intro To Law </option><option value="2"> 1001 Laws - Police Foundations </option></select></td><td><select name = "approve"> <option value = "1"> Yes</option> <option value = "2"> no</option> </select></td></tr> </table> Link to comment https://forums.phpfreaks.com/topic/225160-how-to-handle-this-form/#findComment-1162960 Share on other sites More sharing options...
freelance84 Posted January 21, 2011 Share Posted January 21, 2011 Each row = a new form but you would have to send each form one at a time or step1: one form starting at the top of the table and finishing at the bottom. step2: Created by a loop: Each cell in the table has a hidden field with the value of the cell in it eg: row1 of hidden fields could be: <input type="hidden" name="r1_author" value="mke"/><input type="hidden" name="r1_file" value="filename"/>...etc eg: row2 of hidden fields could be: <input type="hidden" name="r2_author" value="mke"/><input type="hidden" name="r2_file" value="filename"/>...etc step3: processed by a loop (you may want a table row count field somewhere). Obviously when the processing loop hits approved no, do nothing Link to comment https://forums.phpfreaks.com/topic/225160-how-to-handle-this-form/#findComment-1162968 Share on other sites More sharing options...
mike12255 Posted January 21, 2011 Author Share Posted January 21, 2011 Do the hidden fields not posses the same data that the non-hidden ones do? I really appreciate you helping me, but I am confused about this. Link to comment https://forums.phpfreaks.com/topic/225160-how-to-handle-this-form/#findComment-1162972 Share on other sites More sharing options...
freelance84 Posted January 21, 2011 Share Posted January 21, 2011 It's hard to read the table in that form, could you repost it but each <td> on its own line then i'll add the form for you Link to comment https://forums.phpfreaks.com/topic/225160-how-to-handle-this-form/#findComment-1162977 Share on other sites More sharing options...
mike12255 Posted January 21, 2011 Author Share Posted January 21, 2011 Ok, how is this? Also the fields will not always be the same they change depending on what info is in the database. <table align="left" border="1" cellspacing="0" cellpadding="3"> <tr> <td><b>Author</b></td> <td><b>File name</b></td> <td><b>Download</b></td> <td><b>Suggested catagory</b></td> <td><b>Select Catagory</b></td> <td>Approve</td> </tr> <td>MikeH</td> <td> A lot of my skills set back </td> <td><a href= /uzEr%20Upl0ds/cache.zip > Download</a></td> <td> 1001 Laws - Polceing </td> <td><select name="scatagory"> <option value="1"> Intro To Law </option> <option value="2"> 1001 Laws - Police Foundations </option> </select></td> <td><select name = "approve"> <option value = "1"> Yes</option> <option value = "2"> no</option> </select></td> </tr><td>MikeH</td> <td> MM </td> <td><a href= /uzEr%20Upl0ds/Michael Heintzman.doc > Download</a></td> <td> 1001 Laws - Polceing </td> <td><select name="scatagory"> <option value="1"> Intro To Law </option> <option value="2"> 1001 Laws - Police Foundations </option> </select></td> <td><select name = "approve"> <option value = "1"> Yes</option> <option value = "2"> no</option> </select></td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/225160-how-to-handle-this-form/#findComment-1162995 Share on other sites More sharing options...
freelance84 Posted January 21, 2011 Share Posted January 21, 2011 The html form you created (i've only included a few table columns, i have changed the content of each cell to a "disabled" "text" input). Obviously the name of each input will be different depending on the row it is in, eg: tr1_author tr2_author tr3_author ...etc <form action="thisphpscript.php" method="post"> <table align="left" border="1" cellspacing="0" cellpadding="3"> <tr> <td><b>Author</b></td> <td><b>File name</b></td> <td>Approve</td> </tr> <tr> <td> <input type="text" disabled="disabled" name="tr1_author" value="MikeH"/> </td> <td> <input type="text" disabled="disabled" name="tr1_fileName" value="A lot of my skills set back"/> </td> <td> <select name = "tr1_approve"> <option value = "1"> Yes</option> <option value = "2"> no</option> </select> </td> </tr> </table> <input type="hidden" name="rowCount" value="1"> <input type="submit" name="sendData" value="send"/> </form> the php to process the data: if(isset($_POST['send'])) { $dataArray = array(); $row_count = $_POST['rowCount']; for($i=0;$i<$row_count;++$i) { $approve = "tr".$i."_approve"; if($approve == 1) { //setting the post names to catch: $author = "tr".$i."_author"; $fileNmae = "tr".$i."_fileName"; $dataArray[]=array('author'=>$author,'fileName'=>$fileName); } } if(!empty($dataArray)) { //now do what you want with the dataArray... } } Link to comment https://forums.phpfreaks.com/topic/225160-how-to-handle-this-form/#findComment-1163012 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.