I am just learning, but it feels like the whole lightbulb effect went haywire. I feel like why didn't I learn this earlier?
I have been designing static sites for a couple of years for fun, 'cos at work, I create training material and publish on an intranet. I use DW as my WYSIWYG.
For the past week or two, while beginning to learn PHP, I have rarely looked at anything but the code view in DW, where in the past, I could barely understand what I was looking at in that view.
Here is my almost final code. You may find it amusing how I am breaking up the courses by state into different queries. This is to allow for me putting their links in to direct the user to the appropriate directories 'details' page AND so that I can color code the links state by state, so they have a different look on the page to make it easy for the viewer to read the lists...
<?php
require "db.inc.php"; // connect to database
$connectMe_db = connecting2_db(); // "connecting2_db()" function on db.inc.php
$str_selection = "SELECT title,author FROM books WHERE display='yes'"; // first db query
$results_books = mysql_query ($str_selection,$connectMe_db) or db_mysql_die(); // "db_mysql_die()" function on db.inc.php
print ('<ul>');
while ($articleDb =mysql_fetch_object($results_books))
{
print("<li><strong>$articleDb->title</strong> $articleDb->author</li>");
}
print ('</ul>');
print ('<hr>'); // End of getting books. Now get Golf IL Courses:
$str_selection2 = "SELECT name,location FROM courses Where location='il'"; // second db query
$results_courses_il = mysql_query($str_selection2,$connectMe_db) or die('This query showed an error: query1; '.mysql_error());
print ('<ul>');
while ($articleDb2 =mysql_fetch_object($results_courses_il))
{
print("<li><strong>$articleDb2->name</strong>, $articleDb2->location</li>");
}
print ('</ul>');
print ('<hr>'); // End of getting il courses. Now get AZ Courses:
$str_selection3 = "SELECT name,location FROM courses Where location='az'"; // third db query
$results_courses_az = mysql_query($str_selection3,$connectMe_db) or die('This query showed an error: query1; '.mysql_error());
print ('<ul>');
while ($articleDb3 =mysql_fetch_object($results_courses_az))
{
print("<li><strong>$articleDb3->name</strong>, $articleDb3->location</li>");
}
print ('</ul>');
print ('<hr>'); // End of getting az courses.Now get fl Courses:
$str_selection4 = "SELECT name,location FROM courses Where location='fl'"; // fourth db query
$results_courses_fl = mysql_query($str_selection4,$connectMe_db) or die('This query showed an error: query1; '.mysql_error());
print ('<ul>');
while ($articleDb4 =mysql_fetch_object($results_courses_fl))
{
print("<li><strong>$articleDb4->name</strong>, $articleDb4->location</li>");
}
print ('</ul>');
print ('<hr>'); // End of getting fl courses.Now get me Courses:
$str_selection5 = "SELECT name,location FROM courses Where location='me'"; // fifth db query
$results_courses_me = mysql_query($str_selection5,$connectMe_db) or die('This query showed an error: query1; '.mysql_error());
print ('<ul>');
while ($articleDb5 =mysql_fetch_object($results_courses_me))
{
print("<li><strong>$articleDb5->name</strong>, $articleDb5->location</li>");
}
print ('</ul>');
?>
So YES, I am very excited and enthused by learning this, but also for you to help prove me right, that this query/queries can be done!
-ROCK ON PHP!!- AND THANKS AGAIN-