php-general Digest 11 Sep 2005 02:02:52 -0000 Issue 3675
Topics (messages 222111 through 222132):
array2string
222111 by: David Christensen
222112 by: Niels Ganser
222113 by: afan.afan.net
switching php version
222114 by: Florent Monnier
222116 by: Niels Ganser
Convert a timestamp to RFC822??
222115 by: Brian Dunning
222117 by: Niels Ganser
222129 by: Jordan Miller
PHP on FreeBSD - Compiler Bugs and Option selection
222118 by: Vizion
222119 by: Vizion
what is Storage drivers ?
222120 by: mzz2k4
creating a login/registration/admin function/app
222121 by: bruce
222122 by: Manuel Lemos
222127 by: Jay Paulson
ran into a seemingly odd problem
222123 by: matt VanDeWalle
222128 by: Jasper Bryant-Greene
seemingly odd problem
222124 by: matt VanDeWalle
searching through a mysql db/tbl
222125 by: bruce
222126 by: Stephen Johnson
222132 by: Murray . PlanetThoughtful
Re: Books / tutorials on Object Oriented Programming with PHP
222130 by: Jordan Miller
thanks for the help
222131 by: matt VanDeWalle
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Pardon my ignorance and lack of ability to form the right search for
google, but I'm trying to figure out if there's a simple function in PHP
to convert array values to a string with a separator for each value.
eg.
$arr = array(1, 5, 2);
$str = <some_funct>($arr, ',');
print $str; # "1,5,2"
Thanks for your help,
David Christensen
--- End Message ---
--- Begin Message ---
string implode(string glue, array pieces) [1]
Regards,
Niels
[1] http://php.net/manual/en/function.implode.php
> Pardon my ignorance and lack of ability to form the right search for
> google, but I'm trying to figure out if there's a simple function in
> PHP to convert array values to a string with a separator for each
> value.
--- End Message ---
--- Begin Message ---
try serialize function
http://us2.php.net/serialize
it's easy to switch back to array again.
small addition to Niels'post
array 2 string - implode (http://us2.php.net/implode)
string to array - explode (http://us2.php.net/explode)
-afan
> string implode(string glue, array pieces) [1]
>
> Regards,
> Niels
>
> [1] http://php.net/manual/en/function.implode.php
>
>> Pardon my ignorance and lack of ability to form the right search for
>> google, but I'm trying to figure out if there's a simple function in
>> PHP to convert array values to a string with a separator for each
>> value.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Hi,
I have put the last php in /usr/local/bin/php505, but apache still use the
older php in /usr/bin/php
How to configure apache to select one particular from several installed php?
--
Thanks
--- End Message ---
--- Begin Message ---
Choose the right module. Search your apache config for "LoadModule
php5_module" resp. "LoadModule php4_module".
> How to configure apache to select one particular from several
> installed php?
--- End Message ---
--- Begin Message ---
I get my timestamp from the db in this format (I don't have control
over this):
2004-05-14 13:24:48
I need to convert it to RFC822 to make it a valid RSS pubDate field
like this:
Wed, 02 Oct 2002 13:00:00 GMT
How can I do that? I'm tearing my hair out here (what's left)...
:)
--- End Message ---
--- Begin Message ---
Usually you can use a function in your SELECT statement to change the
format of your timestamp. In MySQL it's DATE_FORMAT [1]. Otherwise use
PHP's Date and Time Functions [2]. You could for instance extract the
"ingredients" of your database's timestamp with strptime [3] and
reformat it with strftime [4].
Regards,
Niels
[1]
http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html#id2728257
[2] http://php.net/manual/en/ref.datetime.php
[3] http://php.net/manual/en/function.strptime.php
[4] http://php.net/manual/en/function.strftime.php
> I get my timestamp from the db in this format (I don't have control
> over this):
>
> 2004-05-14 13:24:48
>
> I need to convert it to RFC822 to make it a valid RSS pubDate field
> like this:
>
> Wed, 02 Oct 2002 13:00:00 GMT
>
> How can I do that? I'm tearing my hair out here (what's left)...
--- End Message ---
--- Begin Message ---
we *just* had a post similar to this. It's easy, just use the date()
and strtotime() functions:
$timestamp = '2004-05-14 13:24:48';
$RFC_formatted = date('r', strtotime($timestamp));
done!
Jordan
On Sep 10, 2005, at 11:14 AM, Brian Dunning wrote:
I get my timestamp from the db in this format (I don't have control
over this):
2004-05-14 13:24:48
I need to convert it to RFC822 to make it a valid RSS pubDate field
like this:
Wed, 02 Oct 2002 13:00:00 GMT
How can I do that? I'm tearing my hair out here (what's left)...
:)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi ale
I just wanted to check you had received OK the two compiler errors that I
reported for /usr/ports/lang/php5-extensions.
The first error was apparently caused by make expecting libmagic in an
incorrect path for FreeBSD 5.3. Once a copy was placed in the correct path
compilation resumed.
The second error seems also to be caused by an inability to find requisite
files for wddx.
ext/xml/expat_compat.h
ext/xml/php
As a result of compiling php5 I began to wonder whether it would be helpful
to users if :
drwxr-xr-x 3 root wheel 512 May 2 07:06 php5-cli
drwxr-xr-x 3 root wheel 512 Sep 9 18:00 php5-extensions
drwxr-xr-x 3 root wheel 512 May 28 10:06 php_doc
were more integrated as choices within make for php5.
I would personally find it helpful if all the build options for php could be
in an editable file for sysadmins to define a repeatable unattended build
from all available build options. A closer integration of the subsidiary php5
ports into the php5 make would facilitate this process.
I do not not how welcome these proposals might be or how easy it would be to
make the changes but would be interested to know what others think.
Norberto Meijome <[EMAIL PROTECTED]> made a very interesting suggestion that
he uses on his servers to achieve the above goal. He
uses /usr/local/etc/pkgtools.conf for that purpose but my preference would be
to have a method that is particular to php and does not lead to an
overloading of /usr/local/etc/pkgtools.conf.
I have copied Norbeto's example below:
****************** Quote*******************************
-if you want to avoid having to choose by hand what you really
-want( or have it preconfigured so all you have to do is press OK, then
-use something like /usr/local/etc/pkgtools.conf which will be read by
-portinstall (sysutils/port-maintenance-tools/)
-my relevant sections for my servers are:
-
----
- 'php4-*' =- [
- 'WITH_APACHE2=true',
- 'WITHOUT_DEBUG=true',
- 'WITH_BCMATH=true',
- 'WITH_BZ2=true',
- 'WITHOUT_CALENDAR=true',
- 'WITH_CRACK=true',
- 'WITH_CTYPE=true',
- 'WITHOUT_CURL=true',
- 'WITH_DBA=true',
- 'WITHOUT_DBASE=true',
- 'WITHOUT_DBX=true',
- 'WITHOUT_DIO=true',
- 'WITHOUT_DOMXML=true',
- 'WITHOUT_EXIF=true',
- 'WITHOUT_FILEINFO=true',
- 'WITHOUT_FILEPRO=true',
- 'WITHOUT_FRIBIDI=true',
- 'WITH_FTP=true',
- 'WITH_GD=true',
- 'WITHOUT_GETTEXT=true',
- 'WITHOUT_GMP=true',
- 'WITHOUT_ICONV=true',
- 'WITHOUT_IMAGICK=true',
- 'WITHOUT_IMAP=true',
- 'WITHOUT_INTERBASE=true',
- 'WITHOUT_LDAP=true',
- 'WITH_MBSTRING=true',
- 'WITHOUT_MCAL=true',
- 'WITH_MCRYPT=true',
- 'WITHOUT_MCVE=true',
- 'WITH_MHASH=true',
- 'WITHOUT_MING=true',
- 'WITHOUT_MNOGOSEARCH=true',
- 'WITHOUT_MSSQL=true',
- 'WITH_MYSQL=true',
- 'WITHOUT_NCURSES=true',
- 'WITHOUT_ODBC=true',
- 'WITHOUT_OPENSSL=true',
- 'WITHOUT_ORACLE=true',
- 'WITH_OVERLOAD=true',
- 'WITHOUT_PANDA=true',
- 'WITHOUT_PCNTL=true',
- 'WITH_PCRE=true',
- 'WITHOUT_PDF=true',
- 'WITHOUT_PGSQL=true',
- 'WITH_POSIX=true',
- 'WITHOUT_PSPELL=true',
- 'WITHOUT_READLINE=true',
- 'WITHOUT_RECODE=true',
- 'WITH_SESSION=true',
- 'WITH_SHMOP=true',
- 'WITHOUT_SNMP=true',
- 'WITHOUT_SOCKETS=true',
- 'WITHOUT_SYBASE_CT=true',
- 'WITH_SYSVMSG=true',
- 'WITH_SYSVSEM=true',
- 'WITH_SYSVSHM=true',
- 'WITH_TOKENIZER=true',
- 'WITHOUT_WDDX=true',
- 'WITH_XML=true',
- 'WITHOUT_XMLRPC=true',
- 'WITH_XSLT=true',
- 'WITHOUT_YAZ=true',
- 'WITHOUT_YP=true',
- 'WITH_ZIP=true',
- 'WITH_ZLIB=true',
- ],
- 'php4-dba-*' =- [
- 'WITH_CDB=true',
- 'WITH_DB4=true',
- 'WITH_GDBM=true',
- 'WITH_INIFILE=true',
- 'WITH_FLATFILE=true',
- ],
- 'php4-gd-*' =- [
- 'WITH_T1LIB=true',
- 'WITH_TRUETYPE=true',
- 'WITHOUT_JIS=true',
- 'WITH_LZW=true',
- ],
- 'php4-mbstring-*' =- [
- 'WITH_REGEX=true',
- ],
*************End Quote***************************
I also wonder why the Makefile, by default, uses the --disable-all option in
the Makefile with no option to remove it.
I would be interested in what others have to say and would like to place on
record my appreciation for all your work in maintaining the ports.
david
--
40 yrs navigating and computing in blue waters.
English Owner & Captain of British Registered 60' bluewater Ketch S/V Taurus.
Currently in San Diego, CA. Sailing bound for Europe via Panama Canal after
completing engineroom refit.
--- End Message ---
--- Begin Message ---
On Saturday 10 September 2005 12:49, the author Vizion contributed to the
dialogue on-
PHP on FreeBSD - Compiler Bugs and Option selection:
>Hi ale
>
>I just wanted to check you had received OK the two compiler errors that I
>reported for /usr/ports/lang/php5-extensions.
>
>The first error was apparently caused by make expecting libmagic in an
>incorrect path for FreeBSD 5.3. Once a copy was placed in the correct path
>compilation resumed.
>
I meant to say that full credit should be given to
Kris Kennaway <[EMAIL PROTECTED]> who made the suggestion to
copy /usr/src/contrib/file/magic.h to
/usr/include/magic.h
and see if it works. Which it did.
>The second error seems also to be caused by an inability to find requisite
>files for wddx.
>ext/xml/expat_compat.h
>ext/xml/php
>
>As a result of compiling php5 I began to wonder whether it would be helpful
>to users if :
>drwxr-xr-x 3 root wheel 512 May 2 07:06 php5-cli
>drwxr-xr-x 3 root wheel 512 Sep 9 18:00 php5-extensions
>drwxr-xr-x 3 root wheel 512 May 28 10:06 php_doc
>were more integrated as choices within make for php5.
>
>I would personally find it helpful if all the build options for php could be
>in an editable file for sysadmins to define a repeatable unattended build
>from all available build options. A closer integration of the subsidiary
> php5 ports into the php5 make would facilitate this process.
>
>I do not not how welcome these proposals might be or how easy it would be to
>make the changes but would be interested to know what others think.
>
>Norberto Meijome <[EMAIL PROTECTED]> made a very interesting suggestion
> that he uses on his servers to achieve the above goal. He
>uses /usr/local/etc/pkgtools.conf for that purpose but my preference would
> be to have a method that is particular to php and does not lead to an
>overloading of /usr/local/etc/pkgtools.conf.
>
>I have copied Norbeto's example below:
>****************** Quote*******************************
>-if you want to avoid having to choose by hand what you really
>-want( or have it preconfigured so all you have to do is press OK, then
>-use something like /usr/local/etc/pkgtools.conf which will be read by
>-portinstall (sysutils/port-maintenance-tools/)
>-my relevant sections for my servers are:
>-
>----
>- 'php4-*' =- [
>- 'WITH_APACHE2=true',
>- 'WITHOUT_DEBUG=true',
>- 'WITH_BCMATH=true',
>- 'WITH_BZ2=true',
>- 'WITHOUT_CALENDAR=true',
>- 'WITH_CRACK=true',
>- 'WITH_CTYPE=true',
>- 'WITHOUT_CURL=true',
>- 'WITH_DBA=true',
>- 'WITHOUT_DBASE=true',
>- 'WITHOUT_DBX=true',
>- 'WITHOUT_DIO=true',
>- 'WITHOUT_DOMXML=true',
>- 'WITHOUT_EXIF=true',
>- 'WITHOUT_FILEINFO=true',
>- 'WITHOUT_FILEPRO=true',
>- 'WITHOUT_FRIBIDI=true',
>- 'WITH_FTP=true',
>- 'WITH_GD=true',
>- 'WITHOUT_GETTEXT=true',
>- 'WITHOUT_GMP=true',
>- 'WITHOUT_ICONV=true',
>- 'WITHOUT_IMAGICK=true',
>- 'WITHOUT_IMAP=true',
>- 'WITHOUT_INTERBASE=true',
>- 'WITHOUT_LDAP=true',
>- 'WITH_MBSTRING=true',
>- 'WITHOUT_MCAL=true',
>- 'WITH_MCRYPT=true',
>- 'WITHOUT_MCVE=true',
>- 'WITH_MHASH=true',
>- 'WITHOUT_MING=true',
>- 'WITHOUT_MNOGOSEARCH=true',
>- 'WITHOUT_MSSQL=true',
>- 'WITH_MYSQL=true',
>- 'WITHOUT_NCURSES=true',
>- 'WITHOUT_ODBC=true',
>- 'WITHOUT_OPENSSL=true',
>- 'WITHOUT_ORACLE=true',
>- 'WITH_OVERLOAD=true',
>- 'WITHOUT_PANDA=true',
>- 'WITHOUT_PCNTL=true',
>- 'WITH_PCRE=true',
>- 'WITHOUT_PDF=true',
>- 'WITHOUT_PGSQL=true',
>- 'WITH_POSIX=true',
>- 'WITHOUT_PSPELL=true',
>- 'WITHOUT_READLINE=true',
>- 'WITHOUT_RECODE=true',
>- 'WITH_SESSION=true',
>- 'WITH_SHMOP=true',
>- 'WITHOUT_SNMP=true',
>- 'WITHOUT_SOCKETS=true',
>- 'WITHOUT_SYBASE_CT=true',
>- 'WITH_SYSVMSG=true',
>- 'WITH_SYSVSEM=true',
>- 'WITH_SYSVSHM=true',
>- 'WITH_TOKENIZER=true',
>- 'WITHOUT_WDDX=true',
>- 'WITH_XML=true',
>- 'WITHOUT_XMLRPC=true',
>- 'WITH_XSLT=true',
>- 'WITHOUT_YAZ=true',
>- 'WITHOUT_YP=true',
>- 'WITH_ZIP=true',
>- 'WITH_ZLIB=true',
>- ],
>- 'php4-dba-*' =- [
>- 'WITH_CDB=true',
>- 'WITH_DB4=true',
>- 'WITH_GDBM=true',
>- 'WITH_INIFILE=true',
>- 'WITH_FLATFILE=true',
>- ],
>- 'php4-gd-*' =- [
>- 'WITH_T1LIB=true',
>- 'WITH_TRUETYPE=true',
>- 'WITHOUT_JIS=true',
>- 'WITH_LZW=true',
>- ],
>- 'php4-mbstring-*' =- [
>- 'WITH_REGEX=true',
>- ],
>*************End Quote***************************
>
>I also wonder why the Makefile, by default, uses the --disable-all option in
>the Makefile with no option to remove it.
>
>I would be interested in what others have to say and would like to place on
>record my appreciation for all your work in maintaining the ports.
>
>david
--
40 yrs navigating and computing in blue waters.
English Owner & Captain of British Registered 60' bluewater Ketch S/V Taurus.
Currently in San Diego, CA. Sailing bound for Europe via Panama Canal after
completing engineroom refit.
--- End Message ---
--- Begin Message ---
Dear Sir Pear List users
hi every one i am confused what is Storage drivers is?
please introduce me what is this?
thanks in advance.
zarbizade
--- End Message ---
--- Begin Message ---
hi...
i'm in the process of looking for/creating a function to allow me to perform
user login/registration/etc, as well as handle a user admin function.
i'm looking for the following functionality:
user registration/login:
-allow user to enter basic information
-allow user to enter username/passwd
-ensure unique username
-email confirmation of user registration
-password regeneration (forgot passwd)
-handle forgot username/password
-ip blocking
-email blocking
-security graphic verification (capcha??)
-admin notification
-aadmin enable/authorize
-Session var generation on successful login
-limit login attempts for invalid logins
-ensure only single usage of login at a time
-ensure that multiple logins of a login is
within a geographic/IP range
-IP/User tracking
-captcha processing/implementation
-
Admin functionality:
-IP Tracking
-IP blocking
-User Management
-User Enable/Disable function
-User Auth/Verification function
-User Email Function
-User Password regeneration function
-Site Mamagement
-List Users
-Track User Actions within site
-Allow User to be a member of a given group
-Create Groups
-Assign User Roles/Groups
-
-
-
-
This is kind of a basic/starting point. I'm looking at a few CMS apps, but
i'm curious to know if you guys have seen any app (open source) that has
what i'm looking for...
I'm in the process of extracting the functionality from Mambo/phpBB and
adding some of what i need. Does anybody have any idea as to whether an
existing "Open Source" app is out here, that gives a good deal of this
functionality? Searching google turns up alot of scripts, but nothing that
really has what i'm after and that's free!!
Also, if i have to pretty much create this from scratch, is there anybody
who'd want to play the role of architect/test/reviewer??
thanks
bruce
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Hello,
on 09/10/2005 05:39 PM bruce said the following:
Does anybody have any idea as to whether an
existing "Open Source" app is out here, that gives a good deal of this
functionality? Searching google turns up alot of scripts, but nothing that
really has what i'm after and that's free!!
You may want to take a look at this class as it seems to do most of what
you want:
http://www.phpclasses.org/access_user
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--- End Message ---
--- Begin Message ---
You might also take a look at the following.
http://phpgacl.sourceforge.net/
I know that's what Joomla (formly known as Mambo) is going to use in
their 5.0 version.
jay
hi...
i'm in the process of looking for/creating a function to allow me to
perform
user login/registration/etc, as well as handle a user admin function.
i'm looking for the following functionality:
user registration/login:
-allow user to enter basic information
-allow user to enter username/passwd
-ensure unique username
-email confirmation of user registration
-password regeneration (forgot passwd)
-handle forgot username/password
-ip blocking
-email blocking
-security graphic verification (capcha??)
-admin notification
-aadmin enable/authorize
-Session var generation on successful login
-limit login attempts for invalid logins
-ensure only single usage of login at a time
-ensure that multiple logins of a login is
within a geographic/IP range
-IP/User tracking
-captcha processing/implementation
-
Admin functionality:
-IP Tracking
-IP blocking
-User Management
-User Enable/Disable function
-User Auth/Verification function
-User Email Function
-User Password regeneration function
-Site Mamagement
-List Users
-Track User Actions within site
-Allow User to be a member of a given group
-Create Groups
-Assign User Roles/Groups
-
-
-
-
This is kind of a basic/starting point. I'm looking at a few CMS apps,
but
i'm curious to know if you guys have seen any app (open source) that
has
what i'm looking for...
I'm in the process of extracting the functionality from Mambo/phpBB and
adding some of what i need. Does anybody have any idea as to whether an
existing "Open Source" app is out here, that gives a good deal of this
functionality? Searching google turns up alot of scripts, but nothing
that
really has what i'm after and that's free!!
Also, if i have to pretty much create this from scratch, is there
anybody
who'd want to play the role of architect/test/reviewer??
thanks
bruce
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hello all.
I am new to this list but not to new to php although maybe the problem I
am having will prove otherwise
ok, I am writing a server(or trying to), Basically I am attempting to
write a chat type server in php. I cant seem to get it to realize that I
have typed more than one word, so execute the code within the if
statement. basic function is below, well what I am attempting to do
anyway, I have the str_word_count() defined as $word_count and $words for
the array of words that str_word_count($variable, 1) creates
ok, little piece of code is below
function commands($sock, $data)
{
$word_count = str_word_count($data);
$words = str_word_count($data, 1);
/* here is where the problems come in I think */
if(($word_count == 2) && ($data == '.quit'))
{
echo "you quit with a message of $data\n";
}
else
{
echo "quitting without saying anything...\n";
}
}
it seems like the code fragment above does absolutely nothing e.g
$word_count reverts to being empty once the if statement is hit. if I put
something in the function, but outside of the if statement like
echo "word_count was $word_count\n";
that works fine and returns an integer like it should
am I the only one who finds this little thing odd or am I missing
something that it is so simple it already sticks out to others as a big
glaring error?
any ideas?
matt
--- End Message ---
--- Begin Message ---
matt VanDeWalle wrote:
function commands($sock, $data)
{
$word_count = str_word_count($data);
$words = str_word_count($data, 1);
/* here is where the problems come in I think */
if(($word_count == 2) && ($data == '.quit'))
{
echo "you quit with a message of $data\n";
}
else
{
echo "quitting without saying anything...\n";
}
}
function commands( $sock, $data ) {
$words = explode( ' ', $data );
if( count( $words ) == 2 && $words[0] == '.quit' ) {
echo "quit with a message of {$words[1]}\n";
} else {
echo "quit with no message\n";
}
}
--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/
If you find my advice useful, please consider donating to a poor
student! You can choose whatever amount you think my advice was
worth to you. http://tinyurl.com/7oa5s
--- End Message ---
--- Begin Message ---
I should have added in my previous message, what my test input was so :
ok, i login, this is what I typed to test the little piece of code i
previously wrote...
/* my input */
.quit goodbye
/*
just a note, I know that '.quit' by itself is only one word, i guess I
just assumed people would know what I would test this with but maybe not.
anyway, above is my test input
--- End Message ---
--- Begin Message ---
hi...
i'm trying to figure out how to approach/solve a few issues. looking through
google hasn't made the light shine!!
1) i'm trying to figure out how to allow a user to search through a
query/tbl for a given string. ie, if i have the following as the result of a
query:
name email foo...
aa [EMAIL PROTECTED] dddd
b1 [EMAIL PROTECTED] 123
bb [EMAIL PROTECTED] qwe
if i allow a user to search on say 'aa', i'd like the user to be able to
get:
name email foo...
aa [EMAIL PROTECTED] dddd
b1 [EMAIL PROTECTED] 123
any ideas as to how i could go about and create the query, or what would i
need to do to have this result...
2) if i have a query that produces a number of rows, how/what would i need
to do, to limit the number of rows displayed, and to allow the user to
select a 'back/next' button that would generate/display the next 'N' items
in the list/query results...
if anybody could direct me to sample docs/code that kind of describes/solves
what i've described, i'd appreciate it!!!
thanks
-bruce
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
On 9/10/05 3:13 PM, "bruce" <[EMAIL PROTECTED]> wrote:
> if i allow a user to search on say 'aa', i'd like the user to be able to
> get:
>
> name email foo...
> aa [EMAIL PROTECTED] dddd
> b1 [EMAIL PROTECTED] 123
>
> any ideas as to how i could go about and create the query, or what would i
> need to do to have this result...
Use like in your select statement ...
Select name, email, foo from tbl where email like '%aa%';
> 2) if i have a query that produces a number of rows, how/what would i need
> to do, to limit the number of rows displayed, and to allow the user to
> select a 'back/next' button that would generate/display the next 'N' items
> in the list/query results...
>
Use limit in your select statement
Select * from tbl limit 10;
You can also use a start in the limit so the next button would call this
select.
Select * from tbl limit 10, 10;
> if anybody could direct me to sample docs/code that kind of describes/solves
> what i've described, i'd appreciate it!!!
The folks on the MySQL list can help you with these questions better then
the folks here on the PHP list.
>
> thanks
>
> -bruce
> [EMAIL PROTECTED]
--
Stephen Johnson
The Lone Coder
http://www.ouradoptionblog.com
*Join us on our adoption journey*
[EMAIL PROTECTED]
http://www.thelonecoder.com
*Continuing the struggle against bad code*
--
--- End Message ---
--- Begin Message ---
> hi...
>
> i'm trying to figure out how to approach/solve a few issues. looking
> through
> google hasn't made the light shine!!
>
> 1) i'm trying to figure out how to allow a user to search through a
> query/tbl for a given string. ie, if i have the following as the result of
> a
> query:
>
> name email foo...
> aa [EMAIL PROTECTED] dddd
> b1 [EMAIL PROTECTED] 123
> bb [EMAIL PROTECTED] qwe
>
>
> if i allow a user to search on say 'aa', i'd like the user to be able to
> get:
>
> name email foo...
> aa [EMAIL PROTECTED] dddd
> b1 [EMAIL PROTECTED] 123
>
> any ideas as to how i could go about and create the query, or what would i
> need to do to have this result...
Hi,
Basically what you need to do is dynamically create the WHERE clause of your
query string.
In the example above, the WHERE clause might look something like:
$qry = "SELECT * FROM table WHERE name LIKE '%$searchterm%' OR email LIKE
'%$searchterm%'";
If you want to span the search across more fields, simply add them as extra
OR elements to the WHERE clause.
>
> 2) if i have a query that produces a number of rows, how/what would i need
> to do, to limit the number of rows displayed, and to allow the user to
> select a 'back/next' button that would generate/display the next 'N' items
> in the list/query results...
>
> if anybody could direct me to sample docs/code that kind of
> describes/solves
> what i've described, i'd appreciate it!!!
Here I'm making the assumption that you're using MySQL. If that's the case,
you need to familiarize yourself with the LIMIT clause. This allows you to
specify a starting point and number of rows to return for the resultset.
So, using the query above again:
$qry = "SELECT * FROM table WHERE name LIKE '%$searchterm%' OR email LIKE
'%$searchterm%' LIMIT 0,10";
...will return the first 10 results from your query (records 0 to 9). Note
that the 'first' row is at position 0 in the recordset. Also note: if there
are less than 10 records returned by your query (ie in your example, only 2
match your pseudo request), only those records will be returned.
Then, issuing:
$qry = "SELECT * FROM table WHERE name LIKE '%$searchterm%' OR email LIKE
'%$searchterm%' LIMIT 9,10";
...will return the next 10 results from your query (records 10 to 19), and
so on.
This requires you to pass some variables from one search result page to the
next, particularly the variable that indicates where the 'next' results
should begin, allowing you to factor that in when building the LIMIT clause
of the query string for the search results that should be displayed on that
page.
A Google search on "PHP pagination" or "PHP paginate" should return a number
of online resources explaining how to paginate results returned from a db
query in PHP.
Hope this helps.
Much warmth,
Murray
---
"Lost in thought..."
http://www.planetthoughtful.org
--- End Message ---
--- Begin Message ---
Here is a thorough review on the Zandstra book:
http://books.slashdot.org/article.pl?sid=05/08/16/0434205&tid=169&tid=6
Jordan
On Sep 9, 2005, at 6:39 PM, Jason Coffin wrote:
On 9/9/05, Vinayakam Murugan <[EMAIL PROTECTED]> wrote:
I am learning about Object Oriented Programming with PHP. Can you
suggest
any good books / tutorials?
Greetings,
I HIGHLY recommend "PHP 5 Objects, Patterns, and Practice" by Matt
Zandstra [http://www.apress.com/book/bookDisplay.html?bID=358]. This
was one of the best PHP books I have read and I suspect it is exactly
what you are looking for.
Yours,
Jason Coffin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
hello,
I just wanted to say thank you to the person who basically rewrote the
function i seemed to have problems with and it actually now works.
thanks again
matt
--- End Message ---