Can"t carry over a key parameter from one form to another

Can"t carry over a key parameter from one form to another

am 30.09.2010 20:38:59 von Bill Mudry

--=====================_40855055==.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed

A few weeks ago I was able to get a simple search engine working
in my "TAXA" project and very glad for it. All the pages are dynamically
formed, so the search code has to be able to extract answers from
the 'species' table. At first, the search method was hard wired to
provide answers
on a common name basis for different woods.

I realized that I should be able to expand this to allow users to first
choose by which column to do the search. I chose to list common names,
botanical names, genus, location and description. This form is working just
fine by itself.

The rest of the code for the search is still working great ---- when
I hard wire
which column to use. However, I can't seem to get the user chosen parameter
($searchtype) or its corresponding actual column name ($searchfield) to carry
through once a user finally enters a search string and presses the
submit button.
Mind you, I can see that any output parameters from the first form
gets wiped out
every time the form cycles back to the same page.

I have tried adding a hidden field to preserve the $searchfield
value. That didn't
work. I have tried adding a $_GET statement to bring back that value but that
did not work either. I just tried to change the second form action from
action=\"search.php\" to action=""
and that didn't help either.

What is the proper code to carry over $searchfield so it can be used
by the second form? Because of numerous decode statements I put in and because
hard wiring a column name makes the search engine work just fine, I know that
once that value can be used by the second form, I will have a search function
that will allow users to search by numerous choices. That would be one more
giant leap for my project.

Perhaps one answer would be to merge both forms into one but I am hoping
I can keep then separate so a user doesn't have to choose the method of
search for multiple queries.

I always appreciate the fine help you have all supplied. It has meant
the difference
between accomplishing my goals or not

Bill Mudry
Mississauga, Ontario

The running code can be seen and tried out at:
http://www.prowebcanada.com/taxa/search.php

Here is the complete code for that page:
========================================================
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">





TAXA: Search by Common Name




















This section is under development and will not work well until it is
finished. It will
expand the number of choices by which a person can do a search in the
species table
(such as by species, common name, origin and so on).






Search TAXA




Choose first by which means you wish to search.



action="" >














Common names


Botanical names


Genus


Location


Description


echo " value='{$species_name}' />";
?>






// Get the search variable from URL

$searchtype = @$_GET['searchtype'] ;
$searchtype = trim($searchtype); //trim whitespace from the stored variable

If (isset($searchfield)) {
echo "Searching by - $searchtype";
};
//echo "Line 149 - \$searchtype is - $searchtype
";

$searchfield = "";
switch ($searchtype) {
case "common names":
$searchfield = "species_commonname";
//Echo "
common names
\n";
break;

case "botanical names":
$searchfield = "species_name";
//Echo "
botanical names - $searchfield

\n";
break;
case "genus":
$searchfield = "genus_name";
//Echo "
genus - $searchfield
\n";
break;
case "location":
$searchfield = "location";
//Echo "
location - $searchfield
\n";
break;
case "description":
$searchfield = "species_description";
//Echo "
description - $searchfield

\n";
break;
default: If (!isset($searchfield)) {
echo "Please choose a search type first";
}

}

//echo "Line 180 - \$searchtype is - $searchtype
";

//Echo "Chosen search field (\$searchfield) is $searchfield

";

echo "

Searching by $searchtype

";



echo "";
echo "
";
echo "Line 190 just before the query form - \$searchtype is -
$searchtype
";
?>


method=\"get\">
//echo "";
echo "";
// echo " value=\"{$species_name}\" />";
// echo " value=\"$searchtype\" />";
// echo " value=\"{$searchfield}\" />";
echo "";
echo "
";
echo "Line 199 just after the query form - \$searchtype is -
$searchtype
";
echo "
";


$searchtype = @$_GET['searchtype'] ;

$searchtype = trim($searchtype);


$searchfield = @$_GET['searchfield'] ;

$searchfield = trim($searchfield);


$querystring = @$_GET['querystring'] ;

$querystring = trim($querystring);

/*
Development debug statement:
*/
Echo "Line 209 - \$searchfield chosen by user is - $searchfield
";


