Looking for code for an alphabetic menu in php

Looking for code for an alphabetic menu in php

am 22.05.2009 03:51:29 von Bill Mudry

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

With the botanical wood tree that I have been working on, the number
of records for
genera and for species can get quite large and unwieldy. Presently I
have over 6,000
species records that takes a while to load let alone try to browse through.

I need to chop this up into querying by alphabet of the first letter
of the species
botanical names. For the species level of organization, I have been
keeping the
data in a MySQL file called simply 'species'. I want to have a single
character of the
alphabet with each acting as a link for the first character of each
species name:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
When a user click on one of them, it should be readable (eg. using
$_GET??) into a common variable for
them all that can then be used for a select statement. The rest of
displaying the
results in columns I already have working fine.

What suggestions do you have for typical code that should work?

Much thanks in advance,

Bill Mudry
Mississauga, Ontario, Canada
--=====================_23431828==.ALT--

Re: Looking for code for an alphabetic menu in php

am 22.05.2009 08:29:21 von Lester Caine

Bill Mudry wrote:
> With the botanical wood tree that I have been working on, the number of
> records for
> genera and for species can get quite large and unwieldy. Presently I
> have over 6,000
> species records that takes a while to load let alone try to browse through.
>
> I need to chop this up into querying by alphabet of the first letter of
> the species
> botanical names. For the species level of organization, I have been
> keeping the
> data in a MySQL file called simply 'species'. I want to have a single
> character of the
> alphabet with each acting as a link for the first character of each
> species name:
> A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
> When a user click on one of them, it should be readable (eg. using
> $_GET??) into a common variable for
> them all that can then be used for a select statement. The rest of
> displaying the
> results in columns I already have working fine.
>
> What suggestions do you have for typical code that should work?

Not quite sure what your problem is, you just need to add a filter to
the where clause of your query. I don't think MySQL has STARTING 'A',
but it certainly has LIKE 'A%', so just get each letter to return a link
containing it's letter and use that to select the 'page' of names you want.

$a = $_GET['letter'];
$sql = "SELECT * FROM SPECIES WHERE NAME LIKE '$a%'";

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

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

Re: Looking for code for an alphabetic menu in php

am 22.05.2009 10:23:19 von harlequin2

Hi Bill,

I don't know if I got you right but I hope this will help:

[CODE]
$baseLink = "index.php?letter="; // Assuming your file name is
"index.php"; set up the base link for all pages

//alphabetical links
for($a=65;$a<(65+26);$a++){
print "\n";
}
if (isset($_GET["letter"]) && $_GET["letter"] != ""){
$letter = $_GET["letter"];
$sql = "SELECT * FROM species WHERE [SPECIES_NAME] LIKE
'".$letter."%'"; // Replace [SPECIES_NAME] with your column name
$res = mysql_query($sql);
if ($res){
while ($row = mysql_fetch_row($res)){
// retrieve your row info
}
} else {
print "Failed retrieving data set, error was: ".mysql_error();
}
}
?>
[/CODE]

Enjoy,

Sascha


Bill Mudry schrieb:
> With the botanical wood tree that I have been working on, the number
> of records for
> genera and for species can get quite large and unwieldy. Presently I
> have over 6,000
> species records that takes a while to load let alone try to browse
> through.
>
> I need to chop this up into querying by alphabet of the first letter
> of the species
> botanical names. For the species level of organization, I have been
> keeping the
> data in a MySQL file called simply 'species'. I want to have a single
> character of the
> alphabet with each acting as a link for the first character of each
> species name:
> A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
> When a user click on one of them, it should be readable (eg. using
> $_GET??) into a common variable for
> them all that can then be used for a select statement. The rest of
> displaying the
> results in columns I already have working fine.
>
> What suggestions do you have for typical code that should work?
>
> Much thanks in advance,
>
> Bill Mudry
> Mississauga, Ontario, Canada


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

Re: Looking for code for an alphabetic menu in php

am 22.05.2009 13:25:11 von James Crow

