473,671 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deleting A Row in PHP

flexsingh
17 New Member
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 2045
ronverdonk
4,258 Recognized Expert Specialist
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 Recognized Expert Expert
on line 71 where you have the delete button, shouldnt you be passing the $memberno through the url?
Mar 25 '08 #3
flexsingh
17 New Member
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_de lete.php?Member _No=<?php echo $rows['Member_No'];?>&something=e lse">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 Recognized Expert Expert
I tried this

<a href="member_de lete.php?Member _No=<?php echo $rows['Member_No'];?>&something=e lse">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
flexsingh
17 New Member
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
2731
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 in el:
15
3584
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
1649
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 I am trying to access freed. memory. Is my assumption correct? I tried following code --------------------------------------------------- #include <iostream.h>
6
2429
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 http://groups.google.ca/groups?hl=en&lr=&ie=UTF-8&threadm=AXqqc.89218%24PJ1.865449%40wagner.videotron.net&rnum=1&prev=/groups%3Fq%3Dmatan%2Bnassau%26hl%3Den%26lr%3D%26ie%3DUTF-8%26sa%3DG%26scoring%3Dd ) VariableExp *x = new VariableExp("X"); VariableExp *y = new VariableExp("Y");...
3
2754
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 following code: Private Sub Command28_Click() On Error GoTo Err_Command28_Click
5
14733
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 trying to delete these lines from the dataview like this: for (int i=0; i < dataView.Count; i++) if (dataGrid.IsSelected(i)) dataView.Delete(i);
4
14017
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
4555
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 restarts and all active sessions are terminated. This error is also described in detail here:...
3
2870
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, removing all the files/folders inside it. The problem i am having is that i can only delete files in the Windows/Temp folder, and i can't delete folders if they contain files, i know that you can't do this.
2
1921
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; down here am posting my code; please somebody who can point it out; let me know fast; whats wrong in it... //Delete a number next to the given number void afterdelete() { struct linklist*temp=NULL; int no=0;
0
8483
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8401
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8824
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8673
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7444
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6236
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5703
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.