Thanks in advance for checking out my problem.

Here is a fictional version of the scenario I am trying to achieve - let's say you are searching for a Department of Motor Vehicles office closest to you. So you go to a website and you plug in your zip code. What you get in return, is a table with four offices in that zip code. Glancing at this table you choose the office you want and you click on a "view details" button to go to another page with specifics about that particular office.. such as directions, phone numbers, etc.

The way I am currently set up is - you plug in your zip code (http://www.la-mason.com/2search.html - search for zip 71129) and you get a single webpage with excessive scroll down, listing all of companies in that zip code and all of their detailed information (directions, phone numbers, etc).

I have to break it down.. does that make sense? This link is a non-active graphical representation of what I need http://www.la-mason.com/2resultsA.phpis --- so when you click "View" it takes you to the detailed information of just that company.

THE DETAILS OF HOW I HAVE IT SET UP:
I have 3 tables: Lodges, Officers and Pics.
I'm currently able to display a company, their employees and a photo on my results page based on a $metode search.

SO my problem comes into play when the search is based on zip code or county and there are multiple companies returned. I have to give the user the option to choose which lodge they want in a particular zip code or county.

The code is below, but to see what I am talking about go to:

______________________________________________________________________
2search.html Code:
______________________________________________________________________

<form method="post" action="http://www.la-mason.com/2results.php"; target="_blank">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td bordercolor="#000000">
<p align="center">
<select name="metode" size="1">
<option value="tblLodges.strLodgeName">Name</option>
<option value="tblLodges.intLodgeNumber">Number</option>
<option value="tblLodges.strDistrictName">District</option>
<option value="tblLodges.strLodgeLocationCity">City</option>
<option value="tblLodges.strLodgeLocationZIP">Zip</option>
<option value="tblLodges.strLodgeCounty">County</option>
</select> <input type="text" name="search" size="25">

Search database: <input type="submit" value="Go!!" name="Go"></p>
</td>
</tr>
</table>
</div>
</form>

_____________________________________________________________________
2results.php code:
_____________________________________________________________________
//error message (not found message)begins
$XX = "No Record Found, to search again please close this window";
//query details table begins
$query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeWEB, tblLodges.strLodgeCounty, tblLodges.dtChartered, tblLodges.strLodgeMailingAddress, tblLodges.strLodgeMailingAddress2, tblLodges.strLodgeMailingCity, tblLodges.strLodgeMailingPostCode, tblLodges.strLodgeEmail, tblLodges.strLodgePhone, tblLodges.strLodgeFax, tblLodges.strDrivingDirectons, tblLodges.dtMeetingTime, tblLodges.dtMealTime, tblLodges.strFloorSchool, tblLodges.strLodgeNews, tblOfficers.strOfficerTitle, tblOfficers.strFirstName, tblOfficers.strLastName, tblOfficers.BusinessPhone, tblOfficers.PersEmail FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' GROUP BY tblLodges.strLodgeName LIMIT 0, 50");
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["link"];
//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}'>";
echo "</center>\n";
echo ("</tr>");
}
?> </tr>
</table>
<hr width=75% align=center size=4>
<?php
//query details table begins
$query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeMailingCity, tblLodges.strLodgeMailingPostCode, tblLodges.strLodgeCounty, tblOfficers.strOfficerTitle, tblOfficers.strFirstName, tblOfficers.strLastName, tblOfficers.BusinessPhone, tblOfficers.PersEmail FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50");

$results=mysql_query($query);
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>";
//

while ($row = mysql_fetch_array($query))
{

$variable1=$row["strOfficerTitle"];
$variable2=$row["strFirstName"];
$variable3=$row["strLastName"];
$variable4=$row["PersEmail"];
$variable5=$row["BusinessPhone"];

//table layout for results

print ("<tr>");
echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n";
echo "<td class=\"td_id\">$variable1</td>\n";
echo "<td class=\"td_id\">$variable2</td>\n";
echo "<td class=\"td_id\">$variable3</td>\n";
echo "<td class=\"td_id\">$variable4</td>\n";
echo "<td class=\"td_id\">$variable5</td>\n";
print ("</tr>");
}
?>
</body>
</html>