Bill Mudry wrote:
> With the botanical wood tree that I have been working on, the number
> of records for
> genera and for species can get quite large and unwieldy. Presently I
> have over 6,000
> species records that takes a while to load let alone try to browse
> through.
>
> I need to chop this up into querying by alphabet of the first letter
> of the species
> botanical names. For the species level of organization, I have been
> keeping the
> data in a MySQL file called simply 'species'. I want to have a single
> character of the
> alphabet with each acting as a link for the first character of each
> species name:
> A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
> When a user click on one of them, it should be readable (eg. using
> $_GET??) into a common variable for
> them all that can then be used for a select statement. The rest of
> displaying the
> results in columns I already have working fine.
>
> What suggestions do you have for typical code that should work?
>
> Much thanks in advance,
>
> Bill Mudry
> Mississauga, Ontario, Canada
Bill,

I read this as you want the user to be able to select multiple letters
to search on. If so I would recommend making each letter a checkbox. In
your php code you would need to check each element in the $_GET or
$_POST array. The SQL would then need to be:

SELECT species_name
FROM species
WHERE species_name LIKE 'b%'
OR species_name LIKE 'g%'
OR species_name LIKE 'r%';

Replace species_name with the correct column name.

Without resorting to some sort of client side scripting I am not sure
you could select multiple letters to search on with simple HTML links.

Cheers,
James


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

Re: Looking for code for an alphabetic menu in php

am 22.05.2009 13:37:40 von Richard Quadling

2009/5/22 James Crow :
> Bill Mudry wrote:
>>
>> With the botanical wood tree that I have been working on, the number of
>> records for
>> genera and for species can get quite large and unwieldy. Presently I hav=
e
>> over 6,000
>> species records that takes a while to load let alone try to browse
>> through.
>>
>> I need to chop this up into querying by alphabet of the first letter of
>> the species
>> botanical names. For the species level of organization, I have been
>> keeping the
>> data in a MySQL file called simply 'species'. I want to have a single
>> character of the
>> alphabet with each acting as a link for the first character of each
>> species name:
>>        A B C D E F G H I J K L M N O P Q R S T U V W=
X Y Z
>> When a user click on one of them, it should be readable (eg. using
>> $_GET??) into a common variable for
>> them all that can then be used for a select statement. The rest of
>> displaying the
>> results in columns I already have working fine.
>>
>> What suggestions do you have for typical code that should work?
>>
>> Much thanks in advance,
>>
>> Bill Mudry
>> Mississauga, Ontario, Canada
>
> Bill,
>
>  I read this as you want the user to be able to select multiple lett=
ers to
> search on. If so I would recommend making each letter a checkbox. In your
> php code you would need to check each element in the $_GET or $_POST arra=
y.
> The SQL would then need to be:
>
> SELECT species_name
>   FROM species
>   WHERE species_name LIKE 'b%'
>   OR species_name LIKE 'g%'
>   OR species_name LIKE 'r%';
>
> Replace species_name with the correct column name.
>
> Without resorting to some sort of client side scripting I am not sure you
> could select multiple letters to search on with simple HTML links.
>
> Cheers,
> James
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

You can also ...

SELECT species_name
FROM species
WHERE species_name LIKE '[bgr]%'

Slightly smaller code.

--=20
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
"Standing on the shoulders of some very clever giants!"

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

Re: Looking for code for an alphabetic menu in php

am 22.05.2009 14:24:50 von Joseph LeBlanc

Make sure you filter $letter before using it in the query. Replace
$letter = $_GET["letter"] with this:

preg_match('/^[A-Z]/', $_GET["letter"], $matches);
$letter = $matches[0];

If you don't do this, someone could insert malicious SQL into the
$letter variable. This regular expression will match only one capital
letter at the beginning of the string $_GET["letter"].

-Joe

On May 22, 2009, at 3:23 AM, Sascha Meyer wrote:

