Log in

View Full Version : Problem in reuse of variable



MSK7
06-25-2009, 07:51 AM
Hello all ,

In my form a list of Category names are retrieved from

database & displayed as Link on it.

onclick of this category named link it send its row id to the

second page & there using a variable recieve this id as



$id = $_GET['id'] ;


then use this variable to show all the data of this row id

using in a query as


$sql = "SELECT * FROM `mytable` WHERE `ID`='$id' ";


& this shows all the data successfully .

But the problem arises that when i reuse this recieved

variable $id , for another query to Delete this specific row

as


echo " DELETE FROM `mytable` WHERE `ID` = '$id' ";


the value of this id in Delete query displayed Blank (using echo) as



DELETE FROM `mytable` WHERE `ID` = ''


& So Delete operation is not performed successfully .

I don't understand why this variable $id can't

reuse its value again in other queries also there rather than

only once .

Please suggest solutions regarding these.


Thanks & Regards.