i want to select multiple check boxes to retrieve data from database and display the checked boxes. but now i am having problem displaying the checked boxes. i have no error but i cannot display my checked data. this is my coding
<?php
$sql = "select * from contact_master";
$query = mysqli_query($conn, $sql) ;
while ($row = mysqli_fetch_array($query)){
?>
<tr class="odd gradeX" >
<td><input type="checkbox" name="chk[]" class="chk-box"/></td>
<td><?php echo $row['Contact_Name']; ?> <input type="checkbox" id="myCheck" name="chk[]" class="chk-box" onclick="myFunction()"/></td>
<td ><?php echo $row['Contact_Phone']; ?><input type="checkbox" id="myCheck" name="chk[]" class="chk-box" onclick="myFunction()" /></td> <td><?php echo $row['Contact_Email']; ?><input type="checkbox" id="myCheck" name="chk[]" class="chk-box" onclick="myFunction()"/></td>
<td ><?php echo $row['Contact_Facebook']; ?><input type="checkbox" id="myCheck" name="chk[]" class="chk-box" onclick="myFunction()"/></td> <td ><?php echo $row['Contact_Wechat']; ?><input type="checkbox" id="myCheck" name="chk[]" class="chk-box" onclick="myFunction()"/></td>
<td ><?php echo $row['Contact_Whatsapp']; ?><input type="checkbox" id="myCheck" name="chk[]" class="chk-box" onclick="myFunction()"/></td>
<td ><?php echo $row['Contact_Linkin']; ?><input type="checkbox" id="myCheck" name="chk[]" class="chk-box" onclick="myFunction()"/></td>
<td ><?php echo $row['Contact_Twitter']; ?><input type="checkbox" id="myCheck" name="chk[]" class="chk-box" onclick="myFunction()"/></td>
<input type="submit" name="submit" value="Submit"/>
//this is how i connect data from the database
<?php
$sql = "SELECT * FROM contact_master";
$result = mysqli_query( $conn, $sql );
if( $result ){
// success! check results
while( $row = mysqli_fetch_assoc( $result )){
$i = 0
{
$Contact_Name = $row['Contact_Name'];
if(isset($_POST[$Contact_Name])!=NULL)
{
$i = 0;
$i++;
mysqli_query("select * from contact_master Where Contact_Name = $Contact_Name")or die(mysql_error());
}}}}
$i = 0;
echo "Selected Contact".$i['Contact_Name']
?>
</html>
</tr>
Aucun commentaire:
Enregistrer un commentaire