is_numeric
Posted: Thu Jun 09, 2005 3:29 pm
I'm writing a database applecation that insert update and deletes from a database. I have the whole thing writed but I have a bug with deleting row with an ID over 60 to 70. The way I have it working is when you want to delete a row the application uses the ID as the value of a checkbox. The id is then the varabile used to delete the row in the next page.
First page:
Second page:
As you can see I just get the defined_vars run them through a loop and use the numeric ones to delete the correct row. It works great on the lower numbered ID but it does not work with ID's of around 60 or higher.
any help would be great.
JCART | Please use
First page:
Code: Select all
$query = "select * from database where name='$name'";
$res = mysql_query($query);
if($res){
while($row=mysql_fetch_assoc($res)){
echo "<tr>";
echo "<td> <input type='checkbox' Name='", $row[id] , "' value='", $row[id] , "'></input></td>";
echo "<td>" , $row["name"] ,"</td></tr>";
}
}
else{
echo "<br />Resource not available";
}Code: Select all
$arr = get_defined_vars();
$count = count($arr);
for($i=0;$i<$count;$i++){
if(is_numeric($arr[$i])){
$query = "delete from database where id='$arr[$i]'";
mysql_query($query);
echo "Record " , $arr[$i] , " has been deleted\n";
}
}
mysql_close($conn);
?>any help would be great.
JCART | Please use
Code: Select all
tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color][/size]