?
Solved

Delete, Add or Edit Records

Posted on 2015-01-25
4
Medium Priority
?
124 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 1000 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

770 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