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

Deleting A Row in PHP

flexsingh
Hello there,

I have been trying to delete a row in php for a long time now and its getting frustrating, can any see if they could possible help me please.

My first page is

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // this starts the session 
  3. session_start(); 
  4. ?>
  5. <html>
  6.  
  7. <head>
  8. <h1><font face="sans-serif, Arial" font color="white">Members Page!</h1>
  9. </head>
  10.  
  11. <body background="main background1.jpg" link="yellow" vlink="yellow" hover="green" >
  12. <a href="blank.php">Back To Main page</a>
  13.  
  14. <table align="center" width="600" border="0" cellspacing="0" cellpadding="1" >
  15. <tr>
  16. <td><font face="sans-serif, Arial" color="white" size= "-1">DESC Order</td>
  17. <td><a href="member_select_md.php"><font face="sans-serif, Arial" font font size= "-1">Member DESC</a></td>
  18. <td><a href="member_select_sd.php"><font face="sans-serif, Arial" font font size= "-1">Surname DESC</a></td>
  19. <td><a href="member_select_fd.php"><font face="sans-serif, Arial" font font size= "-1">Forename DESC</a></td>
  20. <td><a href="member_select_ad.php"><font face="sans-serif, Arial" font font size= "-1">Address DESC</a></td>
  21. <td><a href="member_select_dd.php"><font face="sans-serif, Arial" font font size= "-1">DOB DESC</a></td>
  22. </tr>
  23. <tr>
  24. <td><font face="sans-serif, Arial" color="white" font font size= "-1">ASC Order</td>
  25. <td><a href="member_select.php"><font face="sans-serif, Arial" font size= "-1">Member ASC</a></td>
  26. <td><a href="member_select_sa.php"><font face="sans-serif, Arial" font size= "-1">Surname ASC</a></td>
  27. <td><a href="member_select_fa.php"><font face="sans-serif, Arial" font size= "-1">Forename ASC</a></td>
  28. <td><a href="member_select_aa.php"><font face="sans-serif, Arial" font size= "-1">Address ASC</a></td>
  29. <td><a href="member_select_da.php"><font face="sans-serif, Arial" font size= "-1">DOB ASC</a></td>
  30. </tr>
  31. </table>
  32. <br><br><br>
  33. <table align="right" width="700" border="1" cellspacing="0" cellpadding="3" >
  34. <tr>
  35.  
  36. <td align="center" width="12%"><b><u><font face="sans-serif, Arial" font color="white">Member No</b></u></td>
  37. <td align="center" width="13%"><b><u><font face="sans-serif, Arial" font color="white">Surname</b></u></td>
  38. <td align="center" width="13%"><b><u><font face="sans-serif, Arial" font color="white">Forename</b></u></td>
  39. <td align="center" width="40%"><b><u><font face="sans-serif, Arial" font color="white">Address</b></u></td>
  40. <td align="center" width="25%"><b><u><font face="sans-serif, Arial" font color="white">DOB</b></u></td>
  41. <td align="center" width="5%"></td>
  42. </tr>
  43. </table>
  44. <br><br><br><br>
  45. <?php
  46. $db_name="project"; // Database name
  47. $tbl_name="member"; // Table name
  48.  
  49. // Connect to server and select database.
  50. mysql_connect($_SESSION['host'], $_SESSION['username'], $_SESSION['password'])or die("cannot connect");
  51. mysql_select_db("$db_name")or die("cannot select DB");
  52.  
  53. $memberno=urlencode($_GET['Member_No']);
  54.  
  55. // Retrieve data from database
  56. $sql="SELECT * FROM $tbl_name ORDER BY `Member_No` ASC";
  57. $result=mysql_query($sql);
  58.  
  59. // Start looping rows in mysql database.
  60. while($rows=mysql_fetch_array($result)){
  61. ?>
  62.  
  63. <table width="700" border="1" cellspacing="0" cellpadding="3" align="right">
  64. <tr>
  65.  
  66. <td width="12%" align="center"><font face="sans-serif, Arial" font color="white"><? echo $rows['Member_No']; ?></td>
  67. <td width="13%" align="center"><font face="sans-serif, Arial" font color="white"><? echo $rows['Surname']; ?></td>
  68. <td width="13%" align="center"><font face="sans-serif, Arial" font color="white"><? echo $rows['Forename']; ?></td>
  69. <td width="40%" align="center"><font face="sans-serif, Arial" font color="white"><? echo $rows['Address']; ?></td>
  70. <td width="25%" align="center"><font face="sans-serif, Arial" font color="white"><? echo $rows['DOB']; ?></td>
  71. <td width="5%"  align="center" ><a href="member_delete.php">delete</a>
  72. </tr>
  73. </table>
  74. <br><br><br>
  75. <?
  76. // close while loop
  77. }
  78.  
  79. // close connection
  80. mysql_close();
  81. ?>
  82.  
  83. </body>
  84. </html>
