Jump to content

Relatively simple PHP help needed


howard-moore

Recommended Posts

Hi All,

 

I have a snippet of PHP code that I use to call results from a MySQL database with dates, categories and descriptions.

 

I have added two new fields to the MySQL table called 'agenda' and 'minutes'.

 

These two fields contain a path to a file, but not all the entries will have the field completed.

 

What I want to know is how I need to edit my code so that it shows the path to the file if it is present, but displays nothing if it is not present. The complicating factor is that I also want the code to return the requirements for a hyperlink if the field has been populated: e.g. <a href="../meetings/agendas/$agenda">+ download</a>, but return nothing at all, or better still something saying that there is nothing to download if the field has not been populated.

 

The script I have done so far is:

 

<?php
include("MeetingsConfig.php");
include("../config/config.php");
$daysAhead = 60;
?>

<?php
$sql = "SELECT * FROM `PC_$filename`
          WHERE startDate between '".date("Y-m-d")."' AND '".date("Y-m-d",mktime(0, 0, 0, date("m"), date("d")+$daysAhead, date("Y")))."' AND type = 'Meeting'
          ORDER BY startDate ASC";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
while ($row = mysql_fetch_assoc($sql_result)) {
	if ($row["description"]<>'') {
		echo '<table class="calendar_list"><tr><td class="calendar_list_date_';
		echo nl2br(stripslashes(utf8_decode($row["type"]))).'">';
		echo date("F j, Y",strtotime($row["startDate"])).'  »  <strong>';
		echo nl2br(stripslashes(utf8_decode($row["type"]))).'</strong></td></tr>';			
		echo '<tr><td class="calendar_list_description">';
		echo nl2br(stripslashes(html_entity_decode($row["description"]))).'<br /><br /><table><tr><td>';
	};
};
?>

 

Hope someone can help!

 

Rgds,

Neil

Link to comment
https://forums.phpfreaks.com/topic/194939-relatively-simple-php-help-needed/
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.