473,473 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Delete the row at the showed listed table database

93 New Member
Hi all,
Could someone help me how to delete the rows for the listed row below? How do I write the codes at this line? I want to click on 'Delete' to delete the specific row.

<td colspan="2" align="right">Delete</td>

Many thanks

nma

[PHP]
<?php
session_start();

if(!isset($_SESSION['user'])) {
header('Location: /..');
die();
}
?>
<?php
include_once('../ez_sql.php');

if($_GET['eventID'] == 0){
if(isset($_GET['noteID'])){
$noteID = $_GET['noteID'];
$notes = $db->get_results("select MovieNotes.*,UserLogin.username from MovieNotes left join UserLogin on MovieNotes.userID=UserLogin.userID where noteID=$noteID order by noteDate desc");
}
else{
$movieID = $_GET['movieID'];
$notes = $db->get_results("select MovieNotes.*,UserLogin.username from MovieNotes left join UserLogin on MovieNotes.userID=UserLogin.userID where movieID=$movieID order by noteDate desc");
}

}
else {

if(isset($_GET['noteID'])){
$noteID = $_GET['noteID'];
$notes = $db->get_results("select EventNotes.*,UserLogin.username from EventNotes left join UserLogin on EventNotes.userID=UserLogin.userID where noteID=$noteID order by noteDate desc");
}
else {

$eventID = $_GET['eventID'];
$notes = $db->get_results("select EventNotes.*,UserLogin.username from EventNotes left join UserLogin on EventNotes.userID=UserLogin.userID where eventID=$eventID order by noteDate desc");
}
}

if(count($notes) == 0) {
die();
}
foreach($notes as $note) {
?>
<table width="400">
<tr>
<td colspan="2" width="200" class="eventEntryText">
<strong><?php echo $note->noteDate?> </strong> -- <?php echo $note->username?> <br /><?php echo $note->noteText?><br />
</td>

</tr>
<tr>
<td colspan="2" align="right">Delete</td>
</tr>
<tr>
<td colspan="2" height="5"><img src="iframe-borderline.jpg" width="400" height="5"/></td>
</tr>
</table>
<?php
}

?>[/PHP]
Jan 27 '08 #1
12 1929
stepterr
157 New Member
An easy solution would be to add a Delete link for each row and tack on the identify value, such as
[PHP]<a href='Delete.php?value=$value'>Delete</a>[/PHP].
Then on the Delete.php that you have called run the delete statement based on the value stored in [PHP] $_GET[value][/PHP].
Jan 27 '08 #2
nma
93 New Member
An easy solution would be to add a Delete link for each row and tack on the identify value, such as
[PHP]<a href='Delete.php?value=$value'>Delete</a>[/PHP].
Then on the Delete.php that you have called run the delete statement based on the value stored in [PHP] $_GET[value][/PHP].


Hi,

I write like this but still got error. Can anyone help please.


[HTML]
<td colspan="2" align="right"><a href='delete.php?value=<?php $noteText?>'>Delete</td>[/HTML]


[PHP]
<?php

include_once('../ez_sql.php');

$eventID = $_GET['eventID'];
$noteText = $_GET['noteText'];


if($eventID == 0){
$db->query("DELETE FROM MovieNotes WHERE noteText = ($noteText )");
}
else {
$db->query("DELETE FROM EventNotes WHERE noteText =($noteText )");
}

?>
[/PHP]

The errors shows like below:

Notice: Undefined index: eventID in C:\htdocs\..\delete.php on line 5
Notice: Undefined index: noteText in C:\htdocs\..\delete.php on line 6
SQL/DB Error -- [Incorrect syntax near ')'.]
Jan 28 '08 #3
stepterr
157 New Member
[HTML]
<td colspan="2" align="right"><a href='delete.php?value=<?php $noteText?>'>Delete</td>[/HTML]


[PHP]
<?php

include_once('../ez_sql.php');

$eventID = $_GET['eventID'];
$noteText = $_GET['noteText'];

?>
[/PHP]
Nma,
Make this change
[HTML]
<td colspan="2" align="right"><a href='delete.php?noteText=<?php $noteText?>'>Delete</a></td>[/HTML]


[PHP]
<?php

include_once('../ez_sql.php');

$eventID = $_GET['eventID'];
$noteText = $_GET['noteText'];

?>
[/PHP]

When you do a $_GET it has to use the same name has what you did in the URL. So if you wanted to leave the URL with "value=" then your GET would need to be $_GET['value']. Above I changed the URL to match, so it is using noteText. Also you didn't have the closing </a> tag. And where are you getting the $_GET['eventID'] from?

Also change your SQL statements to

[PHP]"DELETE FROM MovieNotes WHERE noteText = '$noteText'"[/PHP]
and
[PHP]"DELETE FROM EventNotes WHERE noteText ='$noteText'"[/PHP]
Jan 28 '08 #4
nma
93 New Member
Nma,
Make this change
[HTML]
<td colspan="2" align="right"><a href='delete.php?noteText=<?php $noteText?>'>Delete</a></td>[/HTML]


[PHP]
<?php

include_once('../ez_sql.php');

$eventID = $_GET['eventID'];
$noteText = $_GET['noteText'];

?>
[/PHP]

When you do a $_GET it has to use the same name has what you did in the URL. So if you wanted to leave the URL with "value=" then your GET would need to be $_GET['value']. Above I changed the URL to match, so it is using noteText. Also you didn't have the closing </a> tag. And where are you getting the $_GET['eventID'] from?

Also change your SQL statements to

