i have a list of rows from my db with delete next to each row but ajax is always deleting the first row in the list no matter what.
PHP CODE >>>>>>
$allowedFunctions = array(
'add_job',
'get_log',
'delete'
);
$functionName = $_GET[ 'func' ];
if( in_array( $functionName, $allowedFunctions ) && function_exists( $functionName ) )
{
$functionName();
}
PHP DISPLAY PAGE >>>>>>
function manage(){
dbconnect();
$qry="SELECT server,id,email,lstcheck,running,runtime,pid FROM adds";
$result=mysql_query($qry);
$i = 0;
echo"<table id='customers'>
<tbody><tr>
<th>Server</th>
<th>Id</th>
<th>Email</th>
<th>Check Date</th>
<th>Delete</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "
";
if($i%2 == 0)
{
$tr="<tr>";
$i++;
} else {
$tr="<tr class='alt'>";
$i++;
}
echo"$tr
<td><input type='text' name='sip' id='sip' size='10' value='".$row['server']."' /></td>
<td><input type='text' name='id' id='id' size='10' value='".$row['id']."'/></td>
<td><input type='text' name='email' id='email' size='10'value='".$row['email']."' /></td>
<td><input type='text' name='lstchk' id='lstchk' size='10'value='".$row['lstcheck']."' /></td>
<td><input type='submit' name='Submit' id='Submit' onClick=\"getAjaxInfom('delete')\" value='Remove' /></td>
</tr>";
}
echo"</tbody></table><div id='resultm'></div>";
}
DELETE FUNCTION>>>>>
function delete() {
dbconnect();
$sip = $_GET[ 'sip' ];
$id = $_GET[ 'id' ];
$email = $_GET[ 'email' ];
$lstchk = $_GET[ 'lstchk' ];
$ok = $_GET[ 'ok' ];
mysql_query("delete from adds where id='$id'");
echo $sip .$id.$email;
}
AJAX CODE>>>>>>>>>
function getAjaxInfom(f) { // submit buton function
var myFunction= f;
var sip = document.getElementById("sip").value;
var id = document.getElementById("id").value;
var email = document.getElementById("email").value;
var lstchk = document.getElementById("lstchk").value;
var url = "includes/func.php?func=" + myFunction + "&sip=" + sip +"&id=" + id +"&email=" + email +"&lstchk=" + lstchk +"";
request.open("GET", url, true);
request.onreadystatechange = updatePage1;
request.send(null);
}
function updatePage1() {
if (request.readyState == 4) {
if (request.status == 200) {
var response = request.responseText;
document.getElementById("resultm").innerHTML = response; //responce for submit
} else
alert("status is " + request.status);
}
}
need some help on this