// rows to return
$limit='100';

// check for an empty string and display a message.


if ($querystring == "")
{
echo "

Please enter a search...

";
exit;
}


// check for a search parameter
if (!isset($querystring))
{
echo "

We do not seem to have anything to search for!

";
exit;
}

//Echo "Line 212 - \$searchfield chosen by user is - $searchfield
";


//////////////////////////////////////////////////////////// ///////
// CONNECT TO THE DATABASE
//////////////////////////////////////////////////////////// ///////

include ("connecttotaxa.php");
$connection = mysql_connect($hostname, $username, $password)
or die("Unable to connect to database server");

$db = mysql_select_db($dbname, $connection)
or die("Unable to connect to database");

// Building optional search fields. Pegged to species common
names at first

//Echo "Line 253 - \$searchfield chosen by user is - $searchfield
";

/*
Debug method: hard wire the searchfield at first to only common name
searches to allow
*/
//$searchfield="species_commonname";
//Echo "Line 253 - \$searchfield is hard set temporarily to
$searchfield
";
Echo "Line 260 - \$searchfield is chosen as $searchfield
";
Echo "Line 261 - \$querystring is user entered as $querystring
";

// Build SQL Query
$query = "select * from species where $searchfield like \"%$querystring%\"
order by $searchfield";

$numresults=mysql_query($query);
Echo "On line 268 \$numresults is - $numresults";
$numrows=mysql_num_rows($numresults);

if ($numrows == 0)
{
echo "

Search Results by $searchtype

";
echo "

Sorry, your search: "" . $querystring . ""
returned zero results

";

//echo "

Sorry, your search: "" . $trimmed . ""
returned zero results

";
}

// next determine if s has been passed to script, if not use 0
if (empty($s)) {
$s=0;
}

// get results
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");
echo "
";

// display what the person searched for
echo "

You searched for: "" . $querystring . ""

";

// begin to show results set
$count = 1 + $s ;
Echo "
";

//////////////////////////////////////////////////////////// ///////////////
// Format the data with a double table and display the data
//////////////////////////////////////////////////////////// ///////////////

echo "";
echo "";
echo "";
echo "";
echo "
";

echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";

echo "
";

// now you can display the results returned
while ($row= mysql_fetch_array($result))
{
extract($row); //At this point, the search data is ready for display
//echo $row;

echo "
";

$title1 = $row["species_commonname"] ;

$title2 = $row["species_name"];

$title3 = $row["location"];

echo "";

echo "";

echo "";

echo "";

echo "";


// echo "$count. $title
" ;

$count++ ;
}

echo "
";
echo "

Results by Common Name

"; //The data title
echo "
";
echo "

#

";
echo "
";
echo "

Common Name

";
echo "
";
echo "

Botanical Name

";
echo "
";
echo "

Location

";
echo "
";
echo "$count";
echo "
";
echo "$title1";
echo "
";
echo '';
echo "$title2";
echo"
.
\n";

echo "
";
echo "$title3";
echo "
";

echo "
";
echo "
";

$currPage = (($s/$limit) + 1);
Echo "";
//break before paging
echo "
";

// next we need to do the links to other results
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print " <<
Prev 10
  ";
}

// calculate number of pages needing links
$pages=intval($numrows/$limit);

// $pages now contains int of pages needed unless there is a
remainder from division

if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}

// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {

// not last page so give NEXT link
$news=$s+$limit;

echo " ";
}

$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "

Showing results $b to $a of $numrows

";

Echo "
";
$searchtype = "";
$querystring = "";

?>






========================================================
--=====================_40855055==.ALT--

Re: Can"t carry over a key parameter from one form to another

am 30.09.2010 21:20:04 von Keith Davis

That's a little vague.

Why not merge the forms and set the column name with a session variable, the=
n it will only have to be chosen once.

Sent from my all-powerful iPhone 4,
Keith Davis 214-906-5183

On Sep 30, 2010, at 1:40 PM, "Bill Mudry" wrote:

