473,325 Members | 2,792 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,325 software developers and data experts.

Deleting entries

I am new to PHP and I am trying make a page that displays the entries in a table and then gives the option to delete a specific entry after checking it. I can get the page to display the entries and there is a link to delete the entry but it will not pass the variable to the second page that deletes the entry. Here is my code.

This is the page that displays the entries:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include 'datacon.php';
  3.  
  4. $result = mysql_query("SELECT * FROM stationfailuretest");
  5.  
  6. echo "<table border='1'>
  7. <tr>
  8. <th>Station Failures</th>
  9. <td>ID</td>
  10. <td>Cube Number</td>
  11. <td>Phone Number</td>
  12. <td>Agent Name</td>
  13. <td>Agent ID</td>
  14. <td>Problem</td>
  15. </tr>";
  16.  
  17. while($row = mysql_fetch_array($result))
  18.   {
  19.   echo "<tr>";
  20.   echo "<td><a href=\"list2.php?ID=";
  21.   echo $row['id'];
  22.   echo "\" TARGET=main>";
  23.   echo "Delete</a></td>";
  24.   echo "<td>".$row['id']."</td>\n";
  25.   echo "<td>".$row['Cube_Number']."</td>\n";
  26.   echo "<td>".$row['Phone_Number']."</td>\n";
  27.   echo "<td>".$row['Agent_Name']."</td>\n";
  28.   echo "<td>".$row['Agent_ID']."</td>\n";
  29.   echo "<td>".$row['Problem']."</td>\n";
  30.   echo "</tr>";
  31.   }
  32. echo "</table>";
  33.  
  34. mysql_close($con);
  35. ?>
  36.  
  37. Here is the code of the page that is supposed to delete the entry:
  38.  
  39. <?php
  40.  
  41. switch (ID)
  42. {
  43. default:
  44. echo "<b>";
  45. include 'datacon.php';
  46.  
  47. $result = mysql_query("DELETE FROM stationfailuretest WHERE id = '".$ID."'");
  48.  
  49. mysql_close($con);
  50. break;
  51. }
  52. ?>

If I hard code the number of the ID into the second page it deletes the entry but not if I leave it to use the passed variable.

Please Help
Jul 20 '07 #1
3 1448
I changed the second page to:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if($id=="")
  3. header("Refresh: 0;url=work.html");
  4. else
  5. {
  6. include 'datacon.php';
  7.  
  8. $query = "delete from stationfailuretest where id='".$id."'";
  9. $result = mysql_query($query);
  10. header("Refresh: 0;url=index.php");
  11. }
  12. ?>
That way I could test to see if the variable is even passed and it comes up with the work.html. So for some reason the variable is not being passed.

Thanks again
Jul 20 '07 #2
actually i found the problem, thank you
Jul 20 '07 #3
pbmods
5,821 Expert 4TB
Heya, 66sprite. Welcome to TSDN!

Well, glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Jul 21 '07 #4

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

Similar topics

3
by: Patrick von Harsdorf | last post by:
I want to iterate over a collection and delete all unwanted entries. for item in collection: del item of course doesn´t do anything useful. Two things come to mind: a) iterating backwards...
18
by: Dan | last post by:
hello, I would to know if it is possible to delete an instance in an array, The following does not allow me to do a delete. I am trying to find and delete the duplicate in an array, thanks ...
12
by: Christoff Pale | last post by:
Hi, suppose I have a list of strings; I have to iterate of the strings and delete certain entries. I and not sure how to do this? for example: #include<list> #include<string>...
4
by: stokefan | last post by:
Hi all, I wondered if anyone knew if it was possible to delete entries in an MS Access database table from just entering data into it? I shall explain : If you have a web form (in asp.net...
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
2
by: johnds | last post by:
I am researching the use of physician services that are recorded in a billing database of over 10 million records. I am only interested in the patient's treatment type, and their attributes (age...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
2
by: helraizer1 | last post by:
Hi folks, I have a file for my chatbox called data.line, which the posts are in the layout CHATBOXTEXT 7 username=helraizer 1202416953
4
by: MiziaQ | last post by:
Hey, I'm using the following code to write entries to a data file and then read them in an msflexgrid. I now would like to add code under a delete button to use the table(grid) to delete rows from...
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.