[PHP]"DELETE FROM MovieNotes WHERE noteText = '$noteText'"[/PHP]
and
[PHP]"DELETE FROM EventNotes WHERE noteText ='$noteText'"[/PHP]


[PHP]
<?php

include_once('../ez_sql.php');

$noteID = $_GET['noteID'];
$eventID = $_GET['eventID'];

if($eventID == 0){
$db->query("DELETE FROM MovieNotes WHERE noteID = $noteID ");
}
else {
$db->query("DELETE FROM EventNotes WHERE noteID = $noteID ");
}
?>
[/PHP]

[HTML]
<table width="400">
<tr>
<td colspan="2" width="350" class="eventEntryText">
<strong><?php echo $note->noteDate?> </strong> -- <?php echo $note->username?> <br /><?php echo $note->noteText?><br />
</td>

</tr>
<tr>
<td colspan="2" align="right"><a href='deleteNote.php?noteID=<?php noteID; ?>& eventID=<?php $eventID; ?>'>Delete</a></td>
[/HTML]

Hi stepterr
Still got error
Notice: Undefined index: eventID in C:\htdocs\..\delete.php on line 6

SQL/DB Error -- [Incorrect syntax near '<'.]

Do I need to write noteID=<?php note->noteID; ?> ,......using note-> at html code line 9 ?(I'm using ez_sql syntak). If I want to combine two variable say noteID and eventID should I use & as in line 9?

Please help..
nma
Jan 28 '08 #5
nma
93 New Member
Hi

I jsut trying with this codes..there is no error but only appear blank screen. When I check at the database, the row does not being deleted. Why is it happen like that?

nma

[HTML]
<td colspan="2" align="right"><a href='deleteNote.php?noteID=<?php $note->noteID; ?>'>Delete</a></td>

[/HTML]

[PHP]
<?php
include_once('../ez_sql.php');
$noteID = $_GET['noteID'];
$db->query("DELETE FROM MovieNotes WHERE noteID = '$noteID' ");
?>
[/PHP]
Jan 28 '08 #6
stepterr
157 New Member
Hi

I jsut trying with this codes..there is no error but only appear blank screen. When I check at the database, the row does not being deleted. Why is it happen like that?

nma

[HTML]
<td colspan="2" align="right"><a href='deleteNote.php?noteID=<?php $note->noteID; ?>'>Delete</a></td>

[/HTML]

[PHP]
<?php
include_once('../ez_sql.php');
$noteID = $_GET['noteID'];
$db->query("DELETE FROM MovieNotes WHERE noteID = '$noteID' ");
?>
[/PHP]
When you hover over the delete link on the first page is it showing correctly with the value of $note->noteID at the bottom of your browser?
Jan 28 '08 #7
nma
93 New Member
When you hover over the delete link on the first page is it showing correctly with the value of $note->noteID at the bottom of your browser?

when I view source ..it shows like this..now I try with noteDate. Seem it does not pass any value.

<td width="100" align="right"><a href='deleteNote.php?noteDate='>Delete</a></td>
Jan 28 '08 #8
Markus
6,050 Recognized Expert Expert
Should you not be echoing it out?

Expand|Select|Wrap|Line Numbers
  1. <a href="delete.php?noteID=<?php echo $noteID;?>&something=else">delete</a>
  2.  
Jan 28 '08 #9
nma
93 New Member
Should you not be echoing it out?

Expand|Select|Wrap|Line Numbers
  1. <a href="delete.php?noteID=<?php echo $noteID;?>&something=else">delete</a>
  2.  
Hi markusn00b

When I put the echo the source show the value. but then still the same..no error but in the database the record is still not deleted.

view source...
<td width="100" align="right"><a href='deleteNote.php?noteDate=Jan 28 2008 8:31PM'>Delete</a></td>
Jan 28 '08 #10
Markus
6,050 Recognized Expert Expert
Try urlencode()ing your variable.. it might not be recognised because it's passed through the url.

[php]
$_noteID = urlencode(...);
[/php]

then on delete.php

[php]
$_noteID = urldecode(...);
[/php]
Jan 28 '08 #11
nma
93 New Member
Hi,

After days of frustrations..now I can delete rows in the database...it works!!!

Thanks to all advise given.

nma
Jan 30 '08 #12
Markus
6,050 Recognized Expert Expert
Hi,

After days of frustrations..now I can delete rows in the database...it works!!!

Thanks to all advise given.

nma
Congrats!

Post back whenever!
Jan 30 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Belinda | last post by:
Hello All I need to read a SQL Server table into a Web Page and within the Web Page to permit my users to make changes to the records, delete or add new records and then save the entire contents...
2
by: michael | last post by:
Gotta post because this is driving me nuts. Trying to DELETE orphans. I can successfully: SELECT GroupID FROM Groups LEFT JOIN Users ON UsersID = UserID WHERE UsersID IS NULL; but when I...
1
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB...
4
by: Susan Bricker | last post by:
I have a command button on a form that is supposed to Delete the record being displayed. The record is displayed one to a form. The form is not a Pop-Up nor is it Modal. Tracing the btnDelete...
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
3
by: blakerrr | last post by:
Hi All, I have a strange situation that I can't figure out. The task is quite simple, delete a record from a table. Here is my situation: I have a form called Order Create which cycles through...
31
by: matthewslyman | last post by:
I have an unusual design and some very unusual issues with my code... I have forced Access to cooperate on everything except one issue - record deletion. My form design involves a recursively...
29
by: shivasusan | last post by:
Hi! I can add rows with inputs to my HTML table dynamically using DOM, but I cannot remove selected rows. In fact, every row contains a Delete button. So, user selects the rows to remove, clicks...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.