473,320 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to delete the item from table? I am using SESSION.

aveeva
33
Here is my code :

Expand|Select|Wrap|Line Numbers
  1. <html> 
  2. <head> 
  3.  
  4.     <style type="text/css"> 
  5.         table { 
  6.             border-collapse: collapse; 
  7.             border: 1px solid black; 
  8.         } 
  9.         table td,th { 
  10.             border: 1px solid black; 
  11.         } 
  12.         td { 
  13.             text-align: center; 
  14.         } 
  15.     </style> 
  16. </head> 
  17.  
  18. <body> 
  19.  
  20.     <h2>Play Lists</h2> 
  21.  
  22.     <table> 
  23.         <th>Voice SKU</th> 
  24.         <th>Voice Name</th> 
  25.         <th>Action</th> 
  26.  
  27.  
  28.         <?php 
  29.        session_start(); 
  30.       foreach ($_SESSION['playlist'] as $key => $value) { 
  31.         echo "<tr>"; 
  32.         echo "<td>" . $key . "</td>\n<td>" . $value . "</td>"; 
  33.  
  34.         echo "<td>". "<button id='btn'>Delete</button>"."</td>"; 
  35.  
  36.         echo "</tr>";     
  37.         } 
  38.         ?> 
  39.     </table> 
  40. </body> 
  41. </html>
  42.  
output:

https://snag.gy/vOt9VX.jpg
Jul 18 '19 #1
2 1284
Luuk
1,047 Expert 1GB
You could do this by creating a javascript function for each button

change line #34 to:
Expand|Select|Wrap|Line Numbers
  1. echo '<td><button onclick=' . 'alert("' . $key . '")' . ' id="btn">Delete</button></td>'; 
Sorry for changing the doublequotes to singlequotes, and vice versa, but … 😉

With this code you should see a popup window with the value of $key.

In stead of 'alert', you could create another javascript function that send i.e. 'http://localhost/delete?id=...' to you server, which then deletes the key from the SESSION on the server.
(But this part (SESSIONs) is not really known to /me, … )
Jul 20 '19 #2
aveeva
33
Thanks for your help.
Jul 22 '19 #3

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

Similar topics

2
by: LVande | last post by:
SQLLY challenged be gentle -- Trying to create code that will drop a table using a variable as the Table Name. DECLARE @testname as char(50) SELECT @testname = 'CO_Line_of_Business_' +...
5
by: Tony | last post by:
hi NG I have got a database, and from this database I want to delete a table in another database, before Iexport a new table to that other database. My question is how can I delete a table in...
4
by: Ian | last post by:
Hi, I have a problem with delete using where in clause. This is a query: delete from tab1 where id not in (select id from tab2) I calculated costs using select instead of delete: select...
0
by: bimeldip | last post by:
Hi, I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be...
1
by: haringmunti | last post by:
hi, how do you add, edit or delete item using vb.net? sad to say, all i know how to do at the moment is pick the command button from the toolbox and then label it properly. im trying to make a...
2
by: Kenxo | last post by:
Hello, I am new at scripting and having some problems with syntax on EXECUTE cmd I was traying to reset the primary key on an access db table but I thought it was easier to delete the table and...
8
by: Ratko | last post by:
Say you have something like this: for item in myList: del item Would this actually delete the item from the list or just decrement the reference counter because the item in myList is not...
0
by: Big Daddy | last post by:
I am trying to do all my DB access through LINQ. For example, I am trying to delete a record from the JobQueue table. There’s a couple ways I could do this: 1. Method 1 – The disadvantage is...
3
by: 125a29 | last post by:
hi i'm trying to update total order cost in order table , basically what i want when i edit order item table such as changing quantity then it automatically update the total cost in order table i...
0
by: Bharthish k v | last post by:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.