Jump to content

[SOLVED] Check Box ,MYSQL Data Base and PHP


binumathew

Recommended Posts

Friends,

 

Think that there is 50 students in the class.....i like to make a attence application for them....i am thinking of using Check Box for nice functioning of the App....What i mean is .... i will list 50 names and there will be a check box....if the teacher click on the check box then the student will mark as absent...am i need to write so much mysql connection and querey for doing this??whats your suggestion??can u gave me a code sample at the same time.....can you tell me how we can post a data from the checked box

Link to comment
Share on other sites

<form action="" method="post">

<input type="checkbox" name="absent[]" value="1"> student #1<br> <input type="checkbox" name="absent[]" value="2"> student #2<br> <input type="checkbox" name="absent[]" value="3"> student #3<br> <input type="checkbox" name="absent[]" value="4"> student #4<br> <input type="checkbox" name="absent[]" value="5"> student #5<br> <input type="submit" name="submit" value="submit"> </form>

 

<?php

if (isset($_POST['submit']))

{

if (isset($_POST['absent']))

{

foreach ($_POST['absent'] as $value)

{

$sql = 'INSERT INTO absent_table set date = NOW(), student_id = ' .  $value;

echo $sql . '<br>';

}

}

else

{

echo 'everybody made it to class, yay';

}

}

?>

solution i got

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.