
08-25-10, 08:56 PM
|
|
Wannabe Coder
|
|
Join Date: Jul 2010
Posts: 132
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
|
mysql and checkboxex
What is wrong with this code PLEASE HELP ME
Last edited by job0107; 08-25-10 at 11:49 PM.
|

08-25-10, 11:47 PM
|
 |
Community Liaison
|
|
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
|
|
Quote:
Originally Posted by williamh26
What is wrong with this code PLEASE HELP ME
|
Your code doesn't make any sense.
First, there is no input element named "team", so $_POST["team"] doesn't exist.
Next, there is no variable named $team which you are using in your foreach loop.
Also, there is no point to your INSERT query because $hour doesn't have any meaning by itself.
And next, there is no relevance to your check boxes because they are not related to anything (team, player, etc...) and you are not collecting their values when the form is submitted (there is no $_POST["tutorhours"] variable), so you are not doing anything with them.
And last, your logic appears to be flawed.
__________________
Jerry Broughton
Last edited by job0107; 08-25-10 at 11:59 PM.
|

08-25-10, 11:53 PM
|
|
Wannabe Coder
|
|
Join Date: Jul 2010
Posts: 132
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
thank you, can help me to do it please
|

08-26-10, 12:03 PM
|
 |
Community Liaison
|
|
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
|
|
What are you trying to do?
__________________
Jerry Broughton
|

08-26-10, 10:22 PM
|
|
Wannabe Coder
|
|
Join Date: Jul 2010
Posts: 132
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
I am trying to populate from db the following"
_Start Time__ EndTime___ Book_____
9:00 am 9:30 am X --> check box
9:30 am 10:00am X --> check box
This is the table is tutorschedule
fields:
tutorscheduleid int increment
tutorid
starttime
endtime
book
So Populate the schedule of every tutor during the day. Then the customer can click the time available and to the db as an appointment. Then if someone else look for the same tutor it will show the checked and unchecked times (the checked times will be disabled so means it was already booked for someone else)
|

08-26-10, 10:47 PM
|
 |
Community Liaison
|
|
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
|
|
The tutorscheduleid should not be an auto-increment field.
It should be used to indicate a month of the year using values 1 through 12.
And then there would be an entry for each time slot for each tutorid for each month (tutorscheduleid).
The book field, starttime field and endtime field would not be needed.
Instead you would need only one field like scheduletime.
Example:
tutorscheduleid | tutorid | scheduletime
1 | 1 | hour1
1 | 1 | hour5
1 | 1 | hour9
1 | 1 | hour14
1 | 2 | hour1
1 | 2 | hour2
1 | 2 | hour3
1 | 2 | hour4
The following data would indicate that tutor 1 would have hour1, hour5, hour9 and hour14 booked for Janurary.
And tutor 2 would have hour1, hour2, hour3 and hour4 booked for Janurary.
After you have the table setup like this,
then you can query the table and dynamically create a form for each tutor using the values you already have in the form you showed earlier.
You will need two pieces of code.
One that will create the forms using the data in the database to show which times are booked and which are available.
And another that will update and/or add booked times to the database.
Another method would be to create a table with a field for each possible scheduletime (20 of them) and then you would only need one record for each tutor for each month.
This type of table, though it would have more fields (22 total fields), would be easier to program for.
That table might look like this:
tutorscheduleid | tutorid | h1 | h2 | h3 | h4 | h5 | h6 | h7 | h8 | h9 | h10 | h11 | h12 | h13 | h14 | h15 | h16 | h17 | h18 | h19 | h20 |
1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
1 | 2 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
The following data would indicate that tutor 1 would have hour1, hour5, hour9 and hour14 booked for Janurary.
And tutor 2 would have hour1, hour2, hour3 and hour4 booked for Janurary.
Before you begin to write the program you will need to choose a schema for your table.
I personally would choose the second method as it would be easier to create a program for it.
And you already have most of the basic form created that you could use as a guide.
It would also be helpful if you had another table that would contain the tutorName and tutorid.
It could be used to create an HTML select box that would be used to lookup a tutor's schedule.
Also you could have another HTML select box that would contain all the possible months that the tutors may be available.
It could then be used in conjunction with the tutors Name to lookup a schedule for a particular month.
__________________
Jerry Broughton
Last edited by job0107; 08-26-10 at 11:35 PM.
|

