creating an tab

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

jhaustein
Forum Newbie
Posts: 11
Joined: Fri Sep 17, 2010 1:40 am

creating an tab

Post 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
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: creating an tab

Post by Jonah Bron »

Your question is unintelligible. Could you try to explain it again?
jhaustein
Forum Newbie
Posts: 11
Joined: Fri Sep 17, 2010 1:40 am

Re: creating an tab

Post 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
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: creating an tab

Post 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>
jhaustein
Forum Newbie
Posts: 11
Joined: Fri Sep 17, 2010 1:40 am

Re: creating an tab

Post by jhaustein »

hi

many thx

can you describe me how i can get the info´s of the checkboxes in my mysql tab
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: creating an tab

Post 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.
}
jhaustein
Forum Newbie
Posts: 11
Joined: Fri Sep 17, 2010 1:40 am

Re: creating an tab

Post 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
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: creating an tab

Post 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?
jhaustein
Forum Newbie
Posts: 11
Joined: Fri Sep 17, 2010 1:40 am

Re: creating an tab

Post 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
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: creating an tab

Post 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.
jhaustein
Forum Newbie
Posts: 11
Joined: Fri Sep 17, 2010 1:40 am

Re: creating an tab

Post 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
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: creating an tab

Post 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).
jhaustein
Forum Newbie
Posts: 11
Joined: Fri Sep 17, 2010 1:40 am

Re: creating an tab

Post by jhaustein »

now i have create the tab - but i don´t know how i can realize it

sorry
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: creating an tab

Post by Jonah Bron »

What do you mean you don't know how to "realize" it?
jhaustein
Forum Newbie
Posts: 11
Joined: Fri Sep 17, 2010 1:40 am

Re: creating an tab

Post 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
Post Reply