Gilly79 Posted February 21, 2010 Share Posted February 21, 2010 Hello Sorry peeps another question! Ive been plaing around with this inserting commands to no availe! What I am trying to do is insert a checkbox in a table of returned data from back end php.. The table is below with its retruned values - however i want to put a check box in the delete and reply table entries... I have the php to delete and reply so thats not an issue - i wrote it myself (a miracle!!0 but no idea how to get a checkbox in the table s i just press submit and it deletes the highlighted messages.. // see if any rows were returned if (mysqli_num_rows($result)>0) { echo "<table border=1>\n<tr>" . "<th>MessageNo</th>" . "<th>MessageFrom</th>" . "<th>MessageTo</th>" . "<th>Subject</th>" . "<th>Message</th>". "<th>Reply</th>". "<th>Delete</th>"; while ($row = @ mysqli_fetch_array($result)) { //while($row = mysql_fetch_row($result)) { echo "<tr>"; echo "<td class=BorderMeRed>".$row["MessageNo"]."</td>"; echo "<td class=BorderMeRed>".$row["MessageFrom"]."</td>"; echo "<td class=BorderMeRed>".$row["MessageTo"]."</td>"; echo "<td class=BorderMeRed>".$row["Subject"]."</td>"; echo "<td class=BorderMeRed>".$row["Message"]."</td>"; echo "<td class=BorderMeRed></td>"; echo "<td class=BorderMeRed></td>"; echo "</tr> Again thank you so much for your help.. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/192861-second-query-really-sorry-putting-a-checkbox-in-returned-data/ Share on other sites More sharing options...
ialsoagree Posted February 22, 2010 Share Posted February 22, 2010 You're looking for the HTML code for a checkbox? <input type="checkbox" name="checkbox_name" value="checkbox_name equals this when this is checked" /> Link to comment https://forums.phpfreaks.com/topic/192861-second-query-really-sorry-putting-a-checkbox-in-returned-data/#findComment-1015958 Share on other sites More sharing options...
Gilly79 Posted February 22, 2010 Author Share Posted February 22, 2010 no its not the html code for a checkbox, its how i put a check box within the same string of returned data from the php query... Can you see how ive got the echo row? well at the returned row id like to put a checkbox at the end so I can mark for delete... however Im just not sure how this is done? Then when I have the checkbox for delete I have a submit button at the bottom of the code which will activate deleting ther relevant row... Is that making sence? sorry explaining is never my forte - which sucks when im asking for help! Link to comment https://forums.phpfreaks.com/topic/192861-second-query-really-sorry-putting-a-checkbox-in-returned-data/#findComment-1016176 Share on other sites More sharing options...
teamatomic Posted February 22, 2010 Share Posted February 22, 2010 echo "<input type=\"checkbox\" name=\"delete[]\" value=\"$row['MessageNo']\" />"; echo "<td class=BorderMeRed>".$row["MessageNo"]."</td>"; _$POST['delete'] will be an array of all the MessageNO that were checked HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/192861-second-query-really-sorry-putting-a-checkbox-in-returned-data/#findComment-1016214 Share on other sites More sharing options...
Gilly79 Posted February 22, 2010 Author Share Posted February 22, 2010 Hiya - thanks for the reply - I came up with something simlar (not quite like that) but it does not compute in my code... the MessageNo come up highlighted as there is an error - Im really sorRy but im strugging with this - Ive just copied the code accross... and put it at the end of the the echo table entry and its saying there is an error... Its the parms and the coding structure i cant seem to grasp... Ive attachted the full file - any help appreciated Sorry teamatomic im being a tard today! [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/192861-second-query-really-sorry-putting-a-checkbox-in-returned-data/#findComment-1016375 Share on other sites More sharing options...
Gilly79 Posted February 22, 2010 Author Share Posted February 22, 2010 got it working.... its like so if anyone is intrested... // see if any rows were returned if (mysqli_num_rows($result)>0) { echo "<table border=1>\n<tr>" . "<th>MessageNo</th>" . "<th>MessageFrom</th>" . "<th>MessageTo</th>" . "<th>Subject</th>" . "<th>Message</th>". "<th>Reply</th>". "<th>Delete</th>"; while ($row = @ mysqli_fetch_array($result)) { //while($row = mysql_fetch_row($result)) { echo "<tr>"; echo "<td >".$row["MessageNo"]."</td>"; echo "<td>".$row["MessageFrom"]."</td>"; echo "<td>".$row["MessageTo"]."</td>"; echo "<td>".$row["Subject"]."</td>"; echo "<td>".$row["Message"]."</td>"; echo "<td><input type=\"checkbox\" name=\"delete[]\" value=".$row["MessageNo"]." /></td>"; echo "</tr>"; thanks for all your help Link to comment https://forums.phpfreaks.com/topic/192861-second-query-really-sorry-putting-a-checkbox-in-returned-data/#findComment-1016479 Share on other sites More sharing options...
Gilly79 Posted February 23, 2010 Author Share Posted February 23, 2010 HIYA Ive got my checkboxes working in full effect - however I dont seem to be getting the var passed from the ttable to my php page.... My php page looks right as it works elsewhere - but the delete checkbox doesn't seem to pass the var on the submit command?? is this echo "<td><input type=\"checkbox\" name=\"reply[]\" value=".$row["MessageNo"]." /></td>"; And i have the $delete = $POST['delete']; IN my php page - any idea why it wont work?? confused.com! ha Link to comment https://forums.phpfreaks.com/topic/192861-second-query-really-sorry-putting-a-checkbox-in-returned-data/#findComment-1016992 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.