This topic is locked

InnerJoin question

1/26/2008 12:28:13 PM
PHPRunner General questions
T
trumpet author

I'm trying to figure out a way to add /edit/view locations per attorney in a database. I plan to include a link on teh attorney profile to "Add Locations" to show which locations the attorney practices.
I tried creating a custom SQL query as follows...
select * from locations

INNER JOIN attorneys_by_locations ON locations.location_id = attorneys_by_locations.location_id

where attorney_id =" & attorney_id
The attorneys_by_locations table includes 2 fields... attorney_id & location_id only.

I need to make the sql query dynamic based on the attorny_id which can be fed from the attorney profile section. How do I pass the attorney_id to this query? I also need to be able to let them add/delete the locations, too.
Thanks for your direction...
-LWTrumpet

J
Jane 1/28/2008

Hi,
you can add where clause dynamically in the View page: Before SQL query tab.

Here is a sample:

$strWhereClause = whereAdd($strWhereCaluse,"attorney_id=".$_REQUEST["attorneyid"])


And here is a sample code for your link:

<a href="TableName_view.php?attorneyid={$row.1attorney_id_value}">Add Locations</a>