how for me to get one value of checkbox if i checked two checkbox, so i can make warn when i want to edit category. only need one value to be PrimaryKey for edit category.
$query="select * from category";
$query_exec = mysqli_query($conn, $query) or die(mysqli_error($conn));
while($data = mysqli_fetch_array($query_exec))
{
echo"<tr>";
echo"<td>"."<input type='checkbox' name='check_list[]' value='".$data['kode_kategori']."'/>"."</td>";
echo"<td id='width_txt'>".$data["kode_kategori"]."</td>";
echo"<td id='width_txt'>".$data["nama_kategori"]."</td>";
echo"<td id='width_txt'>".$data["inisial_produk"]."</td>";
echo"<td id='width_txt'>".$data["status_kategori"]."</td>";
echo"</tr>";
}
<td><input type="submit" name="edit" value="Edit" /></td>
<?php
if(isset($_POST['edit']))
{
$check_list = $_POST['check_list'];
if(empty($_POST['check_list']))
{
echo ("<script language='javascript'>
alert('Pls checklist first.');
</script>");
}
else
{
$n = count($check_list);
foreach($check_list as $check)
{
for($i=0; $i < $n; $i++)
{
if($i == 0)
{
echo ("<script language='javascript'>
window.location='http://ift.tt/1StF1O5';
</script>");
}
else
{
echo ("<script language='javascript'>
alert('Only need one value.');
</script>");
}
}
}
}
}
?>
So this is it the code..
Aucun commentaire:
Enregistrer un commentaire