darkfreaks Posted February 12, 2008 Share Posted February 12, 2008 ok how would i add a checkbox called deleted next to the topics and then at the buttom a delete button and a statement that makes sure if it is checked it deletes??? <?php define('QUADODO_IN_SYSTEM', true); require_once('includes/header2.php'); $logname = stripslashes($qls->user_info['username']); $coven = $qls->Security->make_safe($_GET['coven']); include ('config.php'); $query = "SELECT * FROM vc_coven WHERE name='$coven'"; $result = mysql_query($query); $num=mysql_num_rows($result); mysql_close(); $i=0; for ($i = 0; $i < $num; $i++) { $covid = mysql_result($result,$i,"id"); $header = mysql_result($result,$i,"header"); $info = mysql_result($result,$i,"info"); $date = mysql_result($result,$i,"date"); $startedby = mysql_result($result,$i,"startedby"); $approval = mysql_result($result,$i,"approval"); if ($startedby=="$logname") { echo "[<a href='../coven/editcoven.php?cname=$coven'>Edit Coven</a>] [<a href='../coven/viewmembers.php?coven=$coven'>Edit Memebrs</a>] <p>"; } if ($logname=="chrisx") { if ($startedby=="chrisx") { echo ""; }else{ echo "[<a href='../coven/oceditcoven.php?cname=$coven'>Edit Coven</a>] [<a href='../coven/oceditmembers.php?coven=$coven'>Edit Memebrs</a>] <p>"; } } if ($logname=="Oden") { if ($startedby=="Oden") { echo ""; }else{ echo "[<a href='../coven/oceditcoven.php?cname=$coven'>Edit Coven</a>] [<a href='../coven/oceditmembers.php?coven=$coven'>Edit Memebrs</a>] <p>"; } } echo " $header <div class=h2> <h2>$name</h2> </div> $info <p> <div class=owner> Owner: <a href=../profile/$startedby>$startedby</a> </div> <br> Coven created on $date <br> <div class=\"join\"><a href=../coven/joincoven.php?covid=$covid>Click here to join</a></div> <p>"; include ('config.php'); $query4 = "SELECT * FROM vc_covenmembers WHERE covenname='$coven'"; $result4 = mysql_query($query4); $count=mysql_num_rows($result4); mysql_close(); echo "Current members [<a href='../coven/covenmembers.php?coven=$coven'>$count</a>]<br>"; echo "Currently viewing: "; include ('config.php'); $query2 = "SELECT * FROM vc_covenmembers WHERE covenname='$coven'"; $result2 = mysql_query($query2); $num=mysql_num_rows($result2); mysql_close(); $i=0; for ($i = 0; $i < $num; $i++) { $uname = mysql_result($result2,$i,"username"); $approved = mysql_result($result2,$i,"approved"); $users = $qls->online_users(); $online_count = count($users); $online = false; for ($x = 0; $x < $online_count; $x++) { if ($users[$x]['username'] == $uname) { $online = true; break; } } if ($online === true) { echo " <a href='../profile/$uname'>$uname</a> "; } if ($uname=="$logname") { if ($approved=="no") { echo "<p> Sorry you have to be approved first to be able to access this coven's messages <p> "; }else{ echo "<style type=\"text/css\"> .join { display: none; } </style> <br> <a href=\"../coven/creatcat.php?covid=$covid\">Click here to creat a topic</a> <br> <table width=\"80%\" cellpadding=\"0\" cellspacing=\"0\"> <tr valign=\"top\"> <td width=\"20%\">Topic</td> <td width=\"15%\">Started by</td> <td width=\"5%\">Replies</td> <td width=\"20%\">Date Started</td> </tr>"; include ('config.php'); $query3 = "SELECT * FROM vc_coventopics WHERE covid='$covid' ORDER BY `catid` DESC LIMIT 0,100"; $result3 = mysql_query($query3); $num=mysql_num_rows($result3); mysql_close(); $i=0; for ($i = 0; $i < $num; $i++) { $catid = mysql_result($result3,$i,"catid"); $covid = mysql_result($result3,$i,"covid"); $title = mysql_result($result3,$i,"title"); $date = mysql_result($result3,$i,"date"); $username = mysql_result($result3,$i,"username"); echo "<tr valign=\"top\"> <td> <a href=\"../coven/board.php?catid=$catid&covid=$covid\">$title</a> </td> <td> <a href='../profile/$username'>$username</a> </td>"; include ('config.php'); $query4 = "SELECT * FROM vc_covenmessages WHERE catid='$catid' ORDER BY `id`"; $result4 = mysql_query($query4); $count=mysql_num_rows($result4); mysql_close(); echo "<td>$count</td>"; echo "<td>$date</td> </tr>"; } } } } echo "</table>"; echo "</form>"; } require_once('includes/footer.php'); ?> Link to comment https://forums.phpfreaks.com/topic/90617-code-help/ Share on other sites More sharing options...
Lamez Posted February 12, 2008 Share Posted February 12, 2008 I have a code like this, here is my script for my paid system, see what you can do with it: <?php $paid = "select * from users order by paid"; $q = mysql_query($paid) or die('Error: ' . mysql_error()); while ($rs=mysql_fetch_array($q)) { $id = $rs['username']; ?> <tr> <td><? echo $rs['first'];?> </td> <td><? echo $rs['last'];?></td> <td> <?php If($rs['paid'] == 0 ){ echo '<input type="checkbox" name="checkbox[]" value="'.$rs['username'].'" />'; } elseif($rs['paid'] == 1 ){ echo "<a href='pay_dele.php?cmd=delete&id=$id'>Paid</a>"; } echo " (".$rs['username'].")"; } ?> </td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/90617-code-help/#findComment-464568 Share on other sites More sharing options...
darkfreaks Posted February 12, 2008 Author Share Posted February 12, 2008 ok so i got it setup but it does not do anything??? <?php define('QUADODO_IN_SYSTEM', true); require_once('includes/header2.php'); $logname = stripslashes($qls->user_info['username']); $coven = $qls->Security->make_safe($_GET['coven']); include ('config.php'); $query = "SELECT * FROM vc_coven WHERE name='$coven'"; $result = mysql_query($query); $num=mysql_num_rows($result); mysql_close(); $i=0; for ($i = 0; $i < $num; $i++) { $covid = mysql_result($result,$i,"id"); $header = mysql_result($result,$i,"header"); $info = mysql_result($result,$i,"info"); $date = mysql_result($result,$i,"date"); $startedby = mysql_result($result,$i,"startedby"); $approval = mysql_result($result,$i,"approval"); if ($startedby=="$logname") { echo "[<a href='../coven/editcoven.php?cname=$coven'>Edit Coven</a>] [<a href='../coven/viewmembers.php?coven=$coven'>Edit Memebrs</a>] <p>"; } if ($logname=="chrisx") { if ($startedby=="chrisx") { echo ""; }else{ echo "[<a href='../coven/oceditcoven.php?cname=$coven'>Edit Coven</a>] [<a href='../coven/oceditmembers.php?coven=$coven'>Edit Memebrs</a>] <p>"; } } if ($logname=="Oden") { if ($startedby=="Oden") { echo ""; }else{ echo "[<a href='../coven/oceditcoven.php?cname=$coven'>Edit Coven</a>] [<a href='../coven/oceditmembers.php?coven=$coven'>Edit Memebrs</a>] <p>"; } } echo " <div class=h2> <h2>$name</h2> </div> $info <p> <div class=owner> Owner: <a href=../profile/$startedby>$startedby</a> </div> <br> Coven created on $date <br> <div class=\"join\"><a href=../coven/joincoven.php?covid=$covid>Click here to join</a></div> <p>"; include ('config.php'); $query4 = "SELECT * FROM vc_covenmembers WHERE covenname='$coven'"; $result4 = mysql_query($query4); $count=mysql_num_rows($result4); mysql_close(); echo "Current members [<a href='../coven/covenmembers.php?coven=$coven'>$count</a>]<br>"; echo "Currently viewing: "; include ('config.php'); $query2 = "SELECT * FROM vc_covenmembers WHERE covenname='$coven'"; $result2 = mysql_query($query2); $num=mysql_num_rows($result2); mysql_close(); $i=0; for ($i = 0; $i < $num; $i++) { $uname = mysql_result($result2,$i,"username"); $approved = mysql_result($result2,$i,"approved"); $users = $qls->online_users(); $online_count = count($users); $online = false; for ($x = 0; $x < $online_count; $x++) { if ($users[$x]['username'] == $uname) { $online = true; break; } } if ($online === true) { echo " <a href='../profile/$uname'>$uname</a> "; } if ($uname=="$logname") { if ($approved=="no") { echo "<p> Sorry you have to be approved first to be able to access this coven's messages <p> "; }else{ echo "<style type=\"text/css\"> .join { display: none; } </style> <br> <a href=\"../coven/creatcat.php?covid=$covid\">Click here to creat a topic</a> <br> <table width=\"80%\" cellpadding=\"0\" cellspacing=\"0\"> <tr valign=\"top\"> <td width=\"20%\">Delete</td> <td width=\"20%\">Topic</td> <td width=\"15%\">Started by</td> <td width=\"5%\">Replies</td> <td width=\"20%\">Date Started</td> </tr>"; include ('config.php'); $query3 = "SELECT * FROM vc_coventopics WHERE covid='$covid' ORDER BY `catid` DESC LIMIT 0,100"; $result3 = mysql_query($query3); $num=mysql_num_rows($result3); mysql_close(); $i=0; for ($i = 0; $i < $num; $i++) { $catid = mysql_result($result3,$i,"catid"); $covid = mysql_result($result3,$i,"covid"); $title = mysql_result($result3,$i,"title"); $date = mysql_result($result3,$i,"date"); $username = mysql_result($result3,$i,"username"); echo "<tr valign=\"top\"> <td><input name=checkbox[] type=checkbox></td> <td><a href=\"../coven/board.php?catid=$catid&covid=$covid\">$title</a> </td> <td> <a href='../profile/$username'>$username</a> </td>"; include ('config.php'); $query4 = "SELECT * FROM vc_covenmessages WHERE catid='$catid' ORDER BY `id`"; $result4 = mysql_query($query4); $count=mysql_num_rows($result4); mysql_close(); echo "<td>$count</td>"; echo "<td>$date</td> </tr>"; } } } } echo "</table>"; echo "</form>"; } echo"<form method=post action=delete.php><input type=submit name=Submit></form>"; Link to comment https://forums.phpfreaks.com/topic/90617-code-help/#findComment-464585 Share on other sites More sharing options...
Lamez Posted February 12, 2008 Share Posted February 12, 2008 <?php if(isset($_POST['Submit'])){ $boxes = $_POST['checkbox']; foreach($boxes as &$value){ if($value!=='') { $q = "DELETE FROM forum WHERE postid=$covid"; echo $q.'<br />'; mysql_query($q); } } echo "<h2>Processed</h2>"; echo 'Selected users have been processed<br><a href="index.php">board</a>'; }else{ echo "<h2>Error!</h2>"; echo 'No data to process<br><a href="index.php">Back</a>'; } ?> use this as your form process, see what you can do with that Link to comment https://forums.phpfreaks.com/topic/90617-code-help/#findComment-464604 Share on other sites More sharing options...
darkfreaks Posted February 12, 2008 Author Share Posted February 12, 2008 the process code is in delete.php? how do i make it so when submitted it carries out delete.php??? Link to comment https://forums.phpfreaks.com/topic/90617-code-help/#findComment-464620 Share on other sites More sharing options...
Lamez Posted February 12, 2008 Share Posted February 12, 2008 you need a form action, and a submit button, but if you are trying to make it delete when you select it right then instead of clicking a button to activate the form action, then you might need to look into some JS (Javascript). http://www.google.com/search?q=click+checkbox+for+form+action+JS&btnG=Search&hl=en&safe=off Link to comment https://forums.phpfreaks.com/topic/90617-code-help/#findComment-464629 Share on other sites More sharing options...
Lamez Posted February 12, 2008 Share Posted February 12, 2008 use this, sorry read the post wrong <?php $boxes = $_POST['checkbox']; foreach($boxes as &$value){ if($value!=='') { //YOUR DELETE CODE } ?> Link to comment https://forums.phpfreaks.com/topic/90617-code-help/#findComment-464631 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.