[PHP] Re: Count and Preg_Replace Using Version 4.4.1

2005-12-05 Thread Al

Shaun wrote:

Hi,

The following code matches all occurences of  tags within an html page 
and wraps form tags around it:


echo preg_replace(
'/]*>(.*?)<\/p>/ms',
'action="'.$CFG->edit_pages_adm.'/index.php?action=edit_paragraph" 
method="post">

  
  $1
 ',
file_get_contents($CFG->frontenddir_editable.'/'.$file) );

Unfortunately if there is more than one match the form won't submit because 
the forms have the same name. Does anyone know how can I modify this so that 
each occurence is numbered sequentially i.e.


form'.$count.'...

As I am using version 4.4.1 I don't have access to the count paramter in 
version 5.1.


Thanks for your advice 



Each of your html input elements must have a different name, otherwise the php 
code will only see the last one.

Consider a simple foreach loop to generate your html input elements, e.g.,

$report= ""; $i= 0;

foreach($array as $key=> $value){

$report .= "";

other stuff as needed

$i++;
}//end

echo $report;

I'm not sure I see why you need the JAVA script. Seems like you can let the user poke in everything and then provide a 
submit button to post everything.


Your $_POST will contain all the results.  e.g.,
$value1= $_POST['input1'];
$value2= $_POST['input2'];

etc.

Another simple foreach loop can be used to extract the input values.

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



[PHP] Re: Count online users question

2003-11-27 Thread Kim Steinhaug
Cookies, or browsersession. I found the latter to be very
easy to work with.

-- 
Kim Steinhaug
---
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---


"Al" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > I am trying to figure an accurate way to calculate how many users are
> > viewing a site, at any particular time. This task is very simple except
> for
> > one part - How do you determine when a person has left the site...apache
> > hasn't served anymore requests from a particular ip for xx minutes ??
>
> Hi Mike,
>
> There is no surefire way to measure the exact time a user leaves your
site.
> The most accurate way I can think of would be to use a hidden frame on all
> your pages that refreshes itself every X seconds. When a user has not
> requested that special tracking page for more than X seconds, you can
assume
> they have 'left' the site.
>
> However this solution seems like overkill for most purposes: you'll be
> wasitng server resources and slowing down your users' experience on your
> site.
>
> In response to your proposed method, most advertising associations
> (including the US-based Internet Advertising Bureau) and web analytics
> companies (such as Red Sherrif, Nielsens and Hitwise) define the end of a
> user session on a website when there is 30 minutes without a further
request
> for a page from the site.
>
> And while you may be tempted to track only IP numbers, remember that many
> users are behind shared IP numbers (e.g. firewalls) which may skew your
> stats. You would be better off using cookies on user's machines to
identify
> them and log their accesses to a DB.
>
> Hope that helps,
>
> Al

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



[PHP] Re: Count online users question

2003-11-26 Thread Al
> I am trying to figure an accurate way to calculate how many users are
> viewing a site, at any particular time. This task is very simple except
for
> one part - How do you determine when a person has left the site...apache
> hasn't served anymore requests from a particular ip for xx minutes ??

Hi Mike,

There is no surefire way to measure the exact time a user leaves your site.
The most accurate way I can think of would be to use a hidden frame on all
your pages that refreshes itself every X seconds. When a user has not
requested that special tracking page for more than X seconds, you can assume
they have 'left' the site.

However this solution seems like overkill for most purposes: you'll be
wasitng server resources and slowing down your users' experience on your
site.

In response to your proposed method, most advertising associations
(including the US-based Internet Advertising Bureau) and web analytics
companies (such as Red Sherrif, Nielsens and Hitwise) define the end of a
user session on a website when there is 30 minutes without a further request
for a page from the site.

And while you may be tempted to track only IP numbers, remember that many
users are behind shared IP numbers (e.g. firewalls) which may skew your
stats. You would be better off using cookies on user's machines to identify
them and log their accesses to a DB.

Hope that helps,

Al

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



[PHP] Re: COUNT(*)

2003-08-01 Thread Craig Roberts
use mysql_fetch_rows();

