Jump to content

displaying records


ROCKINDANO

Recommended Posts

Hello everyone, i have a problem with a project. i have two tables where one has more records than the other one and i want to display all the records from both tables in a 3 column table. the first column holds the date the second column holds the file name of the large table and the third holds the file name of the records of the smaller table. the smaller table is going to get populated within time eventually matching the number of records in large table.

 

now i have it where i do two queries. first is the large table query and displays all the records in the in the fist two columns. then i have the 2nd query for the small table and this is where i have a problem. I want to display the name of the file (a link to the file) in the third column if there is a record in that table that matches the query else display a blank in that column.

 

but it seems i have a problem on getting the blank to fill the third column when there are no more records in that small table.

 

here is what i have so far.

    <?php 
		if(!($db = @ mysql_connect('localhost', 'un', 'pass')))
		{
			print "Error: Could not connect to our database sorry for any inconvience.<br /> Please try at a later time.";
		}						
		 //select which database you want to edit
		mysql_select_db("dbsite"); 
		$agenda_id=$_GET[agenda_id];

            print "<center><table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\" style=\"border: 0px solid #2c4876\"><tr bgcolor='#0000ff' style='font-weight: bold; color: #ffffff;'><td width='20%' align='center'>Meeting Date</td><td align='center' width='20%'>Agenda Notice</td><td align='center' width='19%'>Agenda Packet</td>";			

		$query = "SELECT * FROM ccagenda ORDER BY agenda_id DESC";
		$result=mysql_query($query);

		while ($r=mysql_fetch_array($result))
		{
			$agenda_id=$r['agenda_id'];
			$adate=$r['adate'];
			$file=$r['file'];

			print "<tr><td colspan=\"3\">";
			print "<table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"2\" bgcolor=\"#d2d6db\">";
                print "<tr>";
                print "<td width=\"20%\" align=\"left\" style=\"color:#3949f9\">" .strtoupper($adate). "</td>";
                print "<td align=\"right\" width=\"20%\"><a href='pdfs/{$file}' target='_blank'>Agenda Notice</a> <img src=\"images/pdfimage.png\" title=\"\" border=\"0\" /></td>";

			$query2 = "SELECT * FROM packets where packets.file = '{$file}'";
			$result2 = mysql_query($query2);

			while ($r = mysql_fetch_array($result2))
			{
				$agenda_id = $r['agenda_id'];
				$file2 = $r['file'];
				$adate=$r['adate'];

            //THIS IS WHERE I HAVE THE PROBLEM*************************
				if (!empty($file2))
				print "<td width='19%' style=\"text-align: right\"><a href='pdfs/packets/{$file}' target='_blank'>Agenda Packet </a><img src=\"images/pdfimage.png\" title=\"\" border=\"0\" /></td>";
                                        else 
                                           print "<td>A BLANK IN THE COLUMN</td>";
			}
                print "</tr>";
                print "</table>";
			print "</td></tr>";			
		}
		print "</table></center>";
	?>

 

Can someone help me with this?

 

Thank you.

Link to comment
https://forums.phpfreaks.com/topic/183583-displaying-records/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.