------------------------------------------------------------------------------------------------------------------
I get a delete button next to all the rows but when I click on the delete button I get a blank screen, the coding for the delete button is: -
-------------------------------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // this starts the session
  3. session_start();
  4. ?>
  5.  
  6. <?php
  7.  
  8. $db_name="project"; // Database name
  9. $tbl_name="member"; // Table name
  10.  
  11. // Connect to server and select database.
  12. mysql_connect($_SESSION['host'], $_SESSION['username'], $_SESSION['password'])or die("cannot connect");
  13. mysql_select_db("$db_name")or die("cannot select DB");
  14.  
  15. $memberno=urldecode($_GET['Member_No']);
  16.  
  17.  
  18. //$db->query("DELETE FROM $tbl_name WHERE Member_No = '$Member_No'";
  19.  
  20. $query = ("DELETE FROM $tbl_name WHERE Member_No = '".$_GET["Member_No"]."' LIMIT 1");
  21.  
  22. $result = mysql_query($query);
  23.  
  24. //header("location: member_select.php");
  25.  
  26. //$sql= "DELETE FROM $tbl_name WHERE Member_No = $memberno";
  27.  
  28. //$result=mysql_query($sql);
  29. //echo "row deleted";
  30.  
  31. // close connection
  32. mysql_close();
  33. ?>
---------------------------------------------------------------------------------------------------------------

As you can see I have tried alot, could any one please help.

Thank you in advanced
Mar 25 '08 #1
5 2028
ronverdonk
4,258 Expert 4TB
In the first form I see no delete button, no form and no form submission. So how do you pass the clicked record to be deleted to the delete script?

Ronald
Mar 25 '08 #2
Markus
6,050 Expert 4TB
on line 71 where you have the delete button, shouldnt you be passing the $memberno through the url?
Mar 25 '08 #3
on line 71 where you have the delete button, shouldnt you be passing the $memberno through the url?
I tried this
[php]<a href="member_delete.php?Member_No=<?php echo $rows['Member_No'];?>&something=else">delete</a>[/php]
It works! ok it wasnt working before, thank you for your help sorry to have wasted your time, you must have good luck thank you again much appriciated.
Mar 25 '08 #4
Markus
6,050 Expert 4TB
I tried this

<a href="member_delete.php?Member_No=<?php echo $rows['Member_No'];?>&something=else">delete</a>

It works! ok it wasnt working before, thank you for your help sorry to have wasted your time, you must have good luck thank you again much appriciated.
Not goodluck - just did the usual debugging :)

See you around again!
Mar 25 '08 #5
Not goodluck - just did the usual debugging :)

See you around again!
:) will do thanks again
Mar 25 '08 #6

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

Similar topics

5
by: flupke | last post by:
Hi, i'm having trouble with deleting elements from a list in a for loop ============== test program ============== el = print "**** Start ****" print "List = %s " % el index = 0 for line...
15
by: Rick | last post by:
Hi, Does deleting an object more than one times incur undefined behavior? I think it doesn't but just making sure... thanks Rick
6
by: Abhijeet | last post by:
I was just toying around idea of deleting this from a member function. Was expecting that any acess to member variable or function after deleting sould give me dump(segmetation violation).Cause now...
6
by: Matan Nassau | last post by:
Hello. i have a composite which i want to delete. this is a composite which represents a boolean expression (see a previous post of mine with more details at...
3
by: Nathan Bloom | last post by:
Hi, I have a data entry form (access 2000) that also allows the user to add, update, and delete records from the form. The Delete action is carried out in an event procedure and has the...
5
by: Mojtaba Faridzad | last post by:
Hi, with SetDataBinding( ) a DataGrid shows a DataView. user can select some rows in the grid by holding cotrol key. when user clicks on Delete button, I should delete all selected rows. I am...
4
by: al havrilla | last post by:
hi all what does the phrase: "scalar deleting destructor" mean? i'm getting this in a debug error message using c++ 7.1 thanks Al
6
by: Martin Bischoff | last post by:
Hi, I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123) to allow users to upload files. When I later delete these directories (from the code behind), the application...
3
by: Kimera.Kimera | last post by:
I'm trying to write a program in VB.net 2003 that basically deletes all files, folders, sub-folders and sub-sub folders (etc). The program is simply for deleting the Windows/Temp folder contents,...
2
Parul Bagadia
by: Parul Bagadia | last post by:
I have written a code for deleting certain value from linklist; it's not working; where as i have written one for deleting a no., after given no. which works fine! I even debugged it; but invain;...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...

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.