Jump to content

use ?id=3 to call a function in the same page? :S


marksie1988

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>";
				}  
			}
  
		?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.