I wrote a query to select list from job table and display it in table but now I want to get only one value from the table that is id to activate or deactivate the job I am struck here my code is
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>JOb ID</th>
<th>CompanyID</th>
<th>Job Description</th>
<th>Duration</th>
<th>Budget</th>
<th>KeySkills</th>
<th>Joining Date</th>
<th>Expiry Date</th>
<th>Min Experience</th>
<th>Max Experience</th>
<th>Status</th>
<th>Set Status</th>
</tr>
</thead>
<tbody>
<?php
$res=mysql_query("SELECT * FROM job ORDER BY jid DESC");
while($row=mysql_fetch_array($res))
{
$num_rows = mysql_num_rows($res);
?>
<tr>
<td><p><?php echo $row['jid']; ?></p></td>
<td><p><?php echo $row['cid']; ?></p></td>
<td><p><?php echo $row['jdesc']; ?></p></td>
<td><p><?php echo $row['duration']; ?></p></td>
<td><p><?php echo $row['budget']; ?></p></td>
<td><p><?php echo $row['keyskills']; ?></p></td>
<td><p><?php echo $row['jdate']; ?></p></td>
<td><p><?php echo $row['edate']; ?></p></td>
<td><p><?php echo $row['cdexmin']; ?></p></td>
<td><p><?php echo $row['cdexmax']; ?></p></td>
<td><p>
<?php if($row['status']=="active")
{
echo "Active";
}
else {
echo "Inactive";
} ?></p></td>
<td>
<form action="" method="post"> <input type="submit" name="submit" value="activate" />
<?php
if($_POST['submit']=='activate')
{
$jid=$_POST['jid'];
$delet_query = mysql_query("UPDATE job SET status='active' WHERE jid='". $jid."' ") or die(mysql_error());
if($delet_query) {
echo 'job with id '.$row[jid].' is activated, to refresh your page, click'. '<a href='.$_SERVER["PHP_SELF"].' > here </a>';
}
}?>
</form>
<form action="" method="post"><?php $_POST['jid']=$row['jid'] ?><input type="submit" name="submit" value="deactivate" />
<?php
if($_POST['submit']=='deactivate')
{
$jid=$_POST['jid'];
$delet_query = mysql_query("UPDATE job SET status='deactive' WHERE jid='". $jid."' ") or die(mysql_error());
if($delet_query) {
echo 'job with id '.$row[jid].' is deactivated, to refresh your page, click'. '<a href='.$_SERVER["PHP_SELF"].' > here </a>';
}
}?>
</form>
</td>
</tr>
<?php
}
?>
<tr>
<td> <p>Total Jobs:<?php echo $num_rows; ?></p></td>
</tr>
</tbody>
</table>
I need to activate only one value from the table with id so please help me in a way that I created database table
mysql_fetch_row()instead ofmysql_fetch_array, or 2. usewhere clausein yourselect query