Re: database lookup



Yep, I think that's how you'll have to go. Display the "top level"
data, like this, in PHP:

<?
echo "<a
href=\"link_to_page.php?identifying_data=".$row["data_field"]."\">Councilman</a>";
?>

The link takes them to the "link_to_page.php," and the appended data
("?identifying_data=".$row["data_field"]."\") is the data to be used in
an SQL query on the page. You can re-use the code I showed before to do
the query on the subsequent page, and display the "drill down" data.

The thing with PHP and MySQL is that you need the user to do an action
- either click a form button or click a "loaded" link as in my example
above - before the code will do something. It hasn't yet evolved to the
stage where it "knows" what the user wants, and "pre-serves" that
information - a fact some former un-tech-savvy bosses of mine never
seemed to understand. ;) You need to "lead" the user along a logical
PHP/MySQL functionality path.

Hope that helps!

sk wrote:
Thanks Dano, but I have all that done. My question/problem is displaying
either or both "Commissions" / "Councilpeople" from the database. This I
can do at this time, however, how do I let the user select say a
councileperson, that that data and query the database for the
commissioins they are on OR select a commission and then get a list of
all councilpersons on that commission.

I tried to state that I have the database designed and implemented but I
do not know (at this time) how to display the above, take the answer and
query the database again and display.



Dano wrote:
OK, I'll take a stab at answering.

First, you have to connect to the database. I use a separate file,
which I call "connect.php." I use a single file which I reference as an
"include" on all the pages I have. That way, if something in the
connection changes - such as a change in server name, username, or
password - I only have to make the change in ONE file, and not in the
hundreds of files on my sites. Here's the code for the "connect.php"
file:

<?
$db = mysql_connect("server_name", "database_username",
"database_password");
if (!$db)
{
echo "error!";
}
mysql_select_db("database_name");
?>

Of course, substitute your own values for server name, username,
password and database name. Save it in a separate file, with a ".php"
file extension.

Now comes the code for the main page:

<?
include("connect.php");
$query = "select * from table_name";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<p><a
href=\"select_me.php?vital_data=".$row["field_name"]."\">".$row["field_name"]."</a><p>";
}
?>

The "include" function "inserts" the code from connect.php into the
code on the page, just as if you'd written it there. The remainder of
the code sets the query string, executes the query, and sets the
results from the recordset into an array ($row), then loops through the
array. When I display the field, I put it in a simple link ("a href")
which passes the data attached to the URL to the "select_me.php" page.
You can use similar code just about any way you want to do it,
including as a radio button, a select list, etc. You can also write
some JavaScript into your PHP code that would "fire" the action upon a
change ot selection of the item in a form. Really, you're limited only
by your imagination as to what you can do. Of course, you would
probably have more than one field name to display data for, but
hopefully, the code above will give you the idea, and you can expand it
from there.

Good luck!

Johnny wrote:

"someone" <someone@xxxxxxxxxxxxx> wrote in message
news:mmkQg.79935$QM6.40595@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Could someone direct me to a site that would help me with the following:

Have database setup and loaded. Want to create web page that will use
database to do lookup of database on screen and allow selection of
field. Ie... lookup council member in lookup window, select and have
proper/correct committees councilperson belongs to appear.

TIA

start with google, search for

PHP MySql tutorial

and try the various hits.



.



Relevant Pages

  • Re: "order by" issue after compact database
    ... primary key to establish a display order when you display table data. ... When you compact Access doesn't care about the "Order" of the records in the ... I have a Access 2003 database. ... I run a query on each table that is similar to the following and save ...
    (microsoft.public.access.queries)
  • Re: database lookup
    ... the query on the subsequent page, and display the "drill down" data. ... councileperson, that that data and query the database for the ... I tried to state that I have the database designed and implemented but I ...
    (alt.php)
  • Re: Results in multiple pages. Takes too much time
    ... display the results based on the user input. ... Each query is taking about 20-30 seconds. ... I have actually converted a MS access database to SQL ... as much actual and relevant code as necessary to produce the results ...
    (comp.lang.perl.misc)
  • Re: Posting to a Web Form and Displaying the Result in Normal Browser
    ... the Access inventory database to the online database that drives ... everything has to be extensively processed for the website (it's ... then it should display just fine. ... I suppose so the .php application didn't ...
    (comp.databases.ms-access)
  • Re: php vs mysql speed
    ... complex query or to have php do all the complex processing and submit ... lots of simple queries to the mysql database? ... Sometime a complex multijoin query with nested sub-queries may be ... quicker, other times it will take far longer. ...
    (comp.lang.php)