Jump to content

[SOLVED] Get data from URL (newbie)


aQ

Recommended Posts

Hello!

 

I am a php-newbie, so don't please keep your replies easy to understand.

 

I want to take data from the URL to do something. I'll try to explain.

 

Let's say that I have this url: index.php?page=news&delete=4

4 is the "id"-field of a post in my mysql-database. I want to delete the post with the id 4 belongs to.

 

I hope you understand.

Thanks, aQ.

Link to comment
https://forums.phpfreaks.com/topic/49319-solved-get-data-from-url-newbie/
Share on other sites


Thank you map.

I think you meant print_r($_GET)?

 

Now I get this:

Array (


=> news [delete] => 6 )

 

What can I do with it to delete id 6 now?

 

By the way: What is the difference between "print_r" and "print"?

 

pedropedroc:

I want to delete it using php since I don't want to go into phpmyadmin every time.

indeed i did mean $_GET , my mistake

 

print_r recursively goes through arrays, as $_get is an array if we did print $_GET

 

it will just say Array (

 

now to delete data with entry id6, okej

 

$id=$_GET[delete];

 

we have create variable ID with the value of whatever delete was when the url was called

 

we can now run a query and use the $id var (you could use $_GET[delete] without assigning to a var) i prefer to do it this way tho

 

DELETE FROM bla WHERE id=$id

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.