Basic PHP System: View/Edit/Delete/Add Records
#61
Posted 04 October 2011 - 09:27 AM
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
#62
Posted 09 October 2011 - 02:04 AM
#63
Posted 10 October 2011 - 01:35 AM
Ben, on 04 October 2011 - 09:27 AM, said:
Hi Ben,
THANKS FOR YOUR REPLY...
what and how much portion is to be removed?? plz be specific... i am newbie... when i remove if loop it gives me blank page when i click on edit.... or tell me what is to be written in place of is_numeric... if i want user to be enter characters only..
P.S i removed
if (isset($_POST['submit']))
{
// confirm that the 'id' value is a valid integer before getting the form data
if (is_string($_POST['signum']))
{
// get form data, making sure it is valid
$signum =$_POST['signum'];
$name = mysql_real_escape_string(htmlspecialchars($_POST['name']));
$emp_id = mysql_real_escape_string(htmlspecialchars($_POST['emp_id']));
// check that firstname/lastname fields are both filled in
if ($name == '' || $emp_id == '')
{
// generate error message
$error = 'ERROR: Please fill in all required fields!';
//error, display form
renderForm($signum, $name, $emp_id, $error);
}
else
{
// save the data to the database
mysql_query("UPDATE EMP SET name='$name', emp_id='$emp_id' WHERE signum='$signum'")
or die(mysql_error());
// once saved, redirect back to the view page
header("Location: view.php");
}
}
else
{
// if the 'id' isn't valid, display an error
echo 'Error!';
}
}
PLEASE EDIT THE SCRIPT FOR ME AND PASTE IT OVER HERE IF POSSIBLE...
#64
Posted 10 October 2011 - 09:50 AM
I'm trying to create a dynamic table based on your example where the only real difference is that I want to have a different kind of PRIMARY KEY. In other words I want my site visitors to be able to see and edit the primary key which will be in text form (varchar). What kind of changes should I do in the code?
Thanks again
Albersson
#65
Posted 11 October 2011 - 02:23 AM
Ben, on 04 October 2011 - 09:27 AM, said:
Thankyou Thankyou Thankyou... i am done with it.. thanks alot Ben... :*
#67
Posted 16 October 2011 - 06:38 AM
jiroh, on 16 October 2011 - 04:27 AM, said:
The system uses a MySQL database.
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
#68
Posted 15 November 2011 - 05:55 AM
i have some other questions?
how to view only one row data?
Example:- Add a VIEW link after EDIT and DELETE. when click on view show only that id values. (with code) thanks
#69
Posted 15 November 2011 - 11:11 AM
cool, on 15 November 2011 - 02:55 AM, said:
i have some other questions?
how to view only one row data?
Example:- Add a VIEW link after EDIT and DELETE. when click on view show only that id values. (with code) thanks
It would be nearly identical to the edit.php page, except that you wouldn't need to put the record's values in a form for editing purposes, and you won't need code to process the form and update the record.
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
#71
Posted 05 December 2011 - 03:16 PM
Am a beginner in PHP. I have question, If the table(in the above post it is players) is to be selected from the database(for ex:technologies). Then i need a solution where user select from the different tables and that table is displayed. Please help....
#72
Posted 06 December 2011 - 11:36 AM
Rijesh, on 05 December 2011 - 12:16 PM, said:
Am a beginner in PHP. I have question, If the table(in the above post it is players) is to be selected from the database(for ex:technologies). Then i need a solution where user select from the different tables and that table is displayed. Please help....
I think you'll need to explain what you need a bit more before I can help you.
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
#73
Posted 07 December 2011 - 11:51 PM
#74
Posted 08 December 2011 - 12:34 AM
prajakta, on 07 December 2011 - 08:51 PM, said:
Yes. Create a new topic and post your question/the code you are working with.
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
#75
Posted 08 December 2011 - 05:06 AM
Ben, on 08 December 2011 - 11:04 AM, said:
i have crated nw topic as u said ben...but m nt getting proper respons..u pls take a luk at that topic...else just suggest me simple editing code for drop down list.its very urgent
#77
Posted 15 December 2011 - 05:13 PM
DELETE FROM content WHERE id_number=$id_number
in delete.php file ($id_number is the row in my custom database so had to change it), it shows different error each time. Right now if I have it like that then I get an error saying
Quote
But then If I change mysql_query to
DELETE FROM content WHERE id_number='$id_number'
then it will not delete that file but will redirect me to listed location. Would you please help me figure out the problem?
Here is the whole delete.php here if you need to go through it:
<?php
/*
DELETE.PHP
Deletes a specific entry from the 'content' table
*/
// connect to the database
include('connect-db.php');
// check if the 'id' variable is set in URL, and check that it is valid
if (isset($_GET['id_number']) && is_numeric($_GET['id_number']))
{
// get id value
$id = $_GET['id_number'];
// delete the entry
$result = mysql_query("DELETE FROM content WHERE id_number='$id_number'")
or die(mysql_error());
// redirect back to the view page
header("Location: view-paginated.php?page=4");
}
else
// if id isn't set, or isn't valid, redirect back to view page
{
header("Location: view-paginated.php?page=4");
}
?>Thank you in advance Mr. Falk.
#78
Posted 16 December 2011 - 03:33 PM
DELETE FROM content WHERE id_number='$id_number'
Things to double check though:
-- Do you have a "content" table in the database?
-- Do you have an "id_field" column in that database? (and if so, is it spelled differently? "ID_field" for example)
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
#79
Posted 22 December 2011 - 06:30 PM
I have a question, what does the function renderForm do?
#80
Posted 23 December 2011 - 11:20 PM
JotGill, on 15 December 2011 - 05:13 PM, said:
DELETE FROM content WHERE id_number=$id_number
in delete.php file ($id_number is the row in my custom database so had to change it), it shows different error each time. Right now if I have it like that then I get an error saying
But then If I change mysql_query to
DELETE FROM content WHERE id_number='$id_number'
then it will not delete that file but will redirect me to listed location. Would you please help me figure out the problem?
Here is the whole delete.php here if you need to go through it:
<?php
/*
DELETE.PHP
Deletes a specific entry from the 'content' table
*/
// connect to the database
include('connect-db.php');
// check if the 'id' variable is set in URL, and check that it is valid
if (isset($_GET['id_number']) && is_numeric($_GET['id_number']))
{
// get id value
$id = $_GET['id_number'];
// delete the entry
$result = mysql_query("DELETE FROM content WHERE id_number='$id_number'")
or die(mysql_error());
// redirect back to the view page
header("Location: view-paginated.php?page=4");
}
else
// if id isn't set, or isn't valid, redirect back to view page
{
header("Location: view-paginated.php?page=4");
}
?>Thank you in advance Mr. Falk.
I don't actually see $id_number defined in your code on that file. Are you sure you don't mean $id instead? Because I see:
$id = $_GET['id'];
#81
Posted 16 January 2012 - 04:51 AM
I started php few days ago.
thanks for this simple php script.
i will try to add more options like catagory,views.
#82 Guest_Danish
Posted 17 January 2012 - 12:55 AM
Great work i am really impress with your work. This should help those wishing to learn some php. It is also a good start to the Admin side of small applications.
#83
Posted 19 January 2012 - 07:40 AM
1)Check/Uncheck all checkboxes based on one check box to delete multiple records and press the delete button (I mean only one button).
2)Check on the checkbox to select the record you want to update and press the update button (I mean only one button).
#84
Posted 06 February 2012 - 09:36 PM
however, I would like if possible to help me with something extra, I modified the instructions mysql and have adapted to an application with foreign keys in innodb table,
Using innodb table, the update is not working, I've checked the code from the bottom up and top to bottom, the only thing that I changed are the mysql instructions, which operate under mysqlworbench.
I know the topic is not about databases, or types of tables, but please could you help me telling me if the official application with innodb tables?
I get the error: "/ / if the 'id' in the URL is not valid, or if there is no 'id' value, display an error"
There is a difference between the auto increment field in a table myisam / innodb?
Or is it that I delete something in the code that I can see ?
Thank you very much for your time and reading my question / case.
#85
Posted 08 February 2012 - 08:58 PM
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
#86
Posted 09 February 2012 - 01:15 PM
I have a question though, users. How could you bridge this with something lets say joomla (only because thats my next everest
I have actually made this script able to put new users into joomla, using only this script! Thankyou!
Thanks again
Karlos
#87
Posted 16 February 2012 - 04:59 AM
Dear Friend This was an awesome tutorial which I have used to create a database system .
There I have a problem ?? Please see attachment!!
I want to edit the "feedback" field without leaving the view page. I want to edit on preview table. How can I do that. I have modify your code look like that ....
<?php
require_once('auth.php');
?>
<!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=iso-8859-1" />
<title>Member Index</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<center>
<img src="./images/sonali.jpg" height="100px" width="100px"/>
</center>
<div align="center">
<p> <h1> Welcome TO Sonali Bank Limited</h1><br />
<h2><?php echo $_SESSION['SESS_FIRST_NAME'];?></h2>
<h2><?php echo $_SESSION['SESS_LAST_NAME'];?></h2>
<h3>BRANCH CODE : <?php echo $_SESSION['SESS_MEMBER_LOGIN'];?></h3>
</div>
<p><a href="member-profile.php">My Profile</a> | <a href="logout.php">Logout</a> | <a href="user-view-admin.php">View ALL</a> | <a href="user-view-paginated.php">View Paginated</a></p>
<?php
//This code is for SONALI BANK ONLY
// connect to the database
include('user-connect-db.php');
include('config.php');
//check user name
// get the records from the database
if ($result = $mysqli->query("SELECT * FROM sblnrat WHERE brcode = $_SESSION[SESS_MEMBER_LOGIN] Order by id"))
{
// display records if there are records to display
if ($result->num_rows > 0)
{
// display records in a table
echo "<table align='center' border='1' cellpadding='10'>";
// set table headers
echo "<tr><th>SL</th><th>PON</th><th>TRA NO.</th><th>TRA DT</th><th>BR-CODE</th><th>BR-NAME</th><th>BF-NAME</th><th>BF-A/C</th><th>AMT</th><th>Feed Back</th></tr>";
while ($row = $result->fetch_object())
{
// set up a row for each record
echo "<tr>";
echo "<td>" . $row->id . "</td>";
echo "<td>" . $row->pon . "</td>";
echo "<td>" . $row->trano . "</td>";
echo "<td>" . $row->tradt . "</td>";
echo "<td>" . $row->brcode . "</td>";
echo "<td>" . $row->brname . "</td>";
echo "<td>" . $row->bfname . "</td>";
echo "<td>" . $row->bfac . "</td>";
echo "<td>" . $row->amt . "</td>";
echo "<td>" . $row->feedback . "</td>";
echo "<td>".'
<form action="insert.php?id='. $row->id . '" method="post">
<select name="feedback">
<option selected="selected">'.$row->feedback.'</option>
<option value="Paid">02</option>
<option value="NotPaid">05</option>
</select>
<input type="submit" name="submit" value="Update" />
</form>'."</td>";
echo "<td><a href='user-records.php?id=" . $row->id . "'>Edit</a></td>";
echo "</tr>";
}
echo "</table>";
}
//if there are no records in the database, display an alert message
else
{
echo "No results to display!";
}
}
// show an error if there is an issue with the database query
else
{
echo "Error: " . $mysqli->error;
}
// close database connection
$mysqli->close();
?>
<br />
</body>
</html>When I want to submit feed back the insert.php was nor working ????? can any one make a insert.php for me
or any java script solution or other else!!!
#88
Posted 17 February 2012 - 07:08 PM
Rupom, on 16 February 2012 - 04:29 PM, said:
Dear ADMIN This was an awesome tutorial which I have used to create a database system .
There I have a problem ?? Please see attachment!!
I want to edit the "feedback" field without leaving the view page. I want to edit on preview table. How can I do that. I have modify your code look like that ....
<?php
require_once('auth.php');
?>
<!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=iso-8859-1" />
<title>Member Index</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<center>
<img src="./images/sonali.jpg" height="100px" width="100px"/>
</center>
<div align="center">
<p> <h1> Welcome TO Sonali Bank Limited</h1><br />
<h2><?php echo $_SESSION['SESS_FIRST_NAME'];?></h2>
<h2><?php echo $_SESSION['SESS_LAST_NAME'];?></h2>
<h3>BRANCH CODE : <?php echo $_SESSION['SESS_MEMBER_LOGIN'];?></h3>
</div>
<p><a href="member-profile.php">My Profile</a> | <a href="logout.php">Logout</a> | <a href="user-view-admin.php">View ALL</a> | <a href="user-view-paginated.php">View Paginated</a></p>
<?php
//This code is for SONALI BANK ONLY
// connect to the database
include('user-connect-db.php');
include('config.php');
//check user name
// get the records from the database
if ($result = $mysqli->query("SELECT * FROM sblnrat WHERE brcode = $_SESSION[SESS_MEMBER_LOGIN] Order by id"))
{
// display records if there are records to display
if ($result->num_rows > 0)
{
// display records in a table
echo "<table align='center' border='1' cellpadding='10'>";
// set table headers
echo "<tr><th>SL</th><th>PON</th><th>TRA NO.</th><th>TRA DT</th><th>BR-CODE</th><th>BR-NAME</th><th>BF-NAME</th><th>BF-A/C</th><th>AMT</th><th>Feed Back</th></tr>";
while ($row = $result->fetch_object())
{
// set up a row for each record
echo "<tr>";
echo "<td>" . $row->id . "</td>";
echo "<td>" . $row->pon . "</td>";
echo "<td>" . $row->trano . "</td>";
echo "<td>" . $row->tradt . "</td>";
echo "<td>" . $row->brcode . "</td>";
echo "<td>" . $row->brname . "</td>";
echo "<td>" . $row->bfname . "</td>";
echo "<td>" . $row->bfac . "</td>";
echo "<td>" . $row->amt . "</td>";
echo "<td>" . $row->feedback . "</td>";
echo "<td>".'
<form action="insert.php?id='. $row->id . '" method="post">
<select name="feedback">
<option selected="selected">'.$row->feedback.'</option>
<option value="Paid">02</option>
<option value="NotPaid">05</option>
</select>
<input type="submit" name="submit" value="Update" />
</form>'."</td>";
echo "<td><a href='user-records.php?id=" . $row->id . "'>Edit</a></td>";
echo "</tr>";
}
echo "</table>";
}
//if there are no records in the database, display an alert message
else
{
echo "No results to display!";
}
}
// show an error if there is an issue with the database query
else
{
echo "Error: " . $mysqli->error;
}
// close database connection
$mysqli->close();
?>
<br />
</body>
</html>When I want to submit feed back the insert.php was nor working ????? can any one make a insert.php for me
or any java script solution or other else!!!
I have create the insert.php file but it not work can nay one solve this matter....
<?php
// connect to the database
include("user-connect-db.php");
/*-------------------------------
EDIT RECORD
--------------------------------*/
// if the 'id' variable is set in the URL, we know that we need to edit a record
if (isset($_POST['submit']))
{
if (isset($_GET['id']))
{
// if the form's submit button is clicked, we need to process the form
// make sure the 'id' in the URL is valid
if (is_numeric($_POST['id']))
{
// get variables from the URL/form
$id = $_POST['id'];
$feedback = htmlentities($_POST['feedback'], ENT_QUOTES);
// if everything is fine, update the record in the database
if ($stmt = $mysqli->prepare("UPDATE sblnrat SET feedback= ? WHERE id=?"))
{
$stmt->bind_param("si", $feedback, $id);
$stmt->execute();
$stmt->close();
}
// show an error message if the query has an error
else
{
echo "ERROR: could not prepare SQL statement.";
}
// redirect the user once the form is updated
header("Location: member-view.php");
}
}
// if the 'id' variable is not valid, show an error message
else
{
echo "Error...............!!!!!!!";
}
}
// close the mysqli connection
$mysqli->close();
?>
#89
Posted 19 February 2012 - 11:43 AM
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
#90
Posted 20 February 2012 - 12:25 AM
Ben, on 19 February 2012 - 11:13 PM, said:
Thank you very much !!!!!!! I have solved my problem..

Help