Well for starters, this is PHP code, and this forum is ASP.NET, so you're in the wrong forum. However, this is how you should do it:

On your search page, have it submit back to the new page in the new window. In that new page, list it how your example is, the non-active one. Then have that lead to a new page, in the same window. That next page will contain all the specifics.

Search.php:

<form method="post" action="http://www.la-mason.com/2results.php"; target="_blank">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td bordercolor="#000000">
<p align="center">
<select name="metode" size="1">
<option value="tblLodges.strLodgeName">Name</option>
<option value="tblLodges.intLodgeNumber">Number</option>
<option value="tblLodges.strDistrictName">District</option>
<option value="tblLodges.strLodgeLocationCity">City</option>
<option value="tblLodges.strLodgeLocationZIP">Zip</option>
<option value="tblLodges.strLodgeCounty">County</option>
</select> <input type="text" name="search" size="25">

Search database: <input type="submit" value="Go!!" name="Go"></p>
</td>
</tr>
</table>
</div>
</form>

2results.php:

<table border="0" cellpadding="0" cellspacing="0" width="100%">
                              <tbody>

                                <tr>
                                  <td width="100%"><p align="center"><strong>    Locator</strong><br />
                                  </p></td>
                                </tr>
                              </tbody>
                            </table>

                            <center>
                              <span class="style2">3</span> found (<span class="style2">&quot;search field&quot;</span> matches <span class="style2">&quot;search parameters &quot;</span>)
                            </center>

                            <center>
                              <br />
                              <br />
                              <table border="1" cellpadding="4" cellspacing="0" width="85%">
                                <tbody>
                                  <tr>
                                    <td colspan="5" bgcolor="#92adc0" height="18"><center>
                                      Results of Search
                                    </center></td>
                                  </tr>
                                  <tr>
                                    <td align="center" bgcolor="#92adc0" height="18"><center>
                                      Company #
                                    </center></td>
                                    <td align="center" bgcolor="#92adc0" height="18"><center>
                                      Name
                                    </center></td>
                                    <td height="18" align="center" bgcolor="#92adc0"><center>
                                      City
                                    </center></td>
                                    <td height="18" align="center" bgcolor="#92adc0"><center>
                                      Zip
                                    </center></td>
                                    <td align="center" bgcolor="#92adc0" height="18"><center>
                                      View
                                    </center></td>
                                  </tr>

<?php
$query = mysql_query("SELECT strLodgeName, intLodgeNumber, strDistrictName, strLodgeMailingCity FROM tblLodges WHERE $metode LIKE '%$search%' GROUP BY strLodgeName LIMIT 50");
while ($row = @mysql_fetch_array($query))

{
echo "<tr bgcolor=\"#dddddd\"><td><center>";
echo $row["strLodgeName"];
echo "</center></td><td><center>";
echo $row["strDistrictName"];
echo "</center></td><td><center>";
echo $row["strLodgeMailingCity"];
echo "</center></td><td><center><span class=\"style2\">";
echo $metode;
echo ": $search";
echo "</span></center></td><td><center><br /><input name=\"submit\" type=\"button\" value=\"View\" onclick=\"window.location='2view.php?id=";
echo $row["intLodgeNumber"];
echo "\" /></form></center></td></tr>";
}
?>

                                </tbody>
                              </table>
                              <br />
                            </center>

2view.php?id=....

Now with 2view.php, request the querystring and do another search query based upon that ID. Put that in the where clause. This would be your query:

$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");

Then use the code you already have done as you will only have 1 row returned.

Thanks so much for taking the time! I just realized I posted in the wrong forum and reposted in PHP before I got your post. I am very much a beginner and will now go through your reply. Know that I'm confused on your second paragraph, but I will try to dissect what you are saying and try to figure it out.
Thanks again.

You need three pages:

