Page 1 of 2

creating an tab

Posted: Fri Sep 17, 2010 1:47 am
by jhaustein
hi

i have two tables in my mysql db
1. members
2. dates

now i will create an table so that i´ve in the top row the dates from the mysql tab and in the first column the members
in the tab should be checkboxes so that a member can check the checkboxes if he has time or not

should be an attendance list

i don´t know how i can create such kind of table

Re: creating an tab

Posted: Fri Sep 17, 2010 1:33 pm
by Jonah Bron
Your question is unintelligible. Could you try to explain it again?

Re: creating an tab

Posted: Fri Sep 17, 2010 3:39 pm
by jhaustein
sorry

i have the following entries in my mysql db tab
member
id___name
1_peter
2_paul
3_mary

and in the tab dates
id___date
1___12.03.2010
2___23.04.2010
3___12.05.2010

now i will have the following output tab


________12.03.2010________23.04.2010_______12.05.2010
peter____checkbox_________checkbox__________checkbox
paul_____checkbox_________checkbox__________checkbox
mary____checkbox_________checkbox__________checkbox

now want to have the this tab with the checkboxes where i can check the checkboxes

Re: creating an tab

Posted: Fri Sep 17, 2010 3:54 pm
by Jonah Bron

Code: Select all

<table>
<tr>
<td></td>
<?php
$mysql = mysql_connect(/* your mysql info here */);

$query = mysql_query('SELECT * FROM dates', $mysql);
$count = 0;
while ($row = mysql_fetch_assoc($query)) {
    echo '<td>' . $row['date'] . '</td>';
    $count += 1;
}
?>
</tr>
<?php
$query = mysql_query('SELECT * FROM members', $mysql);
while ($row = mysql_fetch_assoc($query)) {
    echo '<tr>' . PHP_EOL . '<td>' . $row['name'] . '</td>' . PHP_EOL;
    for ($i = 0; $i < $count; $i++) {
        echo '<td><input type="checkbox" name="checkbox[]" value="???" /></td>' . PHP_EOL;
    }
    echo '</tr>' . PHP_EOL;
}
?></table>

Re: creating an tab

Posted: Fri Sep 17, 2010 3:58 pm
by jhaustein
hi

many thx

can you describe me how i can get the info´s of the checkboxes in my mysql tab

Re: creating an tab

Posted: Fri Sep 17, 2010 4:26 pm
by Jonah Bron
If you put what I gave you into a form (with method "post"), just loop through $_POST['checkbox'] on the target page.

Code: Select all

if (!isset($_POST['checkbox'])) {
    die();
}
foreach ($_POST['checkbox'] as $checkbox) {
    // do something with $checkbox.
}

Re: creating an tab

Posted: Fri Sep 17, 2010 4:34 pm
by jhaustein
sorry i don´t understand

first i need another mysql tab or?

for example
memberscheck
id_____id_member__________id_dates_______check

or how can i manage it

Re: creating an tab

Posted: Fri Sep 17, 2010 5:35 pm
by Jonah Bron
I really don't understand what you're trying to accomplish. Perhaps if you could explain what you're trying to do exactly I'd be able to help you. What is your country of origin?

Re: creating an tab

Posted: Sat Sep 18, 2010 12:39 am
by jhaustein
hi
i want to create an attendance list

so that a member can seethe list a can check the checkboxes of his row - if he i available or not

Re: creating an tab

Posted: Sat Sep 18, 2010 7:44 pm
by Jonah Bron
Okay, you need to change your date table to create a many-to-one relationship between the date and the members available.

Read this: http://en.wikipedia.org/wiki/One-to-many

[syntax]available_dates
id member date available
1 1 3-12-10 true
2 4 3-12-10 false
3 2 3-13-10 false
...
[/syntax]

You should make it so that each member can see his/her own checkboxes, not other people's.

Re: creating an tab

Posted: Sun Sep 19, 2010 12:21 am
by jhaustein
I think it is à Little difficult for me


i can create the new mysql tab with the datas you gave me - but i don´t know how to change the php code so that i get the datas in my html tab and how i can change it

can you help me more

Re: creating an tab

Posted: Sun Sep 19, 2010 11:36 am
by Jonah Bron
Sure, create the table and post what code you have (please surround your code with the [syntax=php][/syntax] tags when posting. You can use the PHP Code button).

Re: creating an tab

Posted: Sun Sep 19, 2010 1:44 pm
by jhaustein
now i have create the tab - but i don´t know how i can realize it

sorry

Re: creating an tab

Posted: Sun Sep 19, 2010 4:29 pm
by Jonah Bron
What do you mean you don't know how to "realize" it?

Re: creating an tab

Posted: Sun Sep 19, 2010 11:45 pm
by jhaustein
I don't Know the Code for the checkboxes
i really don't Know how to do it

Can you Show me how you ll do that