marksie1988 Posted August 8, 2007 Share Posted August 8, 2007 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 Link to comment https://forums.phpfreaks.com/topic/63974-use-id3-to-call-a-function-in-the-same-page-s/ Share on other sites More sharing options...
joecooper Posted August 8, 2007 Share Posted August 8, 2007 $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") Link to comment https://forums.phpfreaks.com/topic/63974-use-id3-to-call-a-function-in-the-same-page-s/#findComment-318883 Share on other sites More sharing options...
janim Posted August 8, 2007 Share Posted August 8, 2007 as joecooper user $id=($GET['id']); then you should pull from your table like this $result = mysql_db_query($database, "select * from $table where id='$id'") or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/63974-use-id3-to-call-a-function-in-the-same-page-s/#findComment-318891 Share on other sites More sharing options...
marksie1988 Posted August 9, 2007 Author Share Posted August 9, 2007 oh i didnt realise you could use the get function for this i will try it out when i get home tonight Link to comment https://forums.phpfreaks.com/topic/63974-use-id3-to-call-a-function-in-the-same-page-s/#findComment-319173 Share on other sites More sharing options...
marksie1988 Posted August 9, 2007 Author Share Posted August 9, 2007 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>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/63974-use-id3-to-call-a-function-in-the-same-page-s/#findComment-319578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.