Jump to content

displaying records from db


ROCKINDANO

Recommended Posts

Hey all i have a problem, i have a page that displays a list of records (files) for this year but i want to display two types of files. these files that i am trying to display have a a small version of the file and a large version of the file. i need to display both ver. from two db tables that are hold all the information from both files.

 

this is what i have:

    <?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("db_name"); 
		$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/citysect/{$file}' target='_blank'>Agenda</a> <img src=\"images/pdfimage.png\" title=\"\" border=\"0\" /></td>";

			$query2 = "SELECT * FROM packets";
			$result2 = mysql_query($query2);

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

				if($file2 == $file)
				{
					print "<td width='19%' style=\"text-align: right\"><a href='pdfs/citysect/packets/{$file}' target='_blank'>Full Packet </a><img src=\"images/pdfimage.png\" title=\"\" border=\"0\" /></td><td> </td>";
				}
				else if($file2 != $file)
				print "<td width='19%' align='right'>No Packets</td>";
			}

                print "</tr>";
                print "</table>";
			print "</td></tr>";			
		}
		print "</table></center>";
	?>

 

can someone help me?

 

thank you in advance

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

can someone tell me why why this piece of code is doing this?

 

<?php
		$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=\"1\" 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/citysect/{$file}' target='_blank'>Agenda</a> <img src=\"images/pdfimage.png\" title=\"\" border=\"0\" /></td>";

			$query2 = "SELECT * FROM packets where file = '{$file}'";

			$result2 = mysql_query($query2);

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

//					if($file2 == $file)
					print "<td width='19%' style=\"text-align: right\"><a href='pdfs/citysect/packets/{$file}' target='_blank'>Full Packet </a><img src=\"images/pdfimage.png\" title=\"\" border=\"0\" /></td>";

                 //IT IS NOT GOING INTO THIS IF STATEMENT. AND DOESN'T PRINT THE 
				if($file2 != $file)
				print "<td width='19%' align='right'>No Packet</td>";
			}

                print "</tr>";
                print "</table>";
			print "</td></tr>";			
		}
		print "</table></center>";
	?>

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.