Jump to content

Recommended Posts

i have a script which displays information from a mysql table (index.tcos) and then creates a link using the rows id on clicking this link i want it to delete that row from the table so what i need is a way of saying

 

if (isset(index.tcos?id=3)){
delete the row from the database
} 
else{
$query="select * from band ORDER BY name";  
$rt=mysql_query($query);        
echo mysql_error();
while($nt=mysql_fetch_array($rt)){
echo "<a href='../../../admin/del/bandm/index.tcos?id=".$nt[id]."'>$nt[name]</a><br>";
}    
}

 

all i need is to know how i can get the information from the address bar, the ?id=3, and after geting this info it will run a mysql delete query on that row?

 

i hope you understand what i would like to do, all i dont know is how to get the address from the address bar :S

$id=($_GET['id']);

 

That will set $id to what ever is in the address bar which comes after the id=

 

you can change the ['id'] bit to something else, for example, if you want to retreave username from the address bar eg. page.php?username=someone then you can use:

($_GET['username']) (which will return the string "someone")

ok so i got it to work but i want a popup to appear when a link is clicked so that when a user confirms the delete it will run an sql to delete that row.

 

i havent used javascript with php before so this is a first time for me i would like a javascript popup confirm box to go where the echo "working"; part is.

 

please help

 

below is my current code.

		<?php

			if (isset($_GET['id'])){
			echo "Working";
			} 
			else{
			$query="select * from band ORDER BY name";  
			$rt=mysql_query($query);        
			echo mysql_error();
			while($nt=mysql_fetch_array($rt)){
				echo "<a href='../../../admin/del/bandm/index.tcos?id=".$nt[id]."'>$nt[name]</a><br>";
				}  
			}
  
		?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.