Page 1 of 1

Simple question :)

Posted: Wed Mar 03, 2004 7:41 pm
by Flamie
How can I remove a mysql row from php ?
exemple, remove row where ID='5'.
thx
Flamie

Posted: Wed Mar 03, 2004 7:42 pm
by d3ad1ysp0rk
DELETE FROM table WHERE id = '5'

Posted: Wed Mar 03, 2004 7:48 pm
by Deemo
however, be careful with that, and make sure the primary key is ID so u dont accidnetly delete multiple rows :twisted:

Posted: Wed Mar 03, 2004 10:07 pm
by Flamie
thx a lot guys, you're a lot of help :)
Now I'm just having a blank, I TOTALLY forgot how to use a variable from another page, let's say their's a form on page1.php that sends the data to page2.php, and let's say on page1 we entered the variable 'ID', how can I use it on page2 ?
Wasnt it $HTTP_POST or something ?

Posted: Wed Mar 03, 2004 10:36 pm
by infolock
well, the most common way to use http post is to send it through the url..

so, you would have a link on page1.php that looks like this :

page1.php

Code: Select all

<?php
echo '<a href="page2.php?id='.$id.'">Page 2 Link</a>';
?>
then, you can call it like so from page2.php


page2.php

Code: Select all

$id = $HTTP_GET_VARS['id'];

echo $id;
if ur gonna be passing the variable through a form, use $_POST in page 2...

if there is just a variable that has been declared, just include page 1..

Code: Select all

include('page1.php');
echo $id;

Posted: Wed Mar 03, 2004 10:40 pm
by Flamie
ok thx a lot :)

Posted: Thu Mar 04, 2004 3:12 am
by twigletmac
infolock wrote: page2.php

Code: Select all

$id = $HTTP_POST_VARS['id'];

echo $id;
If you're accessing variables from the query string as the page1.php example seems to show, then you need to use $_GET['id'] not $HTTP_POST_VARS['id'] which would be the same as $_POST['id'].

Mac

Re: Simple question :)

Posted: Thu Mar 04, 2004 3:26 am
by m3mn0n
Flamie wrote:How can I remove a mysql row from php ?
exemple, remove row where ID='5'.
thx
Flamie
Check out this site. :)

Posted: Thu Mar 04, 2004 1:11 pm
by infolock
twigletmac, yeah that was a typo on my part lol. my bad ;)