Solved

Delete, Add or Edit Records

Posted on 2015-01-25
4
106 Views
Last Modified: 2015-01-26
I have a table that displays records.

http://www.mediascrubber.com/records.php

How can I make this page interactive to add, edit and delete records.
Thank you.
0
Comment
Question by:DS928
4 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 250 total points
ID: 40570043
Well, start using php only (next you'll can add javascript and do all stuff via Ajax).
- Add a lat column and call it 'Actions
- Set its colspan to 3 (<th colspan="3">Actions</th>)
- Put here two links to two php scripts edit.php and delete.php adding them a querystring to identify the record:
while($row = $result->fetch_assoc()) {
				echo "<tr class='viewpost'>";
  			if(!empty($row['recordId'])) {
      			echo '<td>' . $row['recordId'] . '</td>';
    			}
					else
					{
      			echo '<td>NA</td>';
					}
                                  ....
                         echo "<td>
                                         <a href='edit.php?id=". $row['recordId'] ."'>Edit</a> 
                                         <a href='delete.php?id=". $row['recordId'] ."'>Delete</a> 
                                   </td>"
					echo "</tr>"; //closing row
				}
  			echo '</tbody>';
  			echo '</table>';

Open in new window

In the scripts you get the id of the record diplay a form to edit fields and/or execute the action, then redirect the user to the original script.
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 40570313
The general design of what you want to do is called "table maintenance."  Some of the design principles are shown in this article.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12335-PHP-and-MySQLi-Table-Maintenance.html
0
 
LVL 6

Expert Comment

by:Leon Teale
ID: 40570686
if you are wanting jsut the base of the code then please see here
<?PHP

$user_name = "root";
$password = "";
$database = "addressbook";
$server = "127.0.0.1";

$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);

if ($db_found) {

$SQL = "INSERT INTO tb_address_book (First_Name, Surname, Address) VALUES ('bill', 'gates', 'Microsoft')";

$result = mysql_query($SQL);

mysql_close($db_handle);

print "Records added to the database";

}
else {

print "Database NOT Found ";
mysql_close($db_handle);

}

?>

Open in new window



else if you are wanting explanations then see the other comments. i just wasnt sure what sort of answer you needed.
0
 

Author Closing Comment

by:DS928
ID: 40570895
Thank you everyone.  I appreciate the help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now