search.php

results.php

details.php (or view.php like I called it)

Then, do your search, find the results, view more information.

I pretty much pasted what you did into new documents.
I had to format the table a bit because of inconsistent field names caused missing data.
Here is what I got:

http://www.la-mason.com/3search.html

Its hanging up on 3results.php
The last column is showing part of the code and nothing happens when you click the "view" button..

Thanks.

Replace this code:

{
echo "<tr bgcolor=\"#dddddd\"><td><center>";
echo $row["strLodgeName"];
echo "</center></td><td><center>";
echo $row["strDistrictName"];
echo "</center></td><td><center>";
echo $row["strLodgeMailingCity"];
echo "</center></td><td><center><span class=\"style2\">";
echo $metode;
echo ": $search";
echo "</span></center></td><td><center><br /><input name=\"submit\" type=\"button\" value=\"View\" onclick=\"javascript:window.location='2view.php?id=";
echo $row["intLodgeNumber"];
echo "'\" /></center></td></tr>";
}

What I did, removed the </form>, replaced the onclick attribute.

Don't forget to fix the column hearders, it seems as if there's a missing column (<td></td>)

Try This:

$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");
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["link"];
//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>");
}
?> </tr>
</table>
<hr width=75% align=center size=4>
<?php
//query details table begins
$query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeMailingCity, tblLodges.strLodgeMailingPostCode, tblLodges.strLodgeCounty, tblOfficers.strOfficerTitle, tblOfficers.strFirstName, tblOfficers.strLastName, tblOfficers.BusinessPhone, tblOfficers.PersEmail FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50");

$results=mysql_query($query);
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>";
//

while ($row = mysql_fetch_array($query))
{

$variable1=$row["strOfficerTitle"];
$variable2=$row["strFirstName"];
$variable3=$row["strLastName"];
$variable4=$row["PersEmail"];
$variable5=$row["BusinessPhone"];

//table layout for results

print ("<tr>");
echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n";
echo "<td class=\"td_id\">$variable1</td>\n";
echo "<td class=\"td_id\">$variable2</td>\n";
echo "<td class=\"td_id\">$variable3</td>\n";
echo "<td class=\"td_id\">$variable4</td>\n";
echo "<td class=\"td_id\">$variable5</td>\n";
print ("</tr>");
}
?>

Keep in mind, you have to set the variable $id in order for the query to work.

I was looking through everything to see where the problem might be...
Was I supposed to put in the (a) table name and the (b) table name in that query string?

all the "a" and "b" where for is a quick reference to the table. Instead of always putting tablename.columnname, you can name the table and reference it as that name

newname.columnname

Hence:

SELECT a.City, b.State FROM Cities a, States b

instead of:

SELECT Cities.City, States.State FROM Cities, States

Thanks - I loaded the latest code and its starting to shape up... there are some formatting issues, but I think I can figure all of that out.

The remaining issue seems to be the table/query at the bottom of the page. It lists the Officers, their titles, email and phone. It seems to be messed up...

I didn't make any changes to your second query. I changed the first query for the results page. But the view page should be the same query as you had a long time ago, except for the "WHERE" clause.

Also, in your html, replace this:

[/url]

with this:

</a>

Ok, I'll research it some more......

well, the code is identical from before...

The error message is on the following:
while ($row = mysql_fetch_array($query))

any ideas?

It is most likely telling you that you are trying to display data that isn't there.

Just for giggles, trade out the query to the one you had before, except change the WHERE clause to the current one. Maybe I made a typo somewhere.

Nope, that didn't solve it. But you have already helped me tremendously.. I'll try to figure it out. Thank you very, very much and let me know if there is anything I can do in return... I don't know maybe there is a rating thing on this forum....

There is, "Add to SheSaidImaPreggy's Reputation"

commented: I can't say thanks enough to SheSaidImaPregy... very patient and very helpful. +1
commented: He is VERY helpful o_o .. +5

SheSaidImaPregy- are you available to answer one more question related to this thread?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.