I got a list of id from 1 table . I recently make a few change to the table where i add another column(Active) for id activation . The table look like this
ID | name | active
---|------|-------
01 | Jack | 1
02 | Ben | 1
The list show if the id is active , i use yellow bulb icon and if not active it show grey bulb icon . The problem i got is if i want to change the activation status of the id, it doesnt fetch the result(show only blank page).
SQL
$sql = "SELECT * FROM jobseeker";
$res = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($res))
INDEX PHP
<td align="center"><?php if($row['active']) == '1'){ ?>
<a href ="action.php?ID=<?php echo $row['ID']; ?>" onclick="return confirm ('You want to deactivate ?\n\nNo ID: <?php echo $row['ID']; ?>')"><img src="images/on.png" width="16" height="16" border="0" alt="Deactivate" style="cursor:pointer" align="absbottom" /></a>
<?php } if($row['active'] == '0'){ ?>
<a href ="action.php?ID=<?php echo $row['ID']; ?>" onclick="return confirm ('You want to activate ?\n\nNo ID: <?php echo $row['ID']; ?>')"><img src="images/off.png" width="16" height="16" border="0" alt="Activate" style="cursor:pointer" align="absbottom" /></a>
<?php } ?></td>
ACTION PHP
<?php
session_start();
require_once "inc/db.php";
require_once "inc/tarikh.php";
if(isset($_GET['active'])){
$status=$_GET['active'];
$sql_status=mysql_query(" SELECT * FROM jobseeker WHERE id =".$status);
while($row=mysql_fetch_object($sql_status)){
$st=$row->active;
if($st=='0'){
$status2=1;
}
else{
$status2=0;
}
$update=mysql_query("UPDATE jobseeker SET active = ".$status2. WHERE ID = ".$status);
if($update){
header("Location: jobseeker_list.php");
}
else{
echo mysql_error();
}
}
?>
Is there anything wrong with my code ? Please help me out
mysql_functions are deprecated. Please consider switching to PDO instead.