How to Retrieve Records
This is a discussion on How to Retrieve Records within the MySQL forums, part of the Database category; We have developed a database which has millions of records stored in it. One user has wrongly deleted some of ...
-
How to Retrieve Records
We have developed a database which has millions of records stored in it. One user has wrongly deleted some of the records yesterday. We want to retrieve those deleted records. Kindly suggest some way for getting back those deleted records.
-
You have not mentioned about you backup process. How frequently you take backup and what is the method or process you follow for backup procedure. Only when you give detailed explanation on these I could give a solution for this. This is because without proper backup it is impossible to get the deleted records of your database.
-
04-23-2011, 01:29 PM #3
- Join Date
- Apr 2011
- Location
- Frisco Colorado real estate
- Answers
- 1
Will assume database name is test. Table is myUsers. Date field is bday. Will display matching records from the fields first_name and last_name.
Code:<?php if (isset ($_POST['bday'])) { // *** Data was submitted so get records. // *** Assign user date to variable. $userSuppliedDate = $_POST['bday']; // *** Verify the date is a date and properly formed. $aDate_parts = preg_split("/[\s-]+/", $userSuppliedDate); $year = $aDate_parts[0]; $day = $aDate_parts[2]; $month = $aDate_parts[1]; $isDate = checkdate ($month, $day, $year); if ($isDate) { // *** Connect to database or quit. $con = mysql_connect("localhost", "dbuser", "password"); // *** Select database. mysql_select_db("test", $con); // *** Build and excecute the SQL to retrieve the record list. $sql = "SELECT * FROM myUsers WHERE bday = '$year-$month-$day' "; $result = mysql_query($sql, $con); if (!$result) { // *** Error getting records. Inform user. $bDayList = "<p><b>ERROR:</b> Could not get record list.</p>"; } else { if (mysql_num_rows ($result) > 0) { // *** Results returned so build the list. $bDayList = "Records matching $userSuppliedDate<ul>"; while ($bday = mysql_fetch_array($result)) { $bDayList .= "<li>" . $bday["first_name"] . " " . $bday["last_name"] . "</li>"; } $bDayList .= "</ul>"; } else { // *** No results found. Inform user. $bDayList = "<p>No records matching $userSuppliedDate were found."; } } echo("$bDayList"); } else { echo("The supplied date, $userSuppliedDate, is either not a valid date or not in the form of YYYY-MM-DD."); } } ?> <p>Enter the date of your Birthday (YYYY-MM-DD)</p> <form action="" method="POST"> <p><input type="text" name="bday"></p> <p><input type="submit" name="cmdSubmit" value="Submit" /></p> </form>
Last edited by admin; 04-23-2011 at 11:36 PM.
-
Sponsored Ads


Reply With Quote





