Re: [PHP-DB] how to find

2004-11-11 Thread -{ Rene Brehmer }-
1. learn the basics of arrays
2. RTFM
At 12:27 11-11-2004, peppe wrote:
Hi ,
I have numbers in my array
0 0 0 1 1 1 1 1 1 1 1 0 0 0 0
or
 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0
or
 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
how can I find the first 1 and the last is there a function for it
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] how to find

2004-11-11 Thread peppe
I really don't understand why people like you respond on questions do you
want to make yourself interesting . I'm new to php and I'm trying to learn
something that's why I mail in newsgroup but please please do not insult and
do not respond any more if you think people are asking stupid questions

-{ Rene Brehmer }- [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 1. learn the basics of arrays
 2. RTFM

 At 12:27 11-11-2004, peppe wrote:
 Hi ,
 I have numbers in my array
 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0
 or
   0 0 0 0 0 0 1 1 1 1 0 0 0 0 0
 or
   1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
 how can I find the first 1 and the last is there a function for it

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



RE: [PHP-DB] how to find

2004-11-11 Thread Norland, Martin
I think (hope) that Rene was just trying to emphasize that while this is
a php mailing list - it is focused on databases.  An array full of 0's
and 1's - while certainly data - hardly constitutes that.

I suggest a 'for' loop using 'count()' of the array, or perhaps
'array_walk()'.  Store the keys in some temp variables/etc.

That said. http://www.php.net/docs.php - they have a handy search there.
In addition, you can download the documentation - and if you're using
windows, I recommend getting the chm version available here
http://www.php.net/download-docs.php

Keep on plugging, you'll pick it up!

- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


-Original Message-
From: peppe [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 11, 2004 6:17 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] how to find 


I really don't understand why people like you respond on questions do
you want to make yourself interesting . I'm new to php and I'm trying to
learn something that's why I mail in newsgroup but please please do not
insult and do not respond any more if you think people are asking stupid
questions

-{ Rene Brehmer }- [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 1. learn the basics of arrays
 2. RTFM

 At 12:27 11-11-2004, peppe wrote:
 Hi ,
 I have numbers in my array
 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0
 or
   0 0 0 0 0 0 1 1 1 1 0 0 0 0 0
 or
   1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
 how can I find the first 1 and the last is there a function for it

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

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



RE: [PHP-DB] how to find

2004-11-11 Thread dpgirago
Martin, 

Thanks for your kind words to the new guy. I really don't understand why 
others don't simply refrain from responding rather than burn bandwidth 
with their rants of RTFM or or Off Topic - go somewhere else. I really 
appreciate all the posts folks make as I tend to learn something, even if 
the content is unexpected. 

 I think (hope) that Rene was just trying to emphasize that while this is
 a php mailing list - it is focused on databases.  An array full of 0's
 and 1's - while certainly data - hardly constitutes that.
 
snip

David Giragosian, Psy.D.
Database Developer and Programmer
MD Anderson Cancer Center
Houston, Texas
713-792-7898

Re: [PHP-DB] How to find the last ID?

2003-06-06 Thread . ma
hi

you can easily do this by using

mysql_insert_id();

see
http://www.php.net/manual/en/function.mysql-insert-id.php
.ma

e: [EMAIL PROTECTED]
w: http://www.abendstille.at
/***/
life would be easier if i knew the source code.
Am Freitag, 06.06.03 um 23:16 Uhr schrieb Chris Payne:

Hi there everyone,

I'm creating a new entry using the following:

mysql_query (INSERT INTO agents (agent_name)
   VALUES ('$agentname')
but I need to find out the ID value it created, how can I do this 
easily?

Thanks

Chris




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


Re: [PHP-DB] How to find the last ID?

2003-06-06 Thread Chris Payne
Hi there,

Thanks for your quick reply, very appreciated :-)

Chris

 hi
 
 you can easily do this by using
 
 mysql_insert_id();
 
 see
 http://www.php.net/manual/en/function.mysql-insert-id.php
 
 .ma
 
 e: [EMAIL PROTECTED]
 w: http://www.abendstille.at
 /***/
 life would be easier if i knew the source code.
 
 Am Freitag, 06.06.03 um 23:16 Uhr schrieb Chris Payne:
 
  Hi there everyone,
 
  I'm creating a new entry using the following:
 
  mysql_query (INSERT INTO agents (agent_name)
 VALUES ('$agentname')
 
  but I need to find out the ID value it created, how can I do this 
  easily?
 
  Thanks
 
  Chris
 
 


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



Re: [PHP-DB] How to find the last ID?

2003-06-06 Thread Jeff Shapiro

$last_id = mysql_insert_id();

Check out this page for details.
http://www.php.net/manual/en/function.mysql-insert-id.php

On Fri, 6 Jun 2003 17:16:01 -0400, Chris Payne wrote:
 Hi there everyone,
 
 I'm creating a new entry using the following:
 
 mysql_query (INSERT INTO agents (agent_name) 
VALUES ('$agentname')
 
 but I need to find out the ID value it created, how can I do this easily?
 
 Thanks
 
 Chris

---
Listserv only address.
Jeff Shapiro

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



Re: [PHP-DB] How to find the autoincremented number?

2003-02-21 Thread Leif K-Brooks
http://www.php.net/manual/en/function.mysql-insert-id.php

David Chamberlin wrote:

Hey,

Most of the tables I use identify things using an id which is 
auto-generated using autoincrement.  However I can't seem to figure 
out a good way to find what value was generated for the ID.

For example, let's say I generate a new entry and want to e-mail out a 
link to it and the link identifies the entry by ID.  Currently, the 
only way I can figure to do this is to first do the INSERT and then do 
a SELECT on some unique information that I just inserted (e.g., 
submitter's ID and last-modified date).  So for example, I would have:

function addNewEntry( $stuffToPutIn ){
  $sql = INSERT INTO myTable $stuffToPutIn;
  // I use pearDB with mysql
  $result = $this-db-query( $sql );
  checkDbResult( $result );
  $sql = SELECT id FROM myTable WHERE .
  (last_modified_by = $userId) AND .
  (last_modified_time = $currentTime);
  $result = $this-db-getAll( $sql );
  checkDbResult( $result );
  $entry = $result[0];

  $linkAddress = $baseEntryURL.'?entryId='.$entry-id;

  mailOutLink( $linkAddress );
}
What I'd really like to do is get rid of that SELECT or at least make 
it less hacky to find out what the id was that got autogenerated.

Any ideas?

Thanks,
Dave

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.


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


Re: [PHP-DB] How to find the autoincremented number?

2003-02-21 Thread David Chamberlin
Aha.  I had seen that before, but disregarded it because I was trying to 
just use pearDB calls instead of the mysql calls.  However what I 
noticed this time when looking through there is that there's a 
LAST_INSERT_ID() that I could use in a query.

e.g.,

function addNewEntry( $stuffToPutIn ){
  $sql = INSERT INTO myTable $stuffToPutIn;
  // I use pearDB with mysql
  $result = $this-db-query( $sql );
  checkDbResult( $result );
  $sql = SELECT LAST_INSERT_ID();
  $id = $this-db-getOne( $sql );
  checkDbResult( $id );
  $linkAddress = $baseEntryURL.'?entryId='.$id;

  mailOutLink( $linkAddress );
}
Thank you!

-Dave

Leif K-Brooks wrote:
http://www.php.net/manual/en/function.mysql-insert-id.php

David Chamberlin wrote:

Hey,

Most of the tables I use identify things using an id which is 
auto-generated using autoincrement.  However I can't seem to figure 
out a good way to find what value was generated for the ID.

For example, let's say I generate a new entry and want to e-mail out a 
link to it and the link identifies the entry by ID.  Currently, the 
only way I can figure to do this is to first do the INSERT and then do 
a SELECT on some unique information that I just inserted (e.g., 
submitter's ID and last-modified date).  So for example, I would have:

function addNewEntry( $stuffToPutIn ){
  $sql = INSERT INTO myTable $stuffToPutIn;
  // I use pearDB with mysql
  $result = $this-db-query( $sql );
  checkDbResult( $result );
  $sql = SELECT id FROM myTable WHERE .
  (last_modified_by = $userId) AND .
  (last_modified_time = $currentTime);
  $result = $this-db-getAll( $sql );
  checkDbResult( $result );
  $entry = $result[0];

  $linkAddress = $baseEntryURL.'?entryId='.$entry-id;

  mailOutLink( $linkAddress );
}
What I'd really like to do is get rid of that SELECT or at least make 
it less hacky to find out what the id was that got autogenerated.

Any ideas?

Thanks,
Dave




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


RE: [PHP-DB] How to find out the number of rows in a table?

2002-01-24 Thread Rick Emery

SELECT count(*) AS ctr FROM mytable;

-Original Message-
From: Andy [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 24, 2002 10:36 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] How to find out the number of rows in a table?


Hi there,

I am trying to find out the number of rows in a table. The mysql docu says
there is a mysql_num_rows statement but it requiers a sql statement in
front. How could I do this more efficiently? Can anybody make an example,
please? I am sure that there is an more easy way.

Cheers Andy



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] How to find out the number of rows in a table?

2002-01-24 Thread Sam Masiello


Try the following:

$sql = select count(*) as c from your_table ;
$result = mysql_query(your_db, $sql, your_connection_identifier) ;
$row_count = mysql_result($result, 0, 'c') ;

Now $row_count contains the number of rows in your table named your_table

HTH

--Sam Masiello


Andy [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi there,

 I am trying to find out the number of rows in a table. The mysql docu says
 there is a mysql_num_rows statement but it requiers a sql statement in
 front. How could I do this more efficiently? Can anybody make an example,
 please? I am sure that there is an more easy way.

 Cheers Andy



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]