Jump to content

Display (blank) values, duplicates, even if no record exists


cmattoon

Recommended Posts

Is there a way to force an SQL query to display blanks for values that dont' exist?

 

Once you select a date, it shows all scheduled events for that date, in half hour blocks. There are two half-hour blocks per time (see below). If something is scheduled, the time shows up as plain text, along with some information about the event.  If there is nothing scheduled at that time, it shows no information (obviously), and displays the time as a link. When the user clicks the link, it takes them to a page to register an event (keeps people from over-booking).

the times are displayed from $start to $end, as chosen on the first page. When I do a simple "generate times" php function, that prints two of each block on the screen from $start to $end, it works fine. When I use a standard SELECT * FROM where date='$date', it only displays the scheduled events.

 

07:00

07:00

07:30

07:30

08:00

08:00

08:30

08:30

etc...

 

Maybe generate times, then fill the other table cells depending on query using a foreach?

Link to comment
Share on other sites

Still showing existing trips only?

 

 

$sql2 = mysql_query("SELECT * FROM wcvschedule WHERE trip_date='$human_date' LEFT JOIN times ON wcvschedule.trip_time=times.txtime ORDER BY times.txtime");
$sql3 = mysql_query("SELECT * FROM wcvschedule, times WHERE times.txtime=wcvschedule.trip_time ORDER BY times.txtime");
//sql3 works, only shows trips that are entered..no blanks

$sql4 = mysql_query("SELECT times.*, wcvschedule.* FROM wcvschedule LEFT JOIN times ON wcvschedule.trip_time=times.txtime WHERE wcvschedule.trip_date='$human_date' ORDER BY times.txtime");

$sql5 = mysql_query("SELECT * FROM wcvschedule LEFT JOIN times ON times.txtime=wcvschedule.trip_time WHERE wcvschedule.trip_date='$human_date' ORDER BY times.txtime");

while($row = mysql_fetch_assoc($sql5)){

		if($row[khfd] == ""){
			$khfd = "";
			$trip_time = "<a href=\"../wcv/tx2.php?t=$row[trip_time]&d=$human_date\">$row[trip_time]</a>";
			$ptid = NULL;
		}else{
			$khfd = $row[khfd];
			$trip_time = $row[trip_time];
			$ptid = $row[pt_id];
		}
		echo "<tr><td>$khfd</td><td>$trip_time</td><td>$row[ref_fac]</td><td>$row[rec_fac]</td><td>$row[pt_id]</td><td>$row[driver]</td><td>$row[status]</td></tr>";
	}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.