Wow, it's been awhile since I've posted...

Much has been going on in my life. My wife had foot surgery, which is good and bad. Good because when we go on walks with the pooch [<--new puppy, black lab] she won't experience pain anymore. Bad because she is stuck in the house while I'm at work for 2 months and is going nuts.

I've been screwing around with more PHP and MySQL and want to do more! I like it, Mikey, I really do!

We have a public calendaring program written in PHP from Able Design. It can be seen in action here. We have [or should I say 'had'] about 5 or 6 pages of static text describing our exhibitions, and it was getting tedious to update. Also a little rediculous to do both the calendar and static pages...especially when the shows change so much...sooooo

I wrote a little script on each exhibition page to pull that data from the calendar, and format it correctly on the page. All the folks that input it have to do is conform to some input criteria, and it works great. Maybe some day I'll get around to modifying the forms and db....

        $today = getdate();
        $year = $today[year];
        $currdate = $today[mday]." ";
        $currdate .= $today[month]." ";
        $currdate .= $today[year];

/*
This pulls data from the online exhibition calendar. Webhelp for end users details data forming for input.

array[0] = Title
array[1] = Date
array[2] = Museum
array[3] = Street Address
array[4] = City, State
array[5] = Blank Line
array[6] = Fee description
array[7] = Blank Line
array[8] = Exhibit Description
if ( ! empty(array[9] )) = More Exhibit Description


*/
$db = 'mycal';
$dbuser = 'myuser';
$dbpass = 'mypass';
$dbhost = 'localhost';

mysql_connect($dbhost,$dbuser,$dbpass) or die("could not connect");
mysql_select_db("$db") or die("could not open database");

  $query = "SELECT id,title,description,year,month,day FROM events\n";
  $query .= "LEFT JOIN calendar_cat ON events.cat=calendar_cat.cat_id\n";
  $query .= "WHERE year>=YEAR(CURDATE())\n";
  $query .= "AND month>=MONTH(CURDATE())\n";
  $query .= "AND day>=DAYOFMONTH(CURDATE())\n";
  $query .= "AND approved='1'\n";
  $query .= "AND cat_id='2'\n";
  $query .= "ORDER BY year,month,day ASC\n";

$result = mysql_query($query);
$num = mysql_num_rows($result);
$col = floor($num / 2);
$i = 0;

while ($row = mysql_fetch_object($result)) {

$i++;

$count = count(explode("<br />", $row->description));
$array = explode("<br />", $row->description);

// get our date data from array[1]

$date = trim($array[1]); // trim off white space at end
$arraydate = explode(" ", $date);
$smonth = $arraydate[0];
$sday = rtrim($arraydate[1],",");
$syear = $arraydate[2];
$sdate = $sday." ".$smonth." ".$syear;
// skip hyphen [3]
$emonth = $arraydate[4];
$eday = rtrim($arraydate[5],",");
$eyear = $arraydate[6];
$edate = $eday." ".$emonth." ".$eyear;


   if ( strtotime($sdate) >= strtotime($currdate) ) {

   echo "<p><a href=\"future_exhibits.php\">\n";
    echo $array[0]."</a><br>\n"; // the title
    echo $array[1]."</p>\n"; // the date
     if ( ! empty($array[8]) ) {
     $fsentence = substr($array[8], 0, strpos($array[8],'.'));
      echo "<p>".$fsentence.".<br>\n";
     }


                    if ( ! empty($array[8]) ) {
                  echo "</p>\n";
               }


   }


} // close loop
JC

Comments

Popular posts from this blog

NPI Search Redundancy

freeFTPD

Using ImageMagick and Tesseract to sort TIFFs on Windows