> Hi Bill,
>
> I don't know if I got you right but I hope this will help:
>
> [CODE]
> > $baseLink = "index.php?letter="; // Assuming your file name is
> "index.php"; set up the base link for all pages
>
> //alphabetical links
> for($a=65;$a<(65+26);$a++){
> print "\n";
> }
> if (isset($_GET["letter"]) && $_GET["letter"] != ""){
> $letter = $_GET["letter"];
> $sql = "SELECT * FROM species WHERE [SPECIES_NAME] LIKE '".
> $letter."%'"; // Replace [SPECIES_NAME] with your column name
> $res = mysql_query($sql);
> if ($res){
> while ($row = mysql_fetch_row($res)){
> // retrieve your row info
> }
> } else {
> print "Failed retrieving data set, error was: ".mysql_error();
> }
> }
> ?>
> [/CODE]
>
> Enjoy,
>
> Sascha


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

Excel OLE Automation : accessing the Excel constants

am 27.05.2009 06:55:51 von Samuel.Faubry

Hi,

I'm confronted to a new problem with Excel Automation: I don't manage to
access the constants.

For example, I want to find the last cell in a column:

ExcelSheet.Range("C65536").End(xlUp)

This fails because the constant xlUp is undefined...

There is some user contributed notes about that problem in the
documentation (http://jp2.php.net/manual/en/book.com.php) but it doesn't
say if it's possible to really access the Excel constants.

Thanks for your help !

Sam

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

Re: Excel OLE Automation : accessing the Excel constants

am 27.05.2009 08:29:48 von Geoff Lane

On Wednesday, May 27, 2009, 5:55:51 AM, Samuel wrote:

> ExcelSheet.Range("C65536").End(xlUp)

> This fails because the constant xlUp is undefined...

> There is some user contributed notes about that problem in the
> documentation (http://jp2.php.net/manual/en/book.com.php) but it doesn't
> say if it's possible to really access the Excel constants.
---

You need to define the constants for yourself. Since I don't use PHP
with Excel I haven't done this and so cannot give you a ready-made
file to require(). However, Microsoft give a full list of the
constants at http://msdn.microsoft.com/en-us/library/aa221100.aspx -
so you can look up the ones you need and add them to your own library
as you go along.

HTH,

--
Geoff


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

Re: Re: Excel OLE Automation : accessing the Excel

am 27.05.2009 14:43:17 von Richard Quadling

2009/5/27 Geoff Lane :
> On Wednesday, May 27, 2009, 5:55:51 AM, Samuel wrote:
>
>> ExcelSheet.Range("C65536").End(xlUp)
>
>> This fails because the constant xlUp is undefined...
>
>> There is some user contributed notes about that problem in the
>> documentation (http://jp2.php.net/manual/en/book.com.php) but it doesn't
>> say if it's possible to really access the Excel constants.
> ---
>
> You need to define the constants for yourself. Since I don't use PHP
> with Excel I haven't done this and so cannot give you a ready-made
> file to require(). However, Microsoft give a full list of the
> constants at http://msdn.microsoft.com/en-us/library/aa221100.aspx -
> so you can look up the ones you need and add them to your own library
> as you go along.
>
> HTH,
>
> --
> Geoff
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

This is 3 lines from my PHP script dealing with talking to Crystal Reports.

// Create an Crystal Object Factory.
$o_CrObjectFactory = New COM('CrystalReports11.ObjectFactory.1');

// Create the Crystal Reports Runtime Application.
$o_CrApplication =
$o_CrObjectFactory->CreateObject("CrystalRunTime.Application .11");

// Register the typelibrary.
com_load_typelib('CrystalDesignRunTime.Application');

// Show the value for the PDF Export file type.
echo crEFTPortableDocFormat; // Outputs 31




So, whatever library you load, you have to use com_load_typelib()
(http://docs.php.net/com_load_typelib) on it.

I believe that this is supposed to happen automatically if
com.autoregister_typelib is set, but as the documentation mentions,
the auto-registration is library dependent.

Regards,

Richard.

--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

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