> A few weeks ago I was able to get a simple search engine working
> in my "TAXA" project and very glad for it. All the pages are dynamically
> formed, so the search code has to be able to extract answers from
> the 'species' table. At first, the search method was hard wired to provide=
answers
> on a common name basis for different woods.
>
> I realized that I should be able to expand this to allow users to first
> choose by which column to do the search. I chose to list common names,
> botanical names, genus, location and description. This form is working jus=
t
> fine by itself.
>
> The rest of the code for the search is still working great ---- when I har=
d wire
> which column to use. However, I can't seem to get the user chosen paramete=
r
> ($searchtype) or its corresponding actual column name ($searchfield) to ca=
rry
> through once a user finally enters a search string and presses the submit =
button.
> Mind you, I can see that any output parameters from the first form gets wi=
ped out
> every time the form cycles back to the same page.
>
> I have tried adding a hidden field to preserve the $searchfield value. Tha=
t didn't
> work. I have tried adding a $_GET statement to bring back that value but t=
hat
> did not work either. I just tried to change the second form action from
> action=3D\"search.php\" to action=3D""
> and that didn't help either.
>
> What is the proper code to carry over $searchfield so it can be used by th=
e second form? Because of numerous decode statements I put in and because
> hard wiring a column name makes the search engine work just fine, I know t=
hat
> once that value can be used by the second form, I will have a search funct=
ion
> that will allow users to search by numerous choices. That would be one mor=
e
> giant leap for my project.
>
> Perhaps one answer would be to merge both forms into one but I am hoping
> I can keep then separate so a user doesn't have to choose the method of
> search for multiple queries.
>
> I always appreciate the fine help you have all supplied. It has meant the =
difference
> between accomplishing my goals or not
>
> Bill Mudry
> Mississauga, Ontario
>
> The running code can be seen and tried out at:
> http://www.prowebcanada.com/taxa/search.php
>
> Here is the complete code for that page:
> ==================== =====3D=
==================== =======
=====3D
> ..w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
>
>
>
> >
> TAXA: Search by Common Name
>
>
>
>
>
>
> lace.org/">
>
>
>
>
>
>
>
>
>



>
>
>


> This section is under development and will not work well until it is finis=
hed. It will
> expand the number of choices by which a person can do a search in the spec=
ies table
> (such as by species, common name, origin and so on).
>


>
>
>

>

Search TAXA


>
>
> Choose first by which means you wish to search.

>
>
>
" >
>
>
>
>
>
>
>
>
>
>
>
>
>
>

> Common names
> " />
>

> Botanical names
> ype" />
>

> Genus
>
>

> Location
> =

>

> Description
> />
>

> > echo " es_name}' />";
> ?>
>
>

>

>
>
>
> > // Get the search variable from URL
>
> $searchtype =3D @$_GET['searchtype'] ;
> $searchtype =3D trim($searchtype); //trim whitespace from the stored vari=
able
>
> If (isset($searchfield)) {
> echo "Searching by - $searchtype";
> };
> //echo "Line 149 - \$searchtype is - $searchtype
";
>
> $searchfield =3D "";
> switch ($searchtype) {
> case "common names":
> $searchfield =3D "species_commonname";
> //Echo "
common names
\n";
> break;
>
> case "botanical names":
> $searchfield =3D "species_name";
> //Echo "
botanical names - $searchfield
\n";
> break;
> case "genus":
> $searchfield =3D "genus_name";
> //Echo "
genus - $searchfield
\n";
> break;
> case "location":
> $searchfield =3D "location";
> //Echo "
location - $searchfield
\n";
> break;
> case "description":
> $searchfield =3D "species_description";
> //Echo "
description - $searchfield
\n";
> break;
> default: If (!isset($searchfield)) {
> echo "Please choose a search type first";
> }
>
> }
>
> //echo "Line 180 - \$searchtype is - $searchtype
";
>
> //Echo "Chosen search field (\$searchfield) is $searchfield

";=

>
> echo "

Searching by $searchtype

