i want to use session variable in the code. my requirement is that when i click on "edit/Delete" button,record against the correspondence row is deleted automatically. can any one plz help me how to resolve this problem and also tell me how to use session variable.
`<?php
while($row = $result->fetch_array())
print("
<tr>
<td> $row[0] </td>
<td> $row[1] </td>
<td> $row[2] </td>
<td> $row[3] </td>
<td> $row[4] </td>
<td> <a href='dscm-Emp-Modification.php?ID= $row[0]'>Edit</a></td>
<td> <a href='dscm-Emp-Delete.php?DID= $row[0]'>Delete</a></td>
</tr>
");
?>`
i tried following codes but neither of them worked for me:
//method 1
while($row = $result->fetch_array())
$_SESSION['a']=$row[0];
$_SESSION['b']=$row[1];
$_SESSION['c']=$row[2];
$_SESSION['d']=$row[3];
$_SESSION['e']=$row[4];
print("
<tr>
<td> $_SESSION[a] </td>
<td> $_SESSION[b] </td>
<td> $_SESSION[c] </td>
<td> $_SESSION[d]</td>
<td> $_SESSION[e]</td>
<td> <a href='dscm-Emp-Modification.php?ID= $row[0]'>Edit</a></td>
<td> <a href='dscm-Emp-Delete.php?DID= $row[0]'>Delete</a></td>
</tr>
");
//method 2
{
for ($a=0; $a<=4; $a++){
$_SESSION['data']=$row;
print("
<tr>
<td> $_SESSION[data] </td>
<td> $_SESSION[data] </td>
<td> $_SESSION[data] </td>
<td> $_SESSION[data] </td>
<td> $_SESSION[data] </td>
<td> <a href='dscm-Emp-Modification.php?ID= $row[0]'>Edit</a></td>
<td> <a href='dscm-Emp-Delete.php?DID= $row[0]'>Delete</a></td>
</tr>
");
}
}
You need to call the session_start()
function befor use the $_SESSION
-Array.
Please read more about sessions in the PHP documentation here.