08-26-10, 11:58 PM
|
|
Wannabe Coder
|
|
Join Date: Jul 2010
Posts: 132
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Thank you for ur advise that what i have right now
<?php
$error = "Could not connect to the database";
mysql_connect('localhost','root','') or die($error);
mysql_select_db('learningcenter') or die($error);
$query = "SELECT scheduletime from tutorschedule where tutorid=$tutorid";
$result = mysql_query($query);
$row=mysql_fetch_assoc($result);
$scheduletime = $row['scheduletime'];
echo"<table border='1'>";
echo"<tr>";
echo"<td>$scheduletime</td>";
echo"</tr>";
echo"</table>";
?>
that show me the time of each tutor, my next question will be how set up the code in order to show available and unavailble time?? do i need another field??
Again thank you
I was thinking if i have another two fields like Open and Close type TINYINT as a link
echo"<table border='1'>";
echo"<tr><td>Schedule</td><td>Close</td><td>Open</td></tr>";
echo"<tr>";
echo"<td>$scheduletime</td>";
echo"</tr>";
echo"</table>";
wHAT U THINK??
<?php
$error = "Could not connect to the database";
mysql_connect('localhost','root','') or die($error);
mysql_select_db('learningcenter') or die($error);
$query = "SELECT scheduletime, open , close from tutorschedule where tutorid=$tutorid";
$result = mysql_query($query);
$row=mysql_fetch_assoc($result);
$scheduletime = $row['scheduletime'];
$open = $row['open'];
$close =$rwo['close'];
echo"<table border='1'>";
echo"<tr><td>Schedule</td><td>Open</td><td>Close</td></tr>";
echo"<tr>";
echo"<td>$scheduletime</td><td>$open</td><td>$close</td>";
echo"</tr>";
echo"</table>";
?>
Last edited by williamh26; 08-27-10 at 12:13 AM.
|

08-27-10, 12:23 AM
|
|
Wannabe Coder
|
|
Join Date: Jul 2010
Posts: 132
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
I have this waht u think??
<?php
$error = "Could not connect to the database";
mysql_connect('localhost','root','') or die($error);
mysql_select_db('learningcenter') or die($error);
$query = "SELECT scheduletime, open , close from tutorschedule where tutorid=$tutorid";
$result = mysql_query($query);
$row=mysql_fetch_assoc($result);
$scheduletime = $row['scheduletime'];
$open = $row['open'];
$close =$row['close'];
echo"<table border='1'>";
echo"<tr><td>Schedule</td><td>Open</td><td>Close</td></tr>";
echo"<tr>";
echo"<td>$scheduletime</td><td><a href='index.php?content=timeopen&start=$open'>Open </a></td><td><a href='index.php?content=timeclose&start=$close'>Cl ose</a></td>";
echo"</tr>";
echo"</table>";
?>
|

08-27-10, 01:01 AM
|
 |
Community Liaison
|
|
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
|
|
You didn't read what I said very carefully.
You need to think about it some more.
I could write it all for you, but that wouldn't help you to learn.
And if you aren't really interested in learning then I would be more than happy to write code for you if you are willing to pay $25.00 an hour for my time.
$100.00 minimum.
__________________
Jerry Broughton
|

08-27-10, 08:31 AM
|
|
Wannabe Coder
|
|
Join Date: Jul 2010
Posts: 132
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
That's is what i asked you, cuz i wanna learn!!!!!! i just learning!!!!!! and in order to learn i have to ask questions... right???
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|