$result="SELECT COUNT(*) FROM pet";
$sql=mysql_query($result);
$number_of_rows = mysql_fetch_rows($sql);
while ($row=mysql_fetch_array($sql)){
$pet_name=$row['pet_name'];
echo ..;
}

Craig Roberts


"Yury B ." <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi
>
> I used to use old fashioned mysql quieries but moderm mysql
> apparently became more flexible so. I want to understand how to use
> some of the new features like COUNT(*)
>
> Let's say I have
> $result="SELECT COUNT(*) FROM pet";
> $sql=mysql_query($result);
> while ($row=mysql_fetch_array($sql)){
> $pet_name=$row['pet_name'];
> echo ..;
> }
>
> the question is how do I actually retrieve the number of rows of sql
> query result?
>
> Yury



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



[PHP] Re: Count lines from php files

2002-12-12 Thread Jean-Christian Imbeault
Antti wrote:

How can I count how many code lines I have written? I have many php 
files in one directory. I'm using linux.Do you know any non-php way to 
count the lines.

from a directory one level above where all your files lie do this:

(assuming all you files are in a directory called php)

#ls -R php | wc -l

this will give you the total number of files and directories

If you want to find out how many lines in a file do

# cat myfile.php | wc -l

If you want to count the lines of all files in a directory ending with 
.php do

# cat *.php | wc -l

Jc


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



[PHP] Re: Count in PHP

2002-09-09 Thread Jome

> I am wanting to do a count in PHP. I want to be able to count the number
of
> records from a given database and display this count on the page. Can this
> be done using PHP or is the sql thing?

If you're using MySQL - I don't know if COUNT() is a part of SQL'92 - you
can use SELECT COUNT(*) FROM table like this:



The two zeros at the end means that mysql_result is to fetch the first row,
the first column of the result.

(Also, it'll be much faster than mysql_num_rows(mysql_query("SELECT * FROM
table"))

   Jome



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




[PHP] Re: count errors

2002-08-30 Thread Richard Lynch

>I have a function that resets the count of fields with certain values when
>called. 99.9 percent of the time it works fine. However occaisionally it
>wont update the database. Even after breaking the selects up it still fails
>sometimes. If anyone has an idea of why I would really appreciate hearing
>it. The code is below.

Are there other people/pages/process that are altering the 'active' state of
categories?

Because it's entirely possible that while the script below is only HALF
finished, somebody else comes in and alters the data out from under you.

Which means that your results will "seem" to be incorrect, since the state
of the world changed mid-stream.

You may want to use:

mysql_db_query($db, $query) or error_log(mysql_error());

instead of all those lines you have to comment/uncomment all the time.

When things go wrong, it will be in your Apache error_log

You may also be getting confusing results if some records has Category1 =
'foo' and Category2 = 'foo'  It's going to get "double-counted" in the
current algorithm.

If it's none of the above, you'll *have* to do some digging to figure out
what causes the 0.1% of the time...

>Thanks,
>Julian
>
>//the selects had to be broken up to get it to work consistently
>function resetCounter()
>{
>include("../config.php");
>
>$query = "select categories from categories";
>$result = mysql_db_query($db, $query);
>while($r = mysql_fetch_array($result))
>{
>
>$cats = $r["categories"];
>   // $active = $r["active"];
>   // echo"$cats";
>
>$query1 = "select count(*) from recipes where category1 = '$cats' and
>active = 'yes'";
>   //  echo mysql_errno().": ".mysql_error()."  1"; // uncomment to
>troubleshoot db problems
>$result2 = mysql_db_query($db, $query1);
>$rows1 = mysql_fetch_row($result2);
>$query2 = "select count(*) from recipes where category2 = '$cats' and
>active = 'yes'";
>   // echo mysql_errno().": ".mysql_error()."  1"; // uncomment to
>troubleshoot db problems
>$result3 = mysql_db_query($db, $query2);
>//echo mysql_errno().": ".mysql_error()."  2"; // uncomment to
>troubleshoot db problems
>$rows2 = mysql_fetch_row($result3);
>$query3 = "select count(*) from recipes where category3 = '$cats' and
>active = 'yes'";
>   // echo mysql_errno().": ".mysql_error()."  1"; // uncomment to
>troubleshoot db problems
>$result4 = mysql_db_query($db, $query3);
>   // echo mysql_errno().": ".mysql_error()."  2"; // uncomment to
>troubleshoot db problems
>$rows3 = mysql_fetch_row($result4);
>
>  // echo mysql_errno().": ".mysql_error()."  3"; // uncomment to
>troubleshoot db problems
>   $therows = $rows1[0] + $rows2[0] + $rows3[0];
>   $query4 = "UPDATE categories SET count = '$therows' where(categories =
>'$cats')";
>   $result5 = mysql_db_query($db, $query4);
>  // echo"$therows <--tr $rows1[0] <--r1 $rows2[0] <--r2 $rows3[0] <--r3
>$cats <-- cats";
>
>}
>}
>
>?>
>
>
>
>
>


