Hello, I can’t seem to get this figured out so I was hoping somebody could help me. I am trying to take 3 queries and combine them into one result so I can sort by date. It works fine when I run 3 separate queries but I can only sort each query and I need to sort them together. Here is what I came up with to do this but it does not return any results. I am new to this so the code may not look very good. Please help.
<?php $conn = mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("database",$conn) or die(mysql_error()); $get_birthday= "SELECT master_name.f_name, spouse_name.s_f_name, child_name.c_f_name AS 'first_name', master_name.l_name, spouse_name.s_l_name, child_name.c_l_name AS 'last_name', master_name.m_birthday, spouse_name.s_birthday, child_name.c_birthday AS 'birthday', (DAYOFYEAR(NOW() +INTERVAL 20 day) - DAYOFYEAR('birthday')) AS 'diff' FROM master_name, spouse_name, child_name HAVING 'diff' BETWEEN 1 AND 20"; $birthday= mysql_query($get_birthday); if (mysql_num_rows($birthday) > 0) { $display_block .= "Upcoming Birthdays:
"; while ($bday_info = mysql_fetch_array($birthday)) { $bday = $bday_info['birthday']; $bday_format = date('mm/dd/yyyy', strtotime($bday)); $f_name = $bday_info['first_name']; $l_name = $bday_info['last_name']; $display_block .= "$f_name $l_name:"; $display_block .= "$bday_format
"; } } else { $display_block .= "
There are no upcomming birthdays
"; } ?> <? print $display_block; ?>