Hi all!
I'm trying to fetch the first item from MSSQL table, save it into php variable and then delete it from the table:
table name - tblMACJumpPool
[ intBlockID(int), strMac(varchar12) ]
values:
12,1
12,2
12,3
12,4
My Code:
[code
<?php
include("connect.php");
include("head.php");
function GetJumpMAC($block_id)
{
$get_jump_query = "SELECT strMAC FROM tblMACJumpPool WHERE intBlockID = '$block_id'";
$get_jump_result = mssql_query($get_jump_query) or die('Error, select query failed');
while($row_jump = mssql_fetch_array($get_jump_result, MSSQL_ASSOC))
{
$jump = "{$row_jump['strMAC']}";
return $jump; //echo "Current-->" . $jump . "<br>";
}
}
$counter=1;
$get_n=1;
$get_b_id=12;
while ($counter <= $get_n) {
$jumpmac = GetJumpMAC($get_b_id);
//$jumpmac='2';
$delete_query = "DELETE FROM tblMACJumpPool WHERE strMac = '$jumpmac'";
mssql_query($delete_query) or die('Error, delete query failed');
$counter++;
}
Now the problem is that when i run this php page, 2 rows being deleted instead of 1!
when i remove the include for 'head.php' all works fine, but this file included in all of my pages..
also when i unmark //$jumpmac='2'; , it will delete only 1 row as it suppose to do.
so i'm very confused
I done it lots of times and it worked this way, but this time it doesn't work good.
Hope you can help me,
thanks in advance!