J'ai écrit une requête pour sélectionner la liste de la table des tâches et l'afficher dans la table, mais maintenant je veux obtenir une seule valeur de la table qui est id pour activer ou désactiver le travail, je suis frappé ici mon code est
<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>
Je n'ai besoin d'activer qu'une seule valeur de la table avec l'identifiant, alors aidez-moi d'une manière que j'ai créée la table de base de données
<?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>';
}
} elseif ($_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>';
}
}
?>
<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="hidden" name="jid" value="<?php echo $row['jid']; ?>"/>
<input type="submit" name="submit" value="activate"/>
</form>
<form action="" method="post">
<input type="hidden" name="jid" value="<?php echo $row['jid']; ?>"/>
<input type="submit" name="submit" value="deactivate"/>
</form>
</td>
</tr>
<?php
}
?>
<tr>
<td><p>Total Jobs:<?php echo $num_rows; ?></p></td>
</tr>
</tbody>
</table>
Cet article est collecté sur Internet, veuillez indiquer la source lors de la réimpression.
En cas d'infraction, veuillez [email protected] Supprimer.
laisse moi dire quelques mots