Simple question :)

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Flamie
Forum Contributor
Posts: 166
Joined: Mon Mar 01, 2004 3:19 pm

Simple question :)

Post by Flamie »

How can I remove a mysql row from php ?
exemple, remove row where ID='5'.
thx
Flamie
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

DELETE FROM table WHERE id = '5'
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

however, be careful with that, and make sure the primary key is ID so u dont accidnetly delete multiple rows :twisted:
Flamie
Forum Contributor
Posts: 166
Joined: Mon Mar 01, 2004 3:19 pm

Post 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 ?
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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;
Last edited by infolock on Thu Mar 04, 2004 1:11 pm, edited 2 times in total.
Flamie
Forum Contributor
Posts: 166
Joined: Mon Mar 01, 2004 3:19 pm

Post by Flamie »

ok thx a lot :)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Re: Simple question :)

Post 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. :)
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

twigletmac, yeah that was a typo on my part lol. my bad ;)
Post Reply