-- 
Like Music?  http://l-i-e.com/artists.htm


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




[PHP] Re: count number of downloads

2002-07-11 Thread Richard Lynch

>I have a php-script with which one can download a file with a specific format 
>like this:
>
> header("Content-type: application/specific");
> header("Content-Disposition: attachment; filename=$name.sqrfld");
> echo ("output funny stuff...");
>
>and i will count the number of downloads in a database. When i write the code 
>for counting after the "echo ..." statement it will be executed regardless if 
>the user aborted the download or not. How can i guarantee that i update the 
>database when the download is complete?

Don't think you *CAN* be 100% certain the download succeeded...

You can dink around with ignore_user_abort (or not) and friends to *maybe*
improve accuracy, but you'll never get 100%...



-- 
Like Music?  http://l-i-e.com/artists.htm
Off-Topic:  What is the moral equivalent of 'cat' in Windows?

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




Re: [PHP] Re: Count()

2001-08-29 Thread ERISEN, Mehmet Kamil

$sql = "SELECT COUNT(*) AS myCount FROM Products";
$result = mysql_query($sql);
$count = mysql_result($result,0);

--- Kevin P <[EMAIL PROTECTED]> wrote:
> I have counted some rows in MySQL and I need to know how
> to pull out the
> number of rows.
> "SELECT COUNT(*) AS myCount FROM Products"
> 
> 
> 
> -- 
> PHP General 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]
> 


=
Mehmet Erisen
http://www.erisen.com

__
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

-- 
PHP General 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] Re: Count()

2001-08-29 Thread Kevin P

I have counted some rows in MySQL and I need to know how to pull out the
number of rows.
"SELECT COUNT(*) AS myCount FROM Products"



-- 
PHP General 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] Re: count()?

2001-08-06 Thread Henrik Hansen

[EMAIL PROTECTED] (Jeremy Morano) wrote:

 > Hi, I was woundering how to read and find the # of records in my table...
 > Do I use count()???

yes

select count(*) from table

-- 
Henrik Hansen

-- 
PHP General 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] RE: Count columns in array

2001-02-16 Thread Tim Ward

it's important to remember that what you have here is NOT a 2d array. $array
is an array, each element of which can be any sort of variable ...
e.g.
$array[1] = "fred";
$array[2] = Array();
$array[3] = 1.245;

... but then try ...

foreach ($array as $thisarray)
echo(count($thisarray) . "");

... in this case count($array[2]) = 0 but count($array[1]) = 1 ... so be
careful.

Tim Ward
Senior Systems Engineer

Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html


> -Original Message-
> From: Fabian Fabela [mailto:[EMAIL PROTECTED]]
> Sent: 15 February 2001 18:33
> To: [EMAIL PROTECTED]
> Subject: Count columns in array
> 
> 
> Hello,
> 
> I have the array  $array[x][y];
> 
> if I want to know the x I use count($array);
> 
> Now, How can I count the y??
> 
> Thank you.
> 
> Fabian Fabela
> [EMAIL PROTECTED]
> www.vacagorda.com
> 
> 

-- 
PHP General 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]