Re: linking to a database id

2001-11-03 Thread DL Neil

 I have a database of dealers.

=Hmm, reminds me of a joke: how many industries do you know that refer to their 
customers as users and their
suppliers as dealers?

A web page loads a list of states, a user
 clicks on the
 state and the database is queried and lists in a table the dealers for that state. 
Simple
 enough. When the dealers page is first loaded, it shows all dealers in the database,
 name, address, phone, etc. I want to change that to just the dealer names linked to
 their state listing. I can get the page to display the dealer names okay, but when I 
try to
 get the link to work it just reloads the currant page. The url shows the correct 
information.
 I shouldn't have to designate a seperate page to show the results should I? I don't 
want to,
 I want this to be the default that loads when the page is loaded.
 I have this code snippet below, that when I click on the the link in the web page, 
the url
 shows the correct info for the page, but it does not load, it just reloads the same 
current
 page.

=nothing has sprung off the page and caught my eye (yes well...), but two things:

=1. recommend that you put in an echo/printr immediately before the mysql_query() 
call, to check the $query
contents - and the outcome of the logic in the preceding lots of elseif statements 
trimmed

=2. that statement lots of elseif statements trimmed throws up a yellow flag, 
because the more
intertwined/nested ifs, if-thens, and if-then-elses there are, the more there is space 
for confusion. Assuming
that $orderby is in fact a code for 'state' (as in location) and that the trimmed 
statements are similar why not
do away with the many choices and settle for:

 $query = select * from dealers where ID = $orderby order by 'DealerName' asc;

=Does the debug output match up with the URL?
=dn



 Thanks for the help...
 --
 Chip

 --- lots of elseif statements trimmed --
 elseif ($orderby == '46'):
 $query = select * from dealers where ID = '46' order by 'DealerName' asc;

 else:
 $query = select * from dealers;
 endif;
 $result = mysql_query($query);
 $i = 0;
  while ( $row = mysql_fetch_array($result))
 {
 if ($result):
 {
 printf(tda
href=\http://www.mapquest.com/cgi-bin/ia_free?width=500height=600level=8streetaddress=%scity=%sstate=%s\;
target=\_new\%s/a
 \n, $row[Address1], $row[City], $row[State], $row[DealerName]);
 printf(br%s\n, $row[Address1]);
 printf(br%s\n, $row[Address2]);
 printf(br%s, %s %s\n, $row[City], $row[State], $row[Zipcode]);
 printf(brPhone: %s\n, $row[Phone]);
 printf(brFAX: %s\n, $row[FAX]);
 printf(br\na href=\mailto:%s\;%s/a\n, $row[Email], $row[Email]);
 print(/td\n);
 if ($i % 2)
 {
 echo /tr\ntr\n;
 }
 $i++;
 }
 else:
 printf(td.$row[ID]. a href='dealerDB2.php?ID=$row[ID]'%s/a, 
$row[DealerName]);
 print(/td);
 if ($i % 2)
 {
 echo /tr\ntr\n;
 }
 $i++;
 endif;
  }
 ?


 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail 
[EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




linking to a database id

2001-11-02 Thread chip . wiegand

I have a database of dealers. A web page loads a list of states, a user
clicks on the
state and the database is queried and lists in a table the dealers for that state. 
Simple
enough. When the dealers page is first loaded, it shows all dealers in the database,
name, address, phone, etc. I want to change that to just the dealer names linked to
their state listing. I can get the page to display the dealer names okay, but when I 
try to
get the link to work it just reloads the currant page. The url shows the correct 
information.
I shouldn't have to designate a seperate page to show the results should I? I don't 
want to,
I want this to be the default that loads when the page is loaded.

I have this code snippet below, that when I click on the the link in the web page, the 
url
shows the correct info for the page, but it does not load, it just reloads the same 
current
page.

Thanks for the help...
--
Chip

--- lots of elseif statements trimmed --
elseif ($orderby == '46'):
$query = select * from dealers where ID = '46' order by 'DealerName' asc;

else:
$query = select * from dealers;
endif;
$result = mysql_query($query);
$i = 0;
 while ( $row = mysql_fetch_array($result))
{
if ($result):
{
printf(tda 
href=\http://www.mapquest.com/cgi-bin/ia_free?width=500height=600level=8streetaddress=%scity=%sstate=%s\;
 target=\_new\%s/a
\n, $row[Address1], $row[City], $row[State], $row[DealerName]);
printf(br%s\n, $row[Address1]);
printf(br%s\n, $row[Address2]);
printf(br%s, %s %s\n, $row[City], $row[State], $row[Zipcode]);
printf(brPhone: %s\n, $row[Phone]);
printf(brFAX: %s\n, $row[FAX]);
printf(br\na href=\mailto:%s\;%s/a\n, $row[Email], $row[Email]);
print(/td\n);
if ($i % 2)
{
echo /tr\ntr\n;
}
$i++;
}
else:
printf(td.$row[ID]. a href='dealerDB2.php?ID=$row[ID]'%s/a, 
$row[DealerName]);
print(/td);
if ($i % 2)
{
echo /tr\ntr\n;
}
$i++;
endif;
 }
?


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php