";
>
>
>
> echo "";
> echo "
";
> echo "Line 190 just before the query form - \$searchtype is - $searchtype<=
br />";
> ?>
>
>
>
" metho=
d=3D\"get\">
> > //echo "";
> echo "";
> // echo " es_name}\" />";
> // echo " htype\" />";
> // echo " rchfield}\" />";
> echo "";
> echo "
";
> echo "Line 199 just after the query form - \$searchtype is - $searchtype r />";
> echo "
";
>
>
> $searchtype =3D @$_GET['searchtype'] ;
>
> $searchtype =3D trim($searchtype);
>
>
> $searchfield =3D @$_GET['searchfield'] ;
>
> $searchfield =3D trim($searchfield);
>
>
> $querystring =3D @$_GET['querystring'] ;
>
> $querystring =3D trim($querystring);
>
> /*
> Development debug statement:
> */
> Echo "Line 209 - \$searchfield chosen by user is - $searchfield
";
>
>
> // rows to return
> $limit=3D'100';
>
> // check for an empty string and display a message.
>
>
> if ($querystring == "")
> {
> echo "

Please enter a search...

";
> exit;
> }
>
>
> // check for a search parameter
> if (!isset($querystring))
> {
> echo "

We do not seem to have anything to search for!

";
> exit;
> }
>
> //Echo "Line 212 - \$searchfield chosen by user is - $searchfield
";=

>
>
> //////////////////////////////////////////////////////////// ///////
> // CONNECT TO THE DATABASE
> //////////////////////////////////////////////////////////// ///////
>
> include ("connecttotaxa.php");
> $connection =3D mysql_connect($hostname, $username, $password)
> or die("Unable to connect to database server");
>
> $db =3D mysql_select_db($dbname, $connection)
> or die("Unable to connect to database");
>
> // Building optional search fields. Pegged to species common names =
at first
>
> //Echo "Line 253 - \$searchfield chosen by user is - $searchfield
";=

>
> /*
> Debug method: hard wire the searchfield at first to only common name searc=
hes to allow
> */
> //$searchfield=3D"species_commonname";
> //Echo "Line 253 - \$searchfield is hard set temporarily to $searchfield r />";
> Echo "Line 260 - \$searchfield is chosen as $searchfield
";
> Echo "Line 261 - \$querystring is user entered as $querystring
";
>
> // Build SQL Query
> $query =3D "select * from species where $searchfield like \"%$querystring%=
\"
> order by $searchfield";
>
> $numresults=3Dmysql_query($query);
> Echo "On line 268 \$numresults is - $numresults";
> $numrows=3Dmysql_num_rows($numresults);
>
> if ($numrows == 0)
> {
> echo "

Search Results by $searchtype

";
> echo "

Sorry, your search: "" . $querystring . "" returned ze=
ro results

";
>
> //echo "

Sorry, your search: "" . $trimmed . "" returned zero =
results

";
> }
>
> // next determine if s has been passed to script, if not use 0
> if (empty($s)) {
> $s=3D0;
> }
>
> // get results
> $query .=3D " limit $s,$limit";
> $result =3D mysql_query($query) or die("Couldn't execute query");
> echo "
";
>
> // display what the person searched for
> echo "

You searched for: "" . $querystring . ""

";
>
> // begin to show results set
> $count =3D 1 + $s ;
> Echo "
";
>
> //////////////////////////////////////////////////////////// //////////////=
/
> // Format the data with a double table and display the data
> //////////////////////////////////////////////////////////// //////////////=
/
>
> echo "";
> echo "";
> echo "";
> echo "";
> echo "
";
>
> echo "";
> echo "";
> echo "";
> echo "";
> echo "";
> echo "";
> echo "";
> echo "";
> echo "";
> echo "";
>
> echo "
";
>
> // now you can display the results returned
> while ($row=3D mysql_fetch_array($result))
> {
> extract($row); //At this point, the search data is ready for displa=
y
> //echo $row;
>
> echo "
";
>
> $title1 =3D $row["species_commonname"] ;
>
> $title2 =3D $row["species_name"];
>
> $title3 =3D $row["location"];
>
> echo "";
>
> echo "";
>
> echo "";
>
> echo "";
>
> echo "";
>
>
> // echo "$count. $title
" ;
>
> $count++ ;
> }
>
> echo "
";
> echo "

Results by Common Name

"; //The data title
> echo "
";
> echo "

#

";
> echo "
";
> echo "

Common Name

";
> echo "
";
> echo "

Botanical Name

";
> echo "
";
> echo "

Location

";
> echo "
";
> echo "$count";
> echo "
";
> echo "$title1";
> echo "
";
> echo '';=

> echo "$title2";
> echo"
.
\n";
>
> echo "
";
> echo "$title3";
> echo "
";
>
> echo "
";
> echo "
";
>
> $currPage =3D (($s/$limit) + 1);
> Echo "";
> //break before paging
> echo "
";
>
> // next we need to do the links to other results
> if ($s>=3D1) { // bypass PREV link if s is 0
> $prevs=3D($s-$limit);
> print " <<
> Prev 10
  ";
> }
>
> // calculate number of pages needing links
> $pages=3Dintval($numrows/$limit);
>
> // $pages now contains int of pages needed unless there is a remainder fro=
m division
>
> if ($numrows%$limit) {
> // has remainder so add one page
> $pages++;
> }
>
> // check to see if last page
> if (!((($s+$limit)/$limit)==$pages) && $pages!=3D1) {
>
> // not last page so give NEXT link
> $news=3D$s+$limit;
>
> echo " Next 10 >> a>";
> }
>
> $a =3D $s + ($limit) ;
> if ($a > $numrows) { $a =3D $numrows ; }
> $b =3D $s + 1 ;
> echo "

Showing results $b to $a of $numrows

";
>
> Echo "
";
> $searchtype =3D "";
> $querystring =3D "";
>
> ?>
>
>
>
>
>
>
> ==================== =====3D=
==================== =======
=====3D


This message (including any attachments) may contain confidential or otherwi=
se privileged information and is intended only for the individual(s) to whic=
h it is addressed. If you are not the named addressee you should not dissemi=
nate, distribute or copy this e-mail. Please notify the sender immediately b=
y e-mail if you have received this e-mail by mistake and delete this e-mail =
from your system. E-mail transmission cannot be guaranteed to be secured or =
error-free as information could be intercepted, corrupted, lost, destroyed, =
arrive late or incomplete, or contain viruses. The sender therefore does not=
accept liability for any errors or omissions in the contents of this messag=
e or that arise as a result of e-mail transmission. If verification is requi=
red please request a hard-copy version from the sender.

www.pridedallas.com


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Can"t carry over a key parameter from one form to another

am 30.09.2010 23:09:15 von Jacob Kruger

Store values in session variables?

First line of the pages would be something like:


After that, you can set/get values using the $_SESSION['valueName]' syntax.

Suppose the one issue might be if the browser has cookies turned off, but
anyway...

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

----- Original Message -----
From: "Bill Mudry"
To:
Sent: Thursday, September 30, 2010 8:38 PM
Subject: [PHP-WIN] Can't carry over a key parameter from one form to another


>A few weeks ago I was able to get a simple search engine working
> in my "TAXA" project and very glad for it. All the pages are dynamically
> formed, so the search code has to be able to extract answers from
> the 'species' table. At first, the search method was hard wired to
> provide answers
> on a common name basis for different woods.
>
> I realized that I should be able to expand this to allow users to first
> choose by which column to do the search. I chose to list common names,
> botanical names, genus, location and description. This form is working
> just
> fine by itself.
>
> The rest of the code for the search is still working great ---- when
> I hard wire
> which column to use. However, I can't seem to get the user chosen
> parameter
> ($searchtype) or its corresponding actual column name ($searchfield) to
> carry
> through once a user finally enters a search string and presses the
> submit button.
> Mind you, I can see that any output parameters from the first form
> gets wiped out
> every time the form cycles back to the same page.
>
> I have tried adding a hidden field to preserve the $searchfield
> value. That didn't
> work. I have tried adding a $_GET statement to bring back that value but
> that
> did not work either. I just tried to change the second form action from
> action=\"search.php\" to action=""
> and that didn't help either.
>
> What is the proper code to carry over $searchfield so it can be used
> by the second form? Because of numerous decode statements I put in and
> because
> hard wiring a column name makes the search engine work just fine, I know
> that
> once that value can be used by the second form, I will have a search
> function
> that will allow users to search by numerous choices. That would be one
> more
> giant leap for my project.
>
> Perhaps one answer would be to merge both forms into one but I am hoping
> I can keep then separate so a user doesn't have to choose the method of
> search for multiple queries.
>
> I always appreciate the fine help you have all supplied. It has meant
> the difference
> between accomplishing my goals or not
>
> Bill Mudry
> Mississauga, Ontario
>
> The running code can be seen and tried out at:
> http://www.prowebcanada.com/taxa/search.php
>
> Here is the complete code for that page:
> ========================================================
> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
>
>
>
>
> TAXA: Search by Common Name
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



>
>
>


> This section is under development and will not work well until it is
> finished. It will
> expand the number of choices by which a person can do a search in the
> species table
> (such as by species, common name, origin and so on).
>


>
>
>

>

Search TAXA


>
>
> Choose first by which means you wish to search.

>
>
>
> action="" >
>
>
>
>
>
>
>
>
>
>
>
>
>
>

> Common names
>
>

> Botanical names
> > />
>

> Genus
>
>

> Location
>
>

> Description
>
>

> > echo " > value='{$species_name}' />";
> ?>
>
>

>

>
>
>
> > // Get the search variable from URL
>
> $searchtype = @$_GET['searchtype'] ;
> $searchtype = trim($searchtype); //trim whitespace from the stored
> variable
>
> If (isset($searchfield)) {
> echo "Searching by - $searchtype";
> };
> //echo "Line 149 - \$searchtype is - $searchtype
";
>
> $searchfield = "";
> switch ($searchtype) {
> case "common names":
> $searchfield = "species_commonname";
> //Echo "
common names
\n";
> break;
>
> case "botanical names":
> $searchfield = "species_name";
> //Echo "
botanical names - $searchfield
>
\n";
> break;
> case "genus":
> $searchfield = "genus_name";
> //Echo "
genus - $searchfield
\n";
> break;
> case "location":
> $searchfield = "location";
> //Echo "
location - $searchfield
\n";
> break;
> case "description":
> $searchfield = "species_description";
> //Echo "
description - $searchfield
>
\n";
> break;
> default: If (!isset($searchfield)) {
> echo "Please choose a search type first";
> }
>
> }
>
> //echo "Line 180 - \$searchtype is - $searchtype
";
>
> //Echo "Chosen search field (\$searchfield) is $searchfield

";
>
> echo "

Searching by $searchtype

";
>
>
>
> echo "";
> echo "
";
> echo "Line 190 just before the query form - \$searchtype is -
> $searchtype
";
> ?>
>
>
>
> method=\"get\">
> > //echo "";
> echo "";
> // echo " > value=\"{$species_name}\" />";
> // echo " > value=\"$searchtype\" />";
> // echo " > value=\"{$searchfield}\" />";
> echo "";
> echo "
";
> echo "Line 199 just after the query form - \$searchtype is -
> $searchtype
";
> echo "
";
>
>
> $searchtype = @$_GET['searchtype'] ;
>
> $searchtype = trim($searchtype);
>
>
> $searchfield = @$_GET['searchfield'] ;
>
> $searchfield = trim($searchfield);
>
>
> $querystring = @$_GET['querystring'] ;
>
> $querystring = trim($querystring);
>
> /*
> Development debug statement:
> */
> Echo "Line 209 - \$searchfield chosen by user is - $searchfield
";
>
>
> // rows to return
> $limit='100';
>
> // check for an empty string and display a message.
>
>
> if ($querystring == "")
> {
> echo "

Please enter a search...

";
> exit;
> }
>
>
> // check for a search parameter
> if (!isset($querystring))
> {
> echo "

We do not seem to have anything to search for!

";
> exit;
> }
>
> //Echo "Line 212 - \$searchfield chosen by user is - $searchfield
";
>
>
> //////////////////////////////////////////////////////////// ///////
> // CONNECT TO THE DATABASE
> //////////////////////////////////////////////////////////// ///////
>
> include ("connecttotaxa.php");
> $connection = mysql_connect($hostname, $username, $password)
> or die("Unable to connect to database server");
>
> $db = mysql_select_db($dbname, $connection)
> or die("Unable to connect to database");
>
> // Building optional search fields. Pegged to species common
> names at first
>
> //Echo "Line 253 - \$searchfield chosen by user is - $searchfield
";
>
> /*
> Debug method: hard wire the searchfield at first to only common name
> searches to allow
> */
> //$searchfield="species_commonname";
> //Echo "Line 253 - \$searchfield is hard set temporarily to
> $searchfield
";
> Echo "Line 260 - \$searchfield is chosen as $searchfield
";
> Echo "Line 261 - \$querystring is user entered as $querystring
";
>
> // Build SQL Query
> $query = "select * from species where $searchfield like \"%$querystring%\"
> order by $searchfield";
>
> $numresults=mysql_query($query);
> Echo "On line 268 \$numresults is - $numresults";
> $numrows=mysql_num_rows($numresults);
>
> if ($numrows == 0)
> {
> echo "

Search Results by $searchtype

";
> echo "

Sorry, your search: "" . $querystring . ""
> returned zero results

";
>
> //echo "

Sorry, your search: "" . $trimmed . ""
> returned zero results

";
> }
>
> // next determine if s has been passed to script, if not use 0
> if (empty($s)) {
> $s=0;
> }
>
> // get results
> $query .= " limit $s,$limit";
> $result = mysql_query($query) or die("Couldn't execute query");
> echo "
";
>
> // display what the person searched for
> echo "

You searched for: "" . $querystring . ""

";
>
> // begin to show results set
> $count = 1 + $s ;
> Echo "
";
>
> //////////////////////////////////////////////////////////// ///////////////
> // Format the data with a double table and display the data
> //////////////////////////////////////////////////////////// ///////////////
>
> echo "";
> echo "";
> echo "";
> echo "";
> echo "
";
>
> echo "";
> echo "";
> echo "";
> echo "";
> echo "";
> echo "";
> echo "";
> echo "";
> echo "";
> echo "";
>
> echo "
";
>
> // now you can display the results returned
> while ($row= mysql_fetch_array($result))
> {
> extract($row); //At this point, the search data is ready for
> display
> //echo $row;
>
> echo "
";
>
> $title1 = $row["species_commonname"] ;
>
> $title2 = $row["species_name"];
>
> $title3 = $row["location"];
>
> echo "";
>
> echo "";
>
> echo "";
>
> echo "";
>
> echo "";
>
>
> // echo "$count. $title
" ;
>
> $count++ ;
> }
>
> echo "
";
> echo "

Results by Common Name

"; //The data title
> echo "
";
> echo "

#

";
> echo "
";
> echo "

Common Name

";
> echo "
";
> echo "

Botanical Name

";
> echo "
";
> echo "

Location

";
> echo "
";
> echo "$count";
> echo "
";
> echo "$title1";
> echo "
";
> echo '';
> echo "$title2";
> echo"
.
\n";
>
> echo "
";
> echo "$title3";
> echo "
";
>
> echo "
";
> echo "
";
>
> $currPage = (($s/$limit) + 1);
> Echo "";
> //break before paging
> echo "
";
>
> // next we need to do the links to other results
> if ($s>=1) { // bypass PREV link if s is 0
> $prevs=($s-$limit);
> print " 
<<
> Prev 10
  ";
> }
>
> // calculate number of pages needing links
> $pages=intval($numrows/$limit);
>
> // $pages now contains int of pages needed unless there is a
> remainder from division
>
> if ($numrows%$limit) {
> // has remainder so add one page
> $pages++;
> }
>
> // check to see if last page
> if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {
>
> // not last page so give NEXT link
> $news=$s+$limit;
>
> echo " ";
> }
>
> $a = $s + ($limit) ;
> if ($a > $numrows) { $a = $numrows ; }
> $b = $s + 1 ;
> echo "

Showing results $b to $a of $numrows

";
>
> Echo "
";
> $searchtype = "";
> $querystring = "";
>
> ?>
>
>
>
>
>
>
> ========================================================
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 5493 (20100930) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>


__________ Information from ESET NOD32 Antivirus, version of virus signature database 5493 (20100930) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php