Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

php function

Featured Replies

sorted my script from earlier :-D

 

im wanting to add a delete & edit button in a table with the data from a mysql table

 

i know the sql syntax but wondering how to incorporate

 

would it be best to run to a new page or a function within the current page?

 

e.g. the sql codes would be

 

<b>edit</b>

  mysql_query("UPDATE xx SET name= '.$newname.' WHERE ID = '$id' ");

<b>delete</b>

  mysql_query("DELETE FROM xx WHERE ID='ID'");

 

now should i create a php function e.g function edit & function delete

 

or have a link based idea

sorted my script from earlier :-D

 

im wanting to add a delete & edit button in a table with the data from a mysql table

 

i know the sql syntax but wondering how to incorporate

 

would it be best to run to a new page or a function within the current page?

 

e.g. the sql codes would be

 

<b>edit</b>

  mysql_query("UPDATE xx SET name= '.$newname.' WHERE ID = '$id' ");

<b>delete</b>

  mysql_query("DELETE FROM xx WHERE ID='ID'");

 

now should i create a php function e.g function edit & function delete

 

or have a link based idea

 

How about a CMD eg http://localhost/act.php?cmd=delete

The way I would do this is to have the delete button link you to the same page, but pass some data to the page (using GET or POST)

 

lets say your current page is http://www.atable.com/table.php, you could have the button link to http://www.atable.com/table.php?action=delete,id=5

 

You can then check with php for an action when the page loads, and then use switch/case for the possible values.

if isset($_GET['action']){
switch($_GET['action']){ 
 case "delete":
  $query = "DELETE FROM xx WHERE ID = '$_GET[id]'";
  break;
 case "edit":
  $query = "UPDATE xx SET name= '.$_GET["newname"].' WHERE ID = '$_GET[id]' "
  break;
}
mysql_query($query,$conn); //obviously you'd have to have a connection object set up as $conn for this to work.
}

 

Alternatively you could do the same thing using $_POST variables, but you'd have to have some javascript that changed the values of some hidden fields on the form before, so get is a bit simpler (but easier for the user to edit, and cause some big screw-up!).

 

EDIT: if you'd rather do it the POST way, but don't know how, then let me know.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.