•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 455,979 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,786 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 619 | Replies: 0
![]() |
•
•
Join Date: Oct 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
I'm working on several scripts that form a small, custom build appointment scheduling application. I'm having some trouble with a function that I'm using to check whether appointments for individual times during a given day exist in the database. The function:
1) creates a table
2) uses the date function to loop through all available days
3) checks these days against times in the database, and if the time doesn't exist in the database, displays a radio button to select it for an appointment.
The problem is that the function always evaluates each time as false, even when it exists in the database.
Here's my code:
Thanks for the help,
David
1) creates a table
2) uses the date function to loop through all available days
3) checks these days against times in the database, and if the time doesn't exist in the database, displays a radio button to select it for an appointment.
The problem is that the function always evaluates each time as false, even when it exists in the database.
Here's my code:
function display_time($date, $comp) {
//Set database access variables
$host ='mssql.library.uiuc.edu';
$user = 'BEL_webuser';
$pass ='NeUn72L';
$db = 'BEL';
//Open connection
$connection = mssql_connect($host, $user, $pass) or die("Unable to connect");
//Select database
mssql_select_db($db) or die("Unable to select database");
// create query
$query = "SELECT time FROM bloomberg WHERE(date = N'11-09-2007')";
// execute query
$result = mssql_query($query) or die ("Error in query");
//Create table from with each hour of the day
$start = strtotime('8:30am');
echo "<table border = '1' align = 'center'>";
echo "<tr>";
echo "<th>time</th>";
echo "<th>select</th>";
echo "</tr>";
for($i = 0; $i < 17; $i++){
echo $timeflag;
$tod = $start + ($i * 60 * 30);
$display = date('h:i', $tod);
echo "<tr>";
echo "<td>$display</td>";
if($tableflag == 1){
echo "<td>1</td>";
}
else {
echo "<td>0</td>";
}
for ($j = 0; $j < mssql_num_rows($result); $j++){
$row = mssql_fetch_row($result);
$time = $row[0];
if($time == $display){
$tableflag = 1;
}
}
echo "</tr>";
}
echo "</table>";
//close connection
mssql_close($connection);
}
Thanks for the help,
David
Last edited by daver40 : Nov 30th, 2007 at 12:03 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- memory management in wndows 2000 (Windows NT / 2000 / XP / 2003)
- Accessing a specific calander when calling outlook.application (Visual Basic 4 / 5 / 6)
- pthreads scheduling problem? (C)
- java problem with creating arrays (Java)
Other Threads in the PHP Forum
- Previous Thread: Detect User Details?
- Next Thread: Creating a dynamic query using MSSQL and PHP


Linear Mode