JTapp Posted February 23, 2008 Author Share Posted February 23, 2008 Although I'm now bug-eyed, I started from scratch. There are no more error messages and most of my data is getting returned. I'm just not seeing variables 20-24 in the table at the bottom. It's probably something fairly simple at this point.... Here's the code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php $username = "*****"; $password = "******"; $hostname = "MYSQLHOST"; $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("****",$dbhandle) or die("Could not select *********"); $id = $_GET['id']; $query = mysql_query("SELECT a.strLodgeName, a.intLodgeNumber, a.strDistrictName, a.strLodgeWEB, a.strLodgeCounty, a.dtChartered, a.strLodgeMailingAddress, a.strLodgeMailingAddress2, a.strLodgeMailingCity, a.strLodgeMailingPostCode, a.strLodgeEmail, a.strLodgePhone, a.strLodgeFax, a.strDrivingDirectons, a.dtMeetingTime, a.dtMealTime, a.strFloorSchool, a.strLodgeNews, b.strOfficerTitle, b.strFirstName, b.strLastName, b.BusinessPhone, b.PersEmail FROM tblLodges a LEFT JOIN tblOfficers b ON a.lngLodgeID = b.lngLodgeID WHERE a.intLodgeNumber=$id GROUP BY a.strLodgeName LIMIT 50")or die(mysql_error()); while ($row = @mysql_fetch_array($query)) { $variable1=$row["strLodgeName"]; $variable2=$row["intLodgeNumber"]; $variable3=$row["strDistrictName"]; $variable4=$row["strLodgeWEB"]; $variable5=$row["strLodgeCounty"]; $variable6=$row["dtChartered"]; $variable7=$row["strLodgeMailingAddress"]; $variable8=$row["strLodgeMailingAddress2"]; $variable9=$row["strLodgeMailingCity"]; $variable10=$row["strLodgeMailingStateCode"]; $variable11=$row["strLodgeMailingPostCode"]; $variable12=$row["strLodgeEmail"]; $variable13=$row["strLodgePhone"]; $variable14=$row["strLodgeFax"]; $variable15=$row["strDrivingDirectons"]; $variable16=$row["dtMeetingTime"]; $variable17=$row["dtMealTime"]; $variable18=$row["strFloorSchool"]; $variable19=$row["strLodgeNews"]; $variable20=$row["strOfficerTitle"]; $variable21=$row["strFirstName"]; $variable22=$row["strLastName"]; $variable23=$row["BusinessPhone"]; $variable24=$row["PersEmail"]; //table layout for results echo ("<tr>"); echo "<center>\n"; echo "<p>GRAND LODGE OF LOUISIANA - LODGE LOCATOR RESULTS\n</p>"; echo "Lodge Name: $variable1</p>"; echo "<p><b>Lodge Number:</b> $variable2</p>"; echo "<p><b>District Name:</b> $variable3</p>"; echo "<a href=\"$variable4\">Click Here To Go To The Lodge Website</a>"; echo "<p><b>Lodge County:</b> $variable5</p>"; echo "<p><b>Lodge Chartered On:</b> $variable6</p>"; echo "<p><b>Lodge Address:</b> $variable7, $variable8</p>"; echo '<p>' . $variable9 . $variable10 . $variable11 . '</p>'; echo "Click Here To Email The Lodge"; echo "<p>Lodge Phone Number: $variable13, Lodge FAX Number: $variable14</p>"; echo "<p>Lodge Driving Directions: $variable15</p>"; echo "<p>Lodge Lodge Meeting Time: $variable16</p>"; echo "<p>Lodge Lodge Meal Time: $variable17</p>"; echo "<p>Lodge Floor School: $variable18</p>"; echo "<p>Lodge News: $variable19</p>"; echo "<img src='{$row['link']}'>"; echo "</center>\n"; echo ("</tr>"); } //query details table begins echo "<center>\n"; echo "<H2>Roster of Lodge Officers</H2>\n"; echo "<table border='1'> <tr> <th>Officer Title</th> <th>Officer First</th> <th>Officer Last</th> <th>Officer Email</th> <th>Officer Phone</th> </tr>"; if (mysql_num_rows($query)) { while ($row = mysql_fetch_array($query)){ $variable20=$row["strOfficerTitle"]; $variable21=$row["strFirstName"]; $variable22=$row["strLastName"]; $variable23=$row["PersEmail"]; $variable24=$row["BusinessPhone"]; //table layout for results print ("<tr>"); echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n"; echo "<td class=\"td_id\">$variable20</td>\n"; echo "<td class=\"td_id\">$variable21</td>\n"; echo "<td class=\"td_id\">$variable22</td>\n"; echo "<td class=\"td_id\">$variable23</td>\n"; echo "<td class=\"td_id\">$variable24</td>\n"; print ("</tr>"); } } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
Bauer418 Posted February 23, 2008 Share Posted February 23, 2008 The reason your first query failed is because you had used the variable $metode in the query which was undefined. You can use a blank search in MySQL, meaning "...WHERE column LIKE '%%'" won't trigger an error. However, when PHP sees "...WHERE $metode LIKE '%%'" and doesn't have a value for $metode, you get "...WHERE LIKE '%%'" which will trigger a MySQL error. Also, try cleaning up your code again. Why do you set $variable1-24 when you can just use the originally indexed items of the array? It would save you coding space, time, and size. Quote Link to comment Share on other sites More sharing options...
JTapp Posted February 23, 2008 Author Share Posted February 23, 2008 I tried to change my statement "...WHERE $metode LIKE '%%'..." to "....WHERE column LIKE '%%'.." but it failed to return anything at all. The change was made on my results.php form. Quote Link to comment Share on other sites More sharing options...
Bauer418 Posted February 24, 2008 Share Posted February 24, 2008 I tried to change my statement "...WHERE $metode LIKE '%%'..." to "....WHERE column LIKE '%%'.." but it failed to return anything at all. The change was made on my results.php form. If no results were returned but you didn't get an error, that's just because nothing matched the query, which is something that'll be really tough for us to help you out with. Quote Link to comment Share on other sites More sharing options...
JTapp Posted February 24, 2008 Author Share Posted February 24, 2008 Hmmm... I was getting variables 1-19 populated but was looking for variables 20-24 to be populated. Then I applied your recommendation and I stopped getting variables 1-19 as well as 20-24. The data is definitely there... I triple checked it in MySql.... The difference in the variables is 1-19 are coming from tblLodges and variables 20-24 are coming from tblOfficers. Quote Link to comment Share on other sites More sharing options...
JTapp Posted February 24, 2008 Author Share Posted February 24, 2008 Well.. now I seem to be getting just about everything.. but a single problem remains. My table (2nd query at bottom of code) is only reporting one row of results when there should be two or more. This is the section that has variables 20-24... Does anybody have any thoughts on this? Here is the latest code: $id = $_GET['id']; $query = mysql_query("SELECT a.strLodgeName, a.intLodgeNumber, a.strDistrictName, a.strLodgeWEB, a.strLodgeCounty, a.dtChartered, a.strLodgeMailingAddress, a.strLodgeMailingAddress2, a.strLodgeMailingCity, a.strLodgeMailingPostCode, a.strLodgeEmail, a.strLodgePhone, a.strLodgeFax, a.strDrivingDirectons, a.dtMeetingTime, a.dtMealTime, a.strFloorSchool, a.strLodgeNews, b.strOfficerTitle, b.strFirstName, b.strLastName, b.BusinessPhone, b.PersEmail FROM tblLodges a LEFT JOIN tblOfficers b ON a.lngLodgeID = b.lngLodgeID WHERE a.intLodgeNumber=$id GROUP BY a.strLodgeName LIMIT 50")or die(mysql_error()); while ($row = @mysql_fetch_array($query)) { $variable1=$row["strLodgeName"]; $variable2=$row["intLodgeNumber"]; $variable3=$row["strDistrictName"]; $variable4=$row["strLodgeWEB"]; $variable5=$row["strLodgeCounty"]; $variable6=$row["dtChartered"]; $variable7=$row["strLodgeMailingAddress"]; $variable8=$row["strLodgeMailingAddress2"]; $variable9=$row["strLodgeMailingCity"]; $variable10=$row["strLodgeMailingStateCode"]; $variable11=$row["strLodgeMailingPostCode"]; $variable12=$row["strLodgeEmail"]; $variable13=$row["strLodgePhone"]; $variable14=$row["strLodgeFax"]; $variable15=$row["strDrivingDirectons"]; $variable16=$row["dtMeetingTime"]; $variable17=$row["dtMealTime"]; $variable18=$row["strFloorSchool"]; $variable19=$row["strLodgeNews"]; $variable20=$row["strOfficerTitle"]; $variable21=$row["strFirstName"]; $variable22=$row["strLastName"]; $variable23=$row["BusinessPhone"]; $variable24=$row["PersEmail"]; //table layout for results echo ("<tr>"); echo "<center>\n"; echo "<p>GRAND LODGE OF LOUISIANA - LODGE LOCATOR RESULTS\n</p>"; echo "Lodge Name: $variable1</p>"; echo "<p>Lodge Number: $variable2</p>"; echo "<p>District Name: $variable3</p>"; echo "<a href=\"$variable4\">Click Here To Go To The Lodge Website[/url]"; echo "<p>Lodge County: $variable5</p>"; echo "<p>Lodge Chartered On: $variable6</p>"; echo "<p>Lodge Address: $variable7, $variable8</p>"; echo '<p>' . $variable9 . $variable10 . $variable11 . '</p>'; echo "Click Here To Email The Lodge"; echo "<p>Lodge Phone Number: $variable13, Lodge FAX Number: $variable14</p>"; echo "<p>Lodge Driving Directions: $variable15</p>"; echo "<p>Lodge Lodge Meeting Time: $variable16</p>"; echo "<p>Lodge Lodge Meal Time: $variable17</p>"; echo "<p>Lodge Floor School: $variable18</p>"; echo "<p>Lodge News: $variable19</p>"; echo "<img src='{$row['link']}'>"; echo "</center>\n"; echo ("</tr>"); } //query details table begins echo "<center>\n"; echo "<H2>Roster of Lodge Officers</H2>\n"; echo "<table border='1'> <tr> <th>Officer Title</th> <th>Officer First</th> <th>Officer Last</th> <th>Officer Email</th> <th>Officer Phone</th> </tr>"; $query = mysql_query("SELECT a.strLodgeName, a.intLodgeNumber, a.strDistrictName, a.strLodgeWEB, a.strLodgeCounty, a.dtChartered, a.strLodgeMailingAddress, a.strLodgeMailingAddress2, a.strLodgeMailingCity, a.strLodgeMailingStateCode, a.strLodgeMailingPostCode, a.strLodgeEmail, a.strLodgePhone, a.strLodgeFax, a.strDrivingDirectons, a.dtMeetingTime, a.dtMealTime, a.strFloorSchool, a.strLodgeNews, b.strOfficerTitle, b.strFirstName, b.strLastName, b.BusinessPhone, b.PersEmail FROM tblLodges a LEFT JOIN tblOfficers b ON a.lngLodgeID = b.lngLodgeID WHERE a.intLodgeNumber=$id GROUP BY a.strLodgeName LIMIT 50")or die(mysql_error()); if (mysql_num_rows($query)) { while ($row = mysql_fetch_array($query)){ $variable20=$row["strOfficerTitle"]; $variable21=$row["strFirstName"]; $variable22=$row["strLastName"]; $variable23=$row["PersEmail"]; $variable24=$row["BusinessPhone"]; //table layout for results print ("<tr>"); echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n"; echo "<td class=\"td_id\">$variable20</td>\n"; echo "<td class=\"td_id\">$variable21</td>\n"; echo "<td class=\"td_id\">$variable22</td>\n"; echo "<td class=\"td_id\">$variable23</td>\n"; echo "<td class=\"td_id\">$variable24</td>\n"; print ("</tr>"); } } ?> Quote Link to comment Share on other sites More sharing options...
JTapp Posted February 25, 2008 Author Share Posted February 25, 2008 SOLVED. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.