Jump to content

dsjoes

Members
  • Posts

    149
  • Joined

  • Last visited

    Never

Everything posted by dsjoes

  1. still the same it adds new empty rows
  2. jcbones that is doing the same thing Pikachu2000 yes the info is still there i didn't use the back button
  3. it displays the below with check boxes at the end of the line and the delete and cancel button at the bottom. When i click a check box and delete it removes the info below until i change page and come back. then it is there again
  4. Pikachu2000 that script refreshes the page and it removes all the info until i click on another page and back on to it and nothing has been deleted. This is the whole of the original script for the table with the delete button. <?php $host="Host"; // Host name $username="user"; // Mysql username $password="pass"; // Mysql password $db_name="KAW"; // Database name $tbl_name="Target"; // 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"); // Build SQL query if(!isset($_POST['delete'])) $sql="SELECT * FROM $tbl_name ORDER BY ID"; else { $sql = "DELETE FROM $tbl_name WHERE"; // add row id to where section for($i=0;$i<count($_POST['checkbox']);$i++){ if($i != 0) $sql.= "AND "; $sql .= " ID='" . $_POST['checkbox'][$i] . "'"; } } $result = mysql_query($sql); if(isset($_POST['delete'])) header('Location: admin.php'); // redirect ?> <table align="center" width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td colspan="4" align="center" bgcolor="#000000"><strong>Targets</strong> </td> </tr> <tr> <td align="center" bgcolor="#000000"><strong>Select</strong></td> <td align="center" bgcolor="#000000"><strong>ID</strong></td> <td align="center" bgcolor="#000000"><strong>Target</strong></td> <td align="center" bgcolor="#000000"><strong>Comment</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#000000"> <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['ID']; ?>"> </td> <td bgcolor="#000000"><? echo $rows['ID']; ?></td> <td bgcolor="#000000"><? echo $rows['Target']; ?></td> <td bgcolor="#000000"><? echo $rows['Comment']; ?></td> </tr> <tr> <td colspan="5" align="center" bgcolor="#000000"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php } mysql_close(); ?> </table> </form> </td> </tr> </table>
  5. where do i put this code because i can not get it to display a message
  6. it just does the same. when i click a checkbox and delete it just creates an empty row and same if i press cancel
  7. any one using echo "This is the SQL : " . $sql; // to check if your sql sentence is ok $result = mysql_query($sql) or die(mysql_error()); // to control errors var_dump($result); i got the following message
  8. no it dosen't work it just does the same as it does before i changed it. it creates an empty row after i click delete
  9. that is all ready in the code it displays everything in the table it is in this bit at the bottom // Build SQL query if(!isset($_POST['delete'])) $sql="SELECT * FROM $tbl_name ORDER BY ID"; else { $sql = "DELETE FROM $tbl_name WHERE"; // add row id to where section for($i=0;$i<count($_POST['checkbox']);$i++){ if($i != 0) $sql.= "AND "; $sql .= " ID='" . $_POST['checkbox'][$i] . "'"; } } $result = mysql_query($sql); if(isset($_POST['delete'])) header('Location: admin.php'); // redirect ?> if i put echo $sql; before $result = mysql_query($sql); then i get the below message above the table SELECT * FROM Target
  10. i don't get an error message i put it after this line $sql = "DELETE FROM $tbl_name WHERE";
  11. i don't get any error messages it just dosn't delete the selected row it creates a new blank row every time i try to delete one
  12. i could delete from the database before but i have had to change the site because it would not display in internet explorer correctly. this is the script that lets me select and delete from the database <?php $host="host"; // Host name $username="user"; // Mysql username $password="pass"; // Mysql password $db_name="Targets"; // Database name $tbl_name="Target"; // 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"); // Build SQL query if(!isset($_POST['delete'])) $sql="SELECT * FROM $tbl_name ORDER BY ID"; else { $sql = "DELETE FROM $tbl_name WHERE"; // add row id to where section for($i=0;$i<count($_POST['checkbox']);$i++){ if($i != 0) $sql.= "AND "; $sql .= " ID='" . $_POST['checkbox'][$i] . "'"; } } $result = mysql_query($sql); if(isset($_POST['delete'])) header('Location: admin.php'); // redirect ?> <table align="center" width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td colspan="4" align="center" bgcolor="#000000"><strong>Targets</strong> </td> </tr> <tr> <td align="center" bgcolor="#000000"><strong>Select</strong></td> <td align="center" bgcolor="#000000"><strong>ID</strong></td> <td align="center" bgcolor="#000000"><strong>Target</strong></td> <td align="center" bgcolor="#000000"><strong>Comment</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#000000"> <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['ID']; ?>"> </td> <td bgcolor="#000000"><? echo $rows['ID']; ?></td> <td bgcolor="#000000"><? echo $rows['Target']; ?></td> <td bgcolor="#000000"><? echo $rows['Comment']; ?></td> </tr> <tr> <td colspan="5" align="center" bgcolor="#000000"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php } mysql_close(); ?> </table> </form> </td> </tr> </table> and this is the web page (php) withe the script in <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- TemplateBeginEditable name="doctitle" --> <title>Admin</title> <!-- TemplateEndEditable --> <!-- TemplateBeginEditable name="head" --> <!-- TemplateEndEditable --> <link href="adminsettings.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="container"> <div class="header"><p><?php date_default_timezone_set('Europe/London'); $today = date("l dS \of F Y h:i A (T)"); echo $today; ?></p><center><p><img src="pics/logo.png" alt="Logo" name="Insert_logo" width="540" height="196" id="Insert_logo" style="background: #000000; display:block;" /></p></center> <!-- end .header --></div> <div class="sidebar1"> <ul class="nav"> <li><a href="index.php"><img title='Generated button' src='Buttons/home.png' style="border-style: none" onmouseover='javascript&#058;this.src="Buttons/home1.png"' onmouseout='javascript&#058;this.src="Buttons/home.png"' /></a></li> <li><a href="claninfo.php"><img title='Generated button' src='Buttons/clan info.png' style="border-style: none" onmouseover='javascript&#058;this.src="Buttons/clan info1.png"' onmouseout='javascript&#058;this.src="Buttons/clan info.png"' /></a></li> <li><a href="faq.php"><img title='Generated button' src='Buttons/faq.png' style="border-style: none" onmouseover='javascript&#058;this.src="Buttons/faq1.png"' onmouseout='javascript&#058;this.src="Buttons/faq.png"' /></a></li> <li><a href="admin.php"><img title='Generated button' src='Buttons/admin.png' style="border-style: none" onmouseover='javascript&#058;this.src="Buttons/admin1.png"' onmouseout='javascript&#058;this.src="Buttons/admin.png"' /></a></li> <li><a href="password_protect.php?logout=1"><img title='Generated button' src='Buttons/logout.png' style="border-style: none" onmouseover='javascript&#058;this.src="Buttons/logout1.png"' onmouseout='javascript&#058;this.src="Buttons/logout.png"' /></a></li> </ul> <p>The admin page logs you out automatically after 30 minutes.</p> <!-- end .sidebar1 --></div> <div class="content"> <center><h1>Admin</h1> <p>Enter the targets name and comment here.</p> <p><form action="insert.php" method="post"> Target: <input type="text" name="Target" /> Comment: <input type="text" name="Comment" /> <input type="submit" /></p> <p>To delete a target click on the check box and then on delete.</p> <?php $host="host"; // Host name $username="user"; // Mysql username $password="pass"; // Mysql password $db_name="Targets"; // Database name $tbl_name="Target"; // 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"); // Build SQL query if(!isset($_POST['delete'])) $sql="SELECT * FROM $tbl_name ORDER BY ID"; else { $sql = "DELETE FROM $tbl_name WHERE"; // add row id to where section for($i=0;$i<count($_POST['checkbox']);$i++){ if($i != 0) $sql.= "AND "; $sql .= " ID='" . $_POST['checkbox'][$i] . "'"; } } $result = mysql_query($sql); if(isset($_POST['delete'])) header('Location: admin.php'); // redirect ?> <table align="center" width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td colspan="4" align="center" bgcolor="#000000"><strong>Targets</strong> </td> </tr> <tr> <td align="center" bgcolor="#000000"><strong>Select</strong></td> <td align="center" bgcolor="#000000"><strong>ID</strong></td> <td align="center" bgcolor="#000000"><strong>Target</strong></td> <td align="center" bgcolor="#000000"><strong>Comment</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#000000"> <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['ID']; ?>"> </td> <td bgcolor="#000000"><? echo $rows['ID']; ?></td> <td bgcolor="#000000"><? echo $rows['Target']; ?></td> <td bgcolor="#000000"><? echo $rows['Comment']; ?></td> </tr> <tr> <td colspan="5" align="center" bgcolor="#000000"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php } mysql_close(); ?> </table> </form> </td> </tr> </table> </p> <!-- end .content --></div> <div class="sidebar2"> <h4> </h4> <!-- end .sidebar2 --></div> <div class="footer"> <p> </p> <!-- end .footer --></div> <!-- end .container --></div> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.