User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 423,535 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,340 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 817 | Replies: 19 | Solved
Reply
Join Date: Feb 2008
Posts: 36
Reputation: jtapp is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
jtapp jtapp is offline Offline
Light Poster

Can someone help me with a complicated search parameters

  #1  
Feb 22nd, 2008
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['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>");
}
?>
</body>
</html>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Can someone help me with a complicated search parameters

  #2  
Feb 22nd, 2008
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.
Last edited by SheSaidImaPregy : Feb 22nd, 2008 at 3:01 pm.
Reply With Quote  
Join Date: Feb 2008
Posts: 36
Reputation: jtapp is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
jtapp jtapp is offline Offline
Light Poster

Re: Can someone help me with a complicated search parameters

  #3  
Feb 22nd, 2008
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.
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Can someone help me with a complicated search parameters

  #4  
Feb 22nd, 2008
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.
Reply With Quote  
Join Date: Feb 2008
Posts: 36
Reputation: jtapp is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
jtapp jtapp is offline Offline
Light Poster

Re: Can someone help me with a complicated search parameters

  #5  
Feb 22nd, 2008
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.
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Can someone help me with a complicated search parameters

  #6  
Feb 22nd, 2008
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>)
Reply With Quote  
Join Date: Feb 2008
Posts: 36
Reputation: jtapp is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
jtapp jtapp is offline Offline
Light Poster

Re: Can someone help me with a complicated search parameters

  #7  
Feb 22nd, 2008
Well, it took us through to the view.php page, but it is not populating..

http://www.la-mason.com/3search.html - search for zip code 71129
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Can someone help me with a complicated search parameters

  #8  
Feb 22nd, 2008
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>");
}
?>
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Can someone help me with a complicated search parameters

  #9  
Feb 22nd, 2008
Keep in mind, you have to set the variable $id in order for the query to work.
Reply With Quote  
Join Date: Feb 2008
Posts: 36
Reputation: jtapp is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
jtapp jtapp is offline Offline
Light Poster

Re: Can someone help me with a complicated search parameters

  #10  
Feb 22nd, 2008
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?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 5:30 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC