daver40 0 Newbie Poster

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:

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