guestbook help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    guestbook help

    heya everyone...

    its been ages since i have played around with codes anyways i really need some help, i have a cpanel for my wapsite which has an option to remove extries from the guestbook, now my issue is this i can only remove one extry at a time and sometimes that takes forever LOL, anyways i want to beable to tick each one i want to remove then click remove, here is the code i am using right now.

    Code:
    <?php
    	include 'GbManager_Header.php'; 
    	$Action = Get_QString('Action'); //Requests Postback status from the Querystring.
    	$Id = Get_QString('Id');
    
    	if ($Action == "Remove") {
    		Show_List(Remove_Message($Id));
    	} else {
    		Show_List("False");	
    	}
    
    	include 'GbManager_Footer.php';
    
    function Remove_Message($Id) {
    	$Result = "False";
    	$DbRes = MySqlCmd("DELETE From page_guestbook WHERE Gbk_Id='$Id'");
    	if ($DbRes != "1") {
    		$Result = "Database Error.";
    	}
    	return $Result;
    }
    function Show_List($ShowError) {
    	$SqlResult = MySqlSelect("Select * From page_guestbook ORDER BY Gbk_Date,Gbk_Time,Gbk_Name");
    	$RowCnt = mysql_numrows($SqlResult);
    		
    	$Spacing = "					";
    	echo $Spacing.'<center>'."\n";
    	echo $Spacing.'<br>'."\n";
    	echo $Spacing.'<table border="0" cellpadding="0" cellspacing="0" style="color: #666;font-size:11px;width:550px;">'."\n";
    	echo $Spacing.'	<tr height="15" align="left"><td><span class="Form_Title">Guestbook Messages</span><HR width="100%" SIZE="1"></td></tr>'."\n";
    	echo $Spacing.'</table>'."\n";
    
    	echo $Spacing.'<br>'."\n";
    	echo $Spacing.'<table border="0" cellpadding="0" cellspacing="1" style="font-size:9pt;width:550px;">'."\n";
    	echo $Spacing.'	<tr style="background-color:#666;color:#FFF;"><td style="background-color:#FFF;color:#FFF;"></td><td><b>&nbsp;&nbsp;Date</b></td><td><b>&nbsp;&nbsp;Time</b></td><td><b>&nbsp;&nbsp;Message</b></td><td align="center"><b>Action</b></td></tr>'."\n";
    
    	if ($RowCnt > 0) {
    	$i = 0;
    	while ($i < $RowCnt) {
    		$Gbk_Id = mysql_result($SqlResult,$i,"Gbk_Id");
    		$Gbk_Date = mysql_result($SqlResult,$i,"Gbk_Date");
    		$Gbk_Time = mysql_result($SqlResult,$i,"Gbk_Time");
    		$Gbk_Name = mysql_result($SqlResult,$i,"Gbk_Name");
    		$Gbk_Message = mysql_result($SqlResult,$i,"Gbk_Message");
    
    		$Remove_Link = "Guestbook.php?Action=Remove&Id=$Gbk_Id";
    
    		$Spacing = "						";
    
    		echo $Spacing.'<tr style="background-color:#F5F5F5;color:#666;">';
    		echo '<td style="background-color:#FFF;"></td>';
    
    		echo '<td style="width:80px;">&nbsp;&nbsp;'.$Gbk_Date.'</td>';
    		echo '<td style="width:60px;">&nbsp;&nbsp;'.$Gbk_Time.'</td>';
    		echo '<td>&nbsp;&nbsp;<b>'.$Gbk_Name.'</b><br>&nbsp;&nbsp;'.$Gbk_Message.'</td>';
    
    		echo '<td align="center" style="width:50px;">';
    		echo '<table border="0" cellpadding="0" cellspacing="0" style="margin-top:2px;width:38px;height:16px;">';
    			echo '<tr height="16" align="center"><td>';
    				echo '<a href="#" onclick="return hs.htmlExpand(this, { headingText: '."'Delete Message'".' })"><img src="Design/Images/Remove.png" title="Remove"></a>';
    				echo '<div class="highslide-maincontent">';
    					echo "Are you sure that you want to remove this message? <br><br>";
    					echo '<a href="'.$Remove_Link.'">Yes</a>';
    					echo '<b> | </b>';
    					echo '<a href="#" title="{hs.lang.closeTitle}" onclick="return hs.close(this)">No</a>';
    				echo "</div>";
    			echo '</td></tr>';
    			echo '<tr><td></td></tr>';
    		echo '</table>';
    		echo '</td>';
    
    		echo "</tr>\n";		
    
    		$i++;
    	}
    	} else {
    		$Spacing = "						"; 
    		echo $Spacing.'<tr><td></td><td><font face="Verdana" size="2"><b>No Entries Found.</b></font><br></td></tr>'."\n"; 
    	}
    	$Spacing = "					"; 
    	echo $Spacing."</table><br><br></center>\n";
    }
    
    
    ?>

    #2
    Here you go!

    PHP Code:
    <?php
    $host
    ="localhost"// Host name 
    $username=""// Mysql username 
    $password=""// Mysql password 
    $db_name="test"// Database name 
    $tbl_name="test_mysql"// Table name 

    // Connect to server and select databse.
    mysql_connect("$host""$username""$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);

    $count=mysql_num_rows($result);
    ?>

    <table width="400" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td><form name="form1" method="post" action="">
    <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td>
    </tr>
    <tr>
    <td align="center" bgcolor="#FFFFFF">#</td>
    <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td>
    </tr>

    <?php
    while($rows=mysql_fetch_array($result)){
    ?>

    <tr>
    <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td>
    <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td>
    </tr>

    <?php
    }
    ?>

    <tr>
    <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td>
    </tr>

    <?php

    // Check if delete button active, start this 
    if($delete){
    for(
    $i=0;$i<$count;$i++){
    $del_id $checkbox[$i];
    $sql "DELETE FROM $tbl_name WHERE id='$del_id'";
    $result mysql_query($sql);
    }
    // if successful redirect to delete_multiple.php 
    if($result){
    echo 
    "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">";
    }
    }
    mysql_close();
    ?>

    </table>
    </form>
    </td>
    </tr>
    </table>
    Found it on my pc. Just change the sql. Cheers

    Comment


      #3
      Maybe... With <form> and check boxes with id of entry within

      while ($i < $RowCnt) ...

      and create an array, than just do loop and delete it.
      <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

      Comment

      Working...
      X