Jump to content

Search the Community

Showing results for tags 'delete'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 25 results

  1. Hi everyone, I don't understand why MySQL won't do execute query to delete record in phpmyadmin. I made a script in PHP, what did I do wrong? First page: <?php session_start(); if ($_SESSION['user']) { echo "<p>You are logging in as ".$_SESSION['user']." <a href='logout.php'>Log out</a></p>"; } else { header('location:denied.php'); } require('require.php'); ?> <!doctype html> <html> <head> <title>Delete your member's information</title> <link href="rcd.css" rel="stylesheet" type="text/css"> <link href="submit.css" rel="stylesheet" type="text/css"> </head> <body> <center> <p>Are you sure you want to delete this member's information?</p> <form action="delete2.php"> <table> <?php $del = $_GET['delete']; $show = "SELECT * FROM Members WHERE ID = '".$del."'"; $result = mysqli_query($Garydb, $show); if (mysqli_num_rows($result)) { while ($rows = mysqli_fetch_assoc($result)) { echo "<tr><td>First Name: </td><td><input type='text' value='".$rows['FirstName']."'></td></tr>"; echo "<tr><td>Last Name: </td><td><input type='text' value='".$rows['LastName']."'></td></tr>"; echo "<tr><td>Birth Month: </td><td><input type='text' value='".$rows['Month']."'></td></tr>"; echo "<tr><td>Email: </td><td><input type='text' value='".$rows['Email']."'></td></tr>"; echo "<tr><td>Local: </td><td><input type='text' value='".$rows['Local']."'></td></tr>"; echo "<tr><td colspan='2'><a href='delete2.php?delete2=".$rows['ID']."' style='font-size:20px;'>Delete Member's Information</a></td></tr>"; } } ?> </table> </form> <p><a href="register.php">Return to register page</a></p> </center> </body> </html> Second Page <?php session_start(); if ($_SESSION['user']) { echo $_SESSION['user']; }else { header('denied.php'); } require("require.php"); if ($_GET['delete2']) { $delete = $_GET['delete2']; } if ($delete) { $del = "DELETE * FROM Members WHERE ID = '".$delete."'"; mysqli_query($Garydb, $del); } ?> <!doctype html> <html> <head> <title>Deleted</title> </head> </html>
  2. I have a simple user login where it inserts the user session into database like this (id, user_id, hash). It works fine. I can delete the session from the database when the user logs out. Now I realized something. When I close the browser window, it'll destroy the session(log out the user) as intended but it won't delete the session from the database. I was wondering if there is a way to do that?
  3. The code in attached file is not working for me. and i am failed to find any mistake. Anyone help me please. deletedept.php
  4. Ok this is puzzleing. I am geting "Could not delete data: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1". but its is deleting the entry that needs to be removed. The "1" is the entry. Just not sure what is causing the error. I do have another delete php but I have put that on the back burning for the time being. <?php $con = mysqli_connect("localhost","user","password","part_inventory"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $result = mysqli_query($con, "SELECT * FROM amp20 "); $amp20ptid = $_POST['amp20ptid']; // escape variables for security $amp20ptid = mysqli_real_escape_string($con, $_POST['amp20ptid']); mysqli_query($con, "DELETE FROM amp20 WHERE amp20ptid = '$amp20ptid'"); if (!mysqli_query($con, $amp20ptid)); { die('Could not delete data: ' . mysqli_error($con)); } echo "Part has been deleted to the database!!!\n"; mysqli_close($con); } ?>
  5. I have 2 issues happening, first one I need to get resolved is, line 60 is giving me a 'Notice: Undefined variable: delete'. This codes had multi issues but was able to resolve all but this one and my table not filling in with the data from my database. If you need any other info please let me know, Again I am new at this. <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 *line 60* -----> if ($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysqli_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysqli_close($con); ?>
  6. Hey guys just wandered if you can help me on my website in the mailbox section next to the message there is a delete button to obviously delete that current message. However as I am sure you can appreciate it get tedious when you have 20 messages to do them all at once. So I am after putting a button at the top of this column in the table that will delete all the messages in there with one click. Below is the coding of where all this takes place: function mailbox($mes,$page) { global $config; if(!$page) { $page="1"; } $page=($page - 1); $totalmes=mysql_query("SELECT COUNT(*) FROM messages WHERE toid='".$_SESSION['tid']."' AND rcvddel=0"); $totalmes=mysql_result($totalmes,0); $out[body].=" <div style='float:left;width:69%;margin:5px;'> <table cellspacing='1' cellpadding='1' border='0' width='100%'> <tr> <td width='100%' class='blk_tcon' colspan='5'><b>" . LANG_MAI_MAILBOX . "</b></td> </tr> <tr> <td width='50%' colspan='2' class='blk_tcon_top'>" . LANG_MAI_SUBJECT . "</td> <td width='20%' class='blk_tcon_top'>" . LANG_MAI_FROM . "</td> <td width='25%' class='blk_tcon_top'>" . LANG_MAI_DATE . "</td> <td width='5%' class='blk_tcon_top'></td> </tr>"; $fmail=mysql_query("SELECT id,fromid,subject,active,sent FROM messages WHERE toid='".$_SESSION['tid']."' AND grid='1' AND rcvddel=0 ORDER BY sent DESC LIMIT $page, 15"); while(list($id,$fromid,$subject,$active,$sent)=mysql_fetch_row($fmail)) { $from=mysql_query("SELECT name FROM members WHERE id='$fromid'"); $from=mysql_fetch_array($from); if($fromid == '01') { $froma="Site Challenge"; }else{ $froma="<a href='./profile.php?account=$fromid'>$from[name]</a>"; } if($active == 1) { $icon="<img src='./images/unread.gif' border='0' alt='' />"; $title="<a href='./mailbox.php?action=readmail&mailtype=received&mid=$id'><b>$subject</b></a>"; }else if($active == 2){ $icon="<img src='./images/read.gif' border='0' alt='' />"; $title="<a href='./mailbox.php?action=readmail&mailtype=received&mid=$id'>$subject</a>"; }else{ $icon="<img src='./images/replied.gif' border='0' alt='' />"; $title="<a href='./mailbox.php?action=readmail&mailtype=received&mid=$id'>$subject</a>"; } $out[body].=" <tr> <td width='5%' align='center' class='blk_tcon'>$icon</td> <td width='45%' align='left' class='blk_tcon'>$title</td> <td width='20%' align='center' class='blk_tcon'>$froma</td> <td width='25%' align='center' class='blk_tcon'>$sent</td> <td width='5%' align='center' class='blk_tcon'> <form method='post'> <input type='hidden' name='mail[id]' value='$id' /> <input type='hidden' name='mail[mailtype]' value='received' /> <input type='hidden' name='action' value='delete' /> <input type='submit' class='button' name='submit' value='X' style='color:red; font-weight:bold;' title='" . LANG_MAI_DELETE . "' /> </form> </td> </tr>"; } if($totalmes == 0) { $out[body].=" <tr> <td width='100%' align='center' colspan='5' class='blk_tcon'>" . LANG_MAI_MAILBOX_EMPTY . "</td> </tr>"; } $pagenow=($page + 1); $pages=1; if($pagenow==1) { $skipranks.="[$pages] "; }else{ $skipranks.="<a href='./mailbox.php?page=1'>$pages</a> "; } $arank=1; $brank=15; while($brank < $totalmes) { $arank=($arank + 15); $brank=($brank + 15); $pages++; if($pagenow==$arank) { $skipranks.="[$pages] "; }else{ $skipranks.="<a href='./mailbox.php?page=$arank'>$pages</a> "; } } $out[body].=" <tr> <td width='100%' align='center' class='blk_tcon' colspan='5'>$skipranks</td> </tr> </table> </div> ".TOP_MENU.""; include("$config[html]"); } </tr>"; That is the whole coding of the mailbox received section, as you can see the messages section is all done in form coding so can i pop a nice button at the top to delete all or does it have to be check boxes and stuff. For help with the view of this I have attached a screenshot Thanks for any help in advance.
  7. Hello I am new here, and so i am to php.. i have a small question - i think anyone here could help me, im sure :-) I have a php-gallery running locally on my desktop (using xampp), the gallery just shows images from a directory where a webcam saves its pictures in it (the gallery is named "ubergallery" - maybe anyone knows this gallery). Now i really would like to have following option: - A Button on the thumbnail called "delete" - when clicking on it, the picture should get replaced with another, predefined, placeholder-picture. I really hope somebody here can help me ! Thank you so much for your time ! I have attached the files! UberGallery.php index.php index.php
  8. Hello PHP Freaks, I think this is just if else statement problem but im kinda lose to it. The whole code is succesful in deleting the data from database the problem is i wanted to put a script that remind the user if he/she really sure to delete the data. By the way this is the script. <?php // connect to the database include 'Connect.php'; // confirm that the 'student_id' variable has been set if (isset($_GET['student_id']) && is_numeric($_GET['student_id'])) { // get the 'student_id' variable from the URL $student_id = $_GET['student_id']; // delete record from database if ($stmt = $mysql->prepare("DELETE FROM student_information WHERE student_id = ? LIMIT 1")) { $stmt->bind_param("i",$student_id); $stmt->execute(); $stmt->close(); } else { echo "ERROR: could not prepare SQL statement."; } $mysql->close(); // redirect user after delete is successful header("Location: Admin_Home.php"); } else // if the 'student_id' variable isn't set, redirect the user { header("Location: Admin_Home.php"); } ?> Please help me modify these codes and where to put the missing line/s of codes.
  9. Hello PHP friends, With the help of 2 members here, namely Guru and Clarkey i manage to finalize the Search and this is part of the search.php codes. { $student_id = $row['student_id']; $searchResults .= "<tr>\n"; $searchResults .= " <td>{$row['LRN']}</td>\n"; $searchResults .= " <td>{$row['first_name']}</td>\n"; $searchResults .= " <td>{$row['last_name']}</td>\n"; $searchResults .= " <td>{$row['grade']}</td>\n"; $searchResults .= " <td>{$row['section']}</td>\n"; $searchResults .= " <td><a href='View_Profile.php?id={$student_id}'>View</a> </td>\n"; $searchResults .= " <td><a href='Admin_Edit_Student_Info.php?id={$student_id}'>Update</a></td>\n"; $searchResults .= " <td><a href='Delete.php?id={$student_id}'>Delete</a></td>\n"; $searchResults .= "</tr>\n"; } As we can see we have 3 target links here the VIEW/UPDATE/DELETE. My concern today is to create the Delete.php which if we are going to click the delete. The student selected will be deleted from the database. Thank you very much for reading. Please comment and never hesitate to give suggestions. By the way this is my present codes in connection, please comment and suggest here. //Connect to MySQL Server include 'Connect.php'; mysql_connect($host, $dbusername, $dbpassword); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Escape User Input to help prevent SQL Injection $first_name = mysql_real_escape_string(trim($_GET['first_name'])); // Retrieve data from Query $query = "SELECT * FROM student_information WHERE first_name LIKE '%{$first_name}%'"; $result = mysql_query($query) or die(mysql_error()); :-)
  10. Hey guys! Fairly new with PHP/MySQL and been working on a website for a class, and having some issues with my drop down not working as intended. What I'm trying to do is simply allow the user to select a name from a drop down field, then after pressing the submit button, would delete the selected name from the database. Here is my code. <?php ini_set('display_errors', 'on'); error_reporting(E_ALL); session_start(); $_SESSION['title'] = "PEC Menu"; //Opening Session Vars $currentFile = $_SERVER["PHP_SELF"]; //current page for menu $currentUser = $_SESSION['currentname']; // users account info include('../../functions/mainmenu.php'); // menu functions //Menu Content,Code / Buttons Goes here DrawMenu($currentFile, $currentUser); //Setting up database mysql_connect("localhost","root","changeme"); mysql_select_db("certestdb"); $dbLink = mysql_connect("localhost", "root", "changeme"); mysql_query("SET character_set_client=utf8", $dbLink); mysql_query("SET character_set_connection=utf8", $dbLink); $result = mysql_query("SELECT distinct TermID FROM clinical") or die(mysql_error()); $result2 = mysql_query("SELECT FullName FROM useraccess") or die(mysql_error()); $options=''; $options2=''; while($row=mysql_fetch_array($result)) { if (isset($_POST)) { $TermID=$row["TermID"]; $options.= '<option value="'.$row['TermID'].'">'.$row['TermID'].'</option>'; } }; while($row=mysql_fetch_array($result2)) { if (isset($_POST)) { $FullName=$row["FullName"]; $options2.= '<option value="'.$row['FullName'].'">'.$row['FullName'].'</option>'; } }; if (isset($_POST)) { mysql_query("DELETE FROM useraccess WHERE FullName='$FullName'") or die(mysql_error()); echo "Success!"; } else { echo "Not successful"; } ?> <html> <style> </style> <body> <h4> Add User</h4> <form name = "AddUser" action="PEC_addUser.php" method= "get" style = "text-align:right; color: Black;float:left;"> <input type="submit" value="Add User"> </form><br><br> <hr size = "5" color = "darkgray"> <h4> Assign User to Course</h4> <form name = "AssignUser" action=" " method= "get" style = "text-align:right; float:left; color: darkred;"> User: <select> </select> Course: <select> </select> Term: <SELECT NAME= termid> <OPTION VALUE=0>Choose</OPTION> <?php echo $options; ?> </select> <input type="submit" value="Assign"> </form> <br><br> <hr size = "5" color = "darkgray"> <h4> Assign Student to Instructor </h4> <form name = "AssignStudent" action=" " method= "get" style = "text-align:right; color: darkred;float:left;"> Student: <select> <option value = "Select"> Select</option>} <option value = "one"> 1</option>} <option value = "two"> 2</option>} <option value = "three"> 3</option>} </select> Course: <select> <option value = "Select"> Select</option>} <option value = "one"> 1</option>} <option value = "two"> 2</option>} <option value = "three"> 3</option>} </select> Instructor: <select> <option value = "Select"> Select</option>} <option value = "one"> 1</option>} <option value = "two"> 2</option>} <option value = "three"> 3</option>} </select> <input type="submit" value="Assign"> </form><br><br> <hr size = "5" color = "darkgray"> <h4> Delete User</h4> <form name = "DeleteUser" action=" " method= "get" style = "text-align:right; color: darkred;float:left;"> User: <SELECT NAME= FullName> <OPTION VALUE=0>Choose</OPTION> <?php echo $options2; ?> </select> <input type="submit" name="delete" value="delete"> </form><br><br> <hr size = "5" color = "darkgray"> <link rel="stylesheet" href="styles/pecui.css" media="screen" /> </body> </html> <?php ?> This is where the possible issue is if (isset($_POST)) { mysql_query("DELETE FROM useraccess WHERE FullName='$FullName'") or die(mysql_error()); echo "Success!"; } else { echo "Not successful"; } What happens is upon submitting, it just deletes the last 2 records in the table "useraccess" instead of the value selected from the drop down. I'm thinking that its not properly storing the data from the database, which is whats causing the query issue. If anyone could help me, it would be very much appreciated it.
  11. All I want to do is simply delete a record/row using ajax. For the life of me, I can't get it to work. I have tried many different methods and played around with them. Here is a basic example. Please do tell me what's wrong with it and how I can fix it. index.php <html> <head> <title>Home page</title> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script> $(document).ready(function() { $(function() { $(".del-action").click(function() { var commentContainer = $(this).parent(); var id = $(this).attr("id"); var string = 'id='+ id ; $.ajax({ type: "GET", url: "delete.php", data: string, cache: false, }); }); </script> </head> <body> <?php $get = DB::getInstance()->query("SELECT * FROM records WHERE record_id = 28 "); if(!$get->count()) { echo 'no record found!'; } else { foreach($get->results() as $row) { $record_id = $row->record_id; ?> <div class="record"> <a href="#" class="del-action" id="<?php echo $record_id; ?>" >Delete</a> </div> <?php } } ?> </body> </html> delete.php $record_id = intval($_GET['id']); $delete = DB::getInstance()->delete('records', array('record_id', '=', $record_id)); ps. it deletes the records fine without ajax/js. I just need help with the js code so that I can delete the record without redirecting or refreshing the page.
  12. I can't figure out what's wrong with this. The program works, but the duplication doesn't work. The error I get is : Notice: Undefined variable: SongToAdd in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 6\R.E.6-1_SongOrganizer.php on line 64 Notice: Undefined variable: ExistingSongs in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 6\R.E.6-1_SongOrganizer.php on line64 Warning: in_array() expects parameter 2 to be array, null given in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 6\R.E.6-1_SongOrganizer.php on line 64 Warning: fopen(SongOrganizer/songs.txt): failed to open stream: No such file or directory in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 6\R.E.6-1_SongOrganizer.php on line 72 There was an error saving your message! I bolded line 64 below, which is an if (in_array ) statement. line 64 is: if (in_array($SongToAdd, $ExistingSongs)) { echo "<p>The song you entered already exists!<br />\n"; echo "Your song was not added to the list.</p>"; } <?php if (isset($_GET['action'])) { if ((file_exists("SongOrganizer/songs.txt")) && (filesize("SongOrganizer/songs.txt") != 0)) { $SongArray = file("SongOrganizer/songs.txt"); switch ($_GET['action']) { case 'Remove Duplicates': $SongArray = array_unique($SongArray); $SongArray = array_values($SongArray); break; case 'Sort Ascending': sort($SongArray); break; case 'Shuffle': shuffle($SongArray); break; } // end of switch statement if (count($SongArray)>0) { $NewSongs = implode($SongArray); $SongStore = fopen("SongOrganizer/songs.txt", "wb"); if ($SongStore === false) echo "There was an error updating the song file\n"; else { fwrite($SongStore, $NewSongs); fclose($SongStore); } } else unlink("SongOrganizer/songs.txt"); } } if (isset($_POST['submit'])) { $SongToAdd = stripslashes($_POST['SongName']) . "\n"; $ExistingSongs = array(); if (file_exists("SongOrganizer/songs.txt") && filesize("SongOrganizer/songs.txt") > 0) { $ExistingSongs = file("SongOrganizer/songs.txt"); } } if (in_array($SongToAdd, $ExistingSongs)) { echo "<p>The song you entered already exists!<br />\n"; echo "Your song was not added to the list.</p>"; } else { $SongFile = fopen("SongOrganizer/songs.txt", "ab"); if ($SongFile === false) echo "There was an error saving your message!\n"; else { fwrite($SongFile, $SongToAdd); fclose($SongFile); echo "Your song has been added to the list.\n"; } } if ((!file_exists("SongOrganizer/songs.txt")) || (filesize("SongOrganizer/songs.txt") == 0)) echo "<p>There are no songs in the list.</p>\n"; else { $SongArray = file("SongOrganizer/songs.txt"); echo "<table border=\"1\" width=\"100%\" style=\"background-color:lightgray\">\n"; foreach ($SongArray as $Song) { echo "<tr>\n"; echo "<td>" . htmlentities($Song) . "</td>"; echo "</tr>\n"; } echo "</table>"; } ?> <!-- Display hyperlinks for the three functions in the switch statement (Sort Ascending, Remove Duplicates, and Shuffle) --> <p> <a href="SongOrganizer.php?action=Sort%20Ascending">Sort Song List</a><br /> <a href="SongOrganizer.php?action= Remove%20Duplicates">Remove Duplicate Songs</a><br /> <a href="SongOrganizer.php?action=Shuffle"> Randomize Song List</a><br /> </p> <!-- web form for entering new song names into the song list: --> <form action="SongOrganizer.php" method="post"> <p>Add a New Song</p> <p>Song Name: <input type="text" name="SongName" /></p> <p><input type="submit" name="submit" value="Add Song to List" /> <input type="reset" name="reset" value="Reset Song Name" /></p> </form> Any help would be appreciated!
  13. I am trying to have a js alert box to confirm before deleting a record. Here is the js code. <script> function confirmation() { var answer = confirm("Are you sure?") if (answer){ alert("This record been deleted!") } else{ alert("Not deleted!") } } </script> php code. <a href="delete.php" onclick="confirmation()">Delete record</a> The problem is, even if i click no in the js alert box and the message shows("Not deleted!"), it still deletes the record. Why is it doing that? My second question is, is it possible to css the js alert box? I need to customize it to my own look.
  14. So here I was trying mkdir function with 0777 permissions. Everything worked fine. However when it came to delete the images in the directory, it won't let me. I have a 404 error page set up and it takes me to that page after i click delete. I had a backup of the this project before i added mkdir. So I went back to it and it's still taking me to the 404 error when deleting an image. While on 404 page; in the address bar, it's still shows the id of the file to be deleted. For eg. http://localhost/project/delete.php?id=199 Can someone explain to me what is going on?
  15. Hi guys. I have following code to delete particular row from a table based on the title. But how can I delete all data from the table? <?php require 'connpdo.php'; $naslov = $_POST['naslov']; #DELETE DATA //delete some data $sqlInsert = 'DELETE FROM bloging WHERE title=:title'; $preparedStatement = $conn->prepare($sqlInsert); $preparedStatement->execute(array(':title' => $naslov)); //REDIRECT TO HOME PAGE header('Location: http://localhost/ITAPHP/index.php'); ?> So I would need something which would say DELETE * FROM bloging...Basically I have this table bloging with 3 fields id, title and text, and above code will identify specific post based on the title and delete that particular post. But I need button to delete all posts, to empty table. Thank you in advance!
  16. I can't seem to get reliable results after deleting a row(s) using mysqli. The afftect_rows is always 0. I'm using php5.2 and the mysqli method Something like this: $sql = " DELETE FROM classRoster WHERE id=123 "; if ($result = $this->mysqli->query($sql)) { return $this->mysqli->affected_rows; ///ALWAYS RETURNS 0 }else{ //log error } I have confirmed that the row is in fact deleted, but still get 0 as affected_rows. Please help!
  17. Hi I'm working in a project and I just finished the pagination system (in every page 2 results) but my problem is that I want to add some options beside every result.For example I have to resut which are (john,katy)I want them to be like this : John (Edit) (Delete) Katy (Edit) (Delete) This is my code : <?php include("wasata/inc/config.php"); mysql_query('SET NAMES "UTF-8"'); if(!isset($_GET['page'])){ $page = 1; }else{ $page = (int) $_GET['page']; $records_at_page = 2; $q = mysql_query('SELECT * FROM serv'); $records_count = @mysql_num_rows($q); @mysql_free_result($q); $page_count = (int) ceil($records_count / $records_at_page); if(($page > $page_count) || ($page <= 0)){ mysql_close($con); die('No More Pages'); } $start = ($page - 1) * $records_at_page; $end = $records_at_page; if($records_at_page != 0){ $q = mysql_query("SELECT * FROM serv ORDER BY id ASC LIMIT $start,$end"); while($o = mysql_fetch_object($q)){ echo $o->title .'<br />'; } } echo '<br />'; for($i = 1; $i<= $page_count; $i++){ if($page == $i){ echo $page; }else{ echo '<a href="m.php?page=' .$i . '">' .$i . '</a>'; if($i != $page_count){ echo ' - '; } } } } mysql_close($con); ?> So can any one Help please.
  18. hi ive been trying to sort this out all day, im very inexperianced in php but really want to do well in it and at the moment ive got a table working linked to a database and which pulls records but now i want to get an update and delete button but i cant seem to hack it heres the code. <?php $con = mysqli_connect("localhost","root","","lcm"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } //updates table. if (isset($_POST['update'])){; $UpdateQuery = "UPDATE tbl_contactinfo SET Name='$_POST[Name]', Address='$_POST[Address]' WHERE Name='$_POST[hidden]'"; mysql_query($UpdateQuery, $con); } if (isset($_POST['delete'])){; $DeleteQuery = "DELETE FROM tbl_contactinfo WHERE Name='$_POST[hidden]'"; mysql_query($DeleteQuery, $con); } //selects the table. $sql = "Select * from tbl_contactinfo"; if ($result = mysqli_query($con, $sql)) { echo "<table border='1'> <tr> <th>Name</th> <th>Address</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo '<form action="index1.php" method="post">'; echo '<tr>'; echo '<td><input type="text" name="name" value="' . $row['Name'] . '" /></td>'; echo '<td><input type="text" name="address" value="' . $row['Address'] . '" /></td>'; echo '<td><input type="hidden" name="hidden" value="' . $row['ID'] . '" /></td>'; echo '<td><input type="submit" name="update" value="update" /></td>'; echo '<td><input type="submit" name="delete" value="delete" /></td>'; echo '</tr>'; echo '</form>'; } echo "</table>"; } ?> <html> <body> <form action="insert.php" method="post"> Name: <input type="text" name="Name"> Address: <input type="text" name="Address"> <input type="submit"> </form> </body> </html> and error messages ive been getting. ( ! ) Notice: Undefined index: Name in C:\wamp\www\Index1.php on line 12 Call Stack # Time Memory Function Location 1 0.0000 147208 {main}( ) ..\Index1.php:0 ( ! ) Notice: Undefined index: Address in C:\wamp\www\Index1.php on line 12 Call Stack # Time Memory Function Location 1 0.0000 147208 {main}( ) ..\Index1.php:0 ( ! ) Warning: mysql_query() expects parameter 2 to be resource, object given in C:\wamp\www\Index1.php on line 13 Call Stack # Time Memory Function Location 1 0.0000 147208 {main}( ) ..\Index1.php:0 2 0.1562 154608 mysql_query ( ) ..\Index1.php:13 these are for update and for delete ( ! ) Warning: mysql_query() expects parameter 2 to be resource, object given in C:\wamp\www\Index1.php on line 18 Call Stack # Time Memory Function Location 1 0.0000 147208 {main}( ) ..\Index1.php:0 2 0.1406 154456 mysql_query ( ) ..\Index1.php:18 ive stoped the error messages before dont no how i did it but they wernt showing, only problem is when i pressed them nothing happened any help will be great.
  19. <html> <head> <meta charset="iso-8859-1" /> <title> Hjem </title> </head> <body> <?php include 'config.php'; session_start(); if(!session_is_registered(mitbrugernavn)){ ?> <form action="tjek.php" method="post"> Brugernavn: <input type="text" name="mitbrugernavn"> </p> Kodeord: <input type="password" name="mitkodeord"> </p> <input type="submit" value="Login"> </form> <?php } else { ?> </p> Du er nu logget ind! Velkommen <? print $_SESSION['mitbrugernavn']; ?> </p> <li> <a href="logout.php"> Log ud </a> </li> </p> <li> <a href="opret.php"> Opret ny konto </a> </li> <li> <a href="medlemmer.php">Oprettede kontoer</a> </li> </p> <? $con = mysql_connect("localhost","HIDDEN","HIDDEN"); if (!$con) { die('Kunne ikke tilslutte: ' . mysql_error()); } mysql_select_db("HIDDEN", $con); $result = mysql_query("select count(*) FROM medlemmer"); $row = mysql_fetch_array($result); $total = $row[0]; echo "Antal medlemmer: " . $total; } ?> </p> </p> <?php $aktion= $_GET['action']; if($aktion == "slet"){ mysql_query("DELETE FROM news WHERE name=$nName"); echo "Nyheden er nu slettet"; echo ('<meta http-equiv="refresh" content="3;url=tilfoj-nyheder.php">'); } else { echo "Kunne ikke slette nyheden"; } $loadNews = mysql_query("SELECT * FROM news ORDER BY id DESC") or die(mysql_error()); if(mysql_num_rows($loadNews) == 0) { echo "Der er ikke blevet tilføjet nogle nyheder."; } else { while($showNews = mysql_fetch_array($loadNews)) { $nName = stripslashes($showNews["name"]); $nAuthor = stripslashes($showNews["author"]); $nText = nl2br(stripslashes($showNews["text"])); $nDate = $showNews["date"]; ?> <div> <div align="center" style="border-style:solid; margin:3px; width:400px; height:auto;"> <b> <?php print "$nName"; ?> </b><br /> <i>Skrevet af <? print "$nAuthor ,"; ?> d. <?php print "$nDate"; ?> </i><br /> <? print "$nText"; ?> <br /><br /> </div> </br> <? if(session_is_registered(mitbrugernavn)){ ?> <form action='?action=slet' method="POST"> <input type="submit" value="slet"> </form> <? } ?> </div> <? } } if(session_is_registered(mitbrugernavn)){ echo "<a href=\"tilfoj-nyheder.php\" title=\"Tilføj nyhed\">Tilføj nyhed</a>"; } ?> </body> </html> Hello! I am trying to make a delete button for my news, but I have no idea how it works. The code for the button starts at line 68. PS. Im new here correct me if posting this wrong! Thanks in advance!
  20. Please look at the table data carefully. I need to delete the rows. I need urgent help..!! PFA...!! Table: CREATE TABLE IF NOT EXISTS `version` ( `nidt` varchar(11) NOT NULL, `noeud` tinyint(3) NOT NULL, `VERSION` float NOT NULL, `ETAT_FONCT` varchar(20) default NULL, `idnap` varchar(25) NOT NULL, `nidtint` bigint(20) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; For SAME nidt & SAME noeud, i would like to DELETE rows based on two condition: 1. If ETAT_FONCT = "OPERATIONAL" Delete REST ROWS EXCEPT HIGHEST Version 2. If ETAT_FONCT != "OPERATIONAL" DELETE Older verions Thanks in advanced for input. :)
  21. hi all , I have a table that shows all rows of a selected table . problem is that I want to delete marked rows from this table but this code is not working for me . updating code works fine but I can't delete selected rows . <? if($_SESSION["count"]!=0){ ?> <!-- begining of setting levels informations --> <form name="form2" method="POST" dir="rtl" action="" style="font-family:'B_yekan';"> <input name="level" type="hidden" value="<? if(isset($_POST['level'])){ echo $_POST['level'];} ?>"/> <div align="center" width = 615> <table class="styled-table" cellspacing="0" width="800" border="1"> <tr> <th width="10" scope="col" ></th> <th width="60" scope="col">level</th> <th width="60" scope="col">time</th> <th width="60" scope="col">date</th> <th width="42" scope="col">status</th> <th width="54" scope="col">price</th> <th width="42" scope="col">off</th> <th width="54" scope="col">off 2</th> <th width="60" scope="col">mark</th> </tr> <?php $id = array(); while($rows=mysql_fetch_array($result)){ $id[]=$rows['id']; ?> <tr> <td align="center"><input class="styled-input" type="hidden" name="id[]" id="id" value= "<? echo $rows['id']; ?>" /></td> <td align="center"><input class="styled-input" type="lev" name="lev" id="lev" value="<? echo $tbl_name; ?>" /></td> <td align="center"><input class="styled-input" type="text" name="time[]" id="time" value= "<? echo $rows['time']; ?>" /></td> <td align="center"><select class="styled-input" type="text" name="date[]" id="date" /> <option selected="selected" value="<? if($rows['date']=="1"){echo "1";}else{echo "0";}?>"> <? if($rows['date']=="1"){echo "even";}else{echo "odd";}?></option> <option value="<? if($rows['date']=="1"){echo "0";}else{echo "1";}?>"> <? if($rows['date']=="1"){echo "odd";}else{echo "even";}?></option> </select></td> <td align="center"><select class="styled-input" type="text" name="act[]" id="act" > <option selected="selected" value="<? if($rows['act']==1){echo "1";}else{echo "0";}?>"> <? if($rows['act']==1){echo "enable";}else{echo "disable";}?></option> <option value="<? if($rows['act']==1){echo "0";}else{echo "1";}?>"> <? if($rows['act']==1){echo "disable";}else{echo "enable";}?></option> </select></td> <td align="center"><input class="styled-input" type="text" name="price[]" id="price" value= "<? echo $rows['price']; ?>" /></td> <td align="center"><input class="styled-input" type="text" name="offprice[]" id="offprice" value= "<? echo $rows['offprice']; ?>" /></td> <td align="center"><input class="styled-input" type="text" name="off2price[]" id="off2price" value= "<? echo $rows['off2price']; ?>" /></td> <td align="center"><input class="styled-input" style="padding: 5px;width:20px" type="checkbox" name="checkbox[]" id="checkbox[]" /></td> </tr> <?php }//end of loop ?> </table> </div> <input class="styled-button-8" type="Submit" value="submit" name="Submit" /> <input class="styled-button-8" type="Submit" value="delete" name="delete" /> <?php }//end of if ?> </form> <?php // Check if button name "Submit" is active, do this if(isset($_POST['Submit']) && $_POST['Submit'] == 'submit') { for($i=0;$i<$_SESSION["count"];$i++) { $sql1="UPDATE `".$tbl_name."` SET `time`='".$_REQUEST['time'][$i]."',`date`='".$_REQUEST['date'][$i]."',`act`='".$_REQUEST['act'][$i]."' , `price`='".$_REQUEST['price'][$i]."' , `offprice`='".$_REQUEST['offprice'][$i]."', `off2price`='".$_REQUEST['off2price'][$i]."' WHERE `id`='".$_REQUEST['id'][$i]."' "; $result1=mysql_query($sql1); } if(isset($result1)){ $_SESSION["count"]=""; ?> <script language="javascript">alert('all of the rows updated successfully');</script> <?php print(redirect('regmanage.php')); } ?> <!-- deleteing records --> <?php // Check if button name "Submit" is active, do this if(isset($_POST['delete']) && $_POST['delete'] == 'delete') { for($i=0;$i<$_SESSION["count"];$i++) { if(isset($_POST['checkbox'][$i])){ $del_id = $_POST['checkbox'][$i]; $sql1 = "DELETE FROM `".$tbl_name."` WHERE `id`='".$_REQUEST['id'][$i]."' "; $result1= mysql_query($sq1) or die(mysql_error()); } } } if(isset($result1)){ ?> <script language="javascript">alert('the selected row deleted successfully.');</script> <?php print(redirect('regmanage.php')); } ?> <!-- end of setting infromations -->
  22. I am trying to write a script on a hidden page to delete images in my gallery(I am not using databases). I tried writing this code(to delete both the icon and large version of the image) but it failed. What did I do wrong? <?php if (array_key_exists('delete_file', $_POST)) { $filename = $_POST['delete_file']; if (file_exists($filename)) { unlink($filename); echo 'File '.$filename.' has been deleted'; } else { echo 'Could not delete '.$filename.', file does not exist'; } } $large = glob("/images/main/large/*"); $icons = glob("/images/main/icons/*"); foreach($large as $lrg && $icons as $icon) { echo "<div class='divimages'>"; echo '<img src="'.$lrg.'"/><br>'; echo '<img src="'.$icon.'"/>'; echo '<form method="post">'; echo '<input type="hidden" value="'.$lrg.'" name="delete_file" />'; echo '<input type="hidden" value="'.$icon.'" name="delete_file" />'; echo '<input type="submit" value="Delete image" />'; echo '</form>'; echo "</div>"; } ?>
  23. I have a problem when i Click the Edit button int he form, the database doesn't update, In the beginning i thought i had a problem with the query, but I did a check as a query and everything was fine. Can someone suggest something please. //this is the file - album.func.php function edit_album($album_id, $album_name, $album_description) { $album_id = ((int)$album_id); $album_name = mysql_real_escape_string($album_name); $album_description = mysql_real_escape_string($album_description); mysql_query("UPDATE `albums` SET `name`='$album_name', `description`='$album_description' WHERE `album_id`='$album_id' AND `user_id`=".$_SESSION["user_id"]); } //this is the file - edit_album.php if (!empty($errors)) { foreach ($errors as $error) echo $error; }else { edit_album($album_id, $album_name, $album_description); header('Location: index.php'); exit(); }} ?> <?php $album_id = $_GET["album_id"]; $album_data = album_data($album_id, 'name', 'description'); ?> //this is the form <form action="?album_id=<?php echo $album_id; ?>" method="post"> <p>Name:</br><input type="text" name="album_name" maxlength="55" value="<?php echo $album_data["name"]; ?>"/></p> <p>Description:</br><textarea name="album_description" rows="6" cols="35" maxlength="500"><?php echo $album_data["description"]; ?>
  24. If i hit Edit button i got these error before i click Submit <? if ($_GET['do'] == 'test2') { $id = ($_POST['id']); $username = cleanuserinput($_POST['username']); $password = cleanuserinput($_POST['password']); $rpassword = cleanuserinput($_POST['rpassword']); $pass = md5($_POST['password']); if(isset($_POST['delete'])){ mysql_query("delete from admin where id='".$id."'"); print '<center><font color=black>Admin has been deleted!</font><br>'; } if(isset($_POST['edit'])){ //Make sure username isn't blank if (!$username){ $error .= '<font color=red>Sorry, the username was empty.</font><br>'; } //Make sure password isn't blank if (!$password){ $error .= '<font color=red>Sorry, your password was empty.</font><br>'; } //Make sure both passwords match if ($password != $rpassword) { $error .= '<font color=red>Passwords Doesn\'t Match!</font><br>'; } //Check username length if (!ctype_alnum($username) || strlen($username) < 4 || strlen($username) > 15) { $error .= '<font color=red>Username must be between 4-15 characters!</font><br>'; } //Check password length if (!ctype_alnum($password) || strlen($password) < 4 || strlen($password) > 15) { $error .= '<font color=red>Password must be between 4-15 characters.</font><br>'; } if (!$error){ $sql_update = "UPDATE admin set username = '$username', password= '$pass' where id='".$id."'"; $result = mysql_query ($sql_update) or die(mysql_error()); print "<center><font color=black>User ". $_POST['username'] ." Has been edited.</font><br>"; } $get_admin = mysql_query("select * from admin where id='".$id."'"); $admin = mysql_fetch_array($get_admin); echo $error . "<form action='?do=test2' method='post'> <table> <tr><th colspan=20>Edit Admin</th></tr> <tr><td><b>Username<font color=red>*</font></b></td><td><div><small>[ 4-15 characters ]</small></div><input name='username' type='text' maxlength='50' size='25' tabindex='1' value='".$admin['username']."'></td></tr> <tr><td><b>Password<font color=red>*</font></b></td><td><div><small>[ 4-15 characters ]</small></div><input name='password' type='text' maxlength='50' size='25' tabindex='2' value=''></td></tr> <tr><td><b>Password 2<font color=red>*</font></b></td><td><input name='rpassword' type='text' maxlength='50' size='25' tabindex='3' value=''></td></tr> </table> <input type=hidden name=id value='".$admin['id']."'> <div align='center'><br><input type='submit' name='submit' tabindex='4' value='Submit'></div> </form>"; } else { print" <table width=90%> <tr><th colspan=20>Current Admin</th></tr> <td>Admin Name</td> <td>Added Date</td> <td align=center>Action</td>"; $get_admin = mysql_query("select * from admin "); while ($row = mysql_fetch_array($get_admin)){ print " <tr> <td>". $row['username'] ."</td> <td>". $row['date'] ."</td> <td align=center> <form method=POST> <input name=id type=hidden value='".$row['id']."'> <input type=submit name=edit value='Edit'> <input type=submit name=delete value='Delete'> </td> </form> </tr>"; } print "</table>"; } } else { admin_wrong_file(); } ?>
  25. I have the following code below. I have added buttons to each entry that pops up but I need the buttons to do certain things and I'm stuck. When the Approve button is pressed I want the entire entry to go to another table called "incomplete" (no quotations) and then I want the record to be deleted from the table "needs" (no quotations), which it currently resides in. When the Deny button is pushed I want the entry to just be deleted from the table "needs" (no quotations). Tried to figure it out on my own but I have nothing. I'm new to all this and the fact that I've gotten this far makes me excited :-) $query = mysql_query("SELECT * FROM needs"); while ($rows = mysql_fetch_array($query)): $firstname = $rows['firstname']; $lastname = $rows['lastname']; $address = $rows['address']; $city = $rows['city']; $state = $rows['state']; $phone = $rows['phone']; $email = $rows['email']; $typeofneed = $rows['typeofneed']; echo "$firstname $lastname<br>$address<br>$city $state<br>$phone<br>$email<br>$typeofneed<br>"; echo "<button name='approve' type='button'>Approve</button><button name='deny' type='button'>Deny</button><br>---------------------------<br>"; endwhile;
  • 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.