php-general Digest 25 Feb 2011 23:58:41 -0000 Issue 7200

2011-02-25 Thread php-general-digest-help

php-general Digest 25 Feb 2011 23:58:41 - Issue 7200

Topics (messages 311577 through 311581):

Re: Why is this array_walk_recursive action not working? [SOLVED]
311577 by: Dave M G

Re: Dynamically Created Checkboxes
311578 by: tedd

Re: How to write code: how wrong am I?
311579 by: tedd
311580 by: tedd

Re: mysql_num_rows()
311581 by: tedd

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
Feln, Richard, Jim,

Thank you for responding.

I understand now that the problem wasn't with variable scope, but with
my lack of understanding of what array_walk_recursive returns.

Thank you all for your explanations.

-- 
Dave M G
---End Message---
---BeginMessage---

At 5:06 PM -0500 2/22/11, Gary wrote:

-snip-

Would appriciate your help.

Thank you.
--
Gary


Gary:

This might help:

http://php1.net/b/form-checkbox1/

Cheers,

tedd

--
---
http://sperling.com/
---End Message---
---BeginMessage---

At 9:13 AM -0500 2/22/11, Robert Cummings wrote:

On 11-02-22 08:58 AM, Dotan Cohen wrote:

On Tue, Feb 22, 2011 at 14:11, Jay Blanchardjblanch...@pocket.com  wrote:

It is an interesting concept Dotan, what is the goal? Who is the page
targeted to?


The goal is to have every open and close bracket matched, and not have
to worry about what is still open.


This is why I use the bracing style I use in PHP. A cursory glance 
of the code will show you where you've forgotten a brace. Syntax 
highlighting is also nice.


HTML can trip you up with missing or superfluous tags, but a quick 
run through the W3C validator will catch those errors.


Cheers,
Rob.


Rob is exactly right on both counts.

Place braces on their own lines and use the W3C Validator to check 
both html and css.


Cheers,

tedd

--
---
http://sperling.com/
---End Message---
---BeginMessage---

At 11:04 AM -0700 2/22/11, Alexis wrote:

On 22/02/11 09:40, Dotan Cohen wrote:

On Tue, Feb 22, 2011 at 16:15, Robert Cummingsrob...@interjinn.com  wrote:

If you switch to vertically aligned braces you will have an easier time
matching up open and close braces...

if (something)
{
// Code here
}

It's trivial to match using this style since you only need to scan one axis.



That bracing style drives me nuts! But I have no problem scanning a
single axis for the close brace and any statement, be it an if, while,
switch, or something else.



Well the way you do it, drives me nuts  :)

Morale of the story, do whatever *you* are most comfortable 
with..personally I indent as well, has it's downsides I admit, but 
it's what I've done for the last 20 years and I'm comfortable with 
it.


Alexis



I agree with Alexis.

Furthermore, I place braces on their own lines AND I do it in all 
languages I program in, such as CSS, PHP, JavaScript, and others.


Cheers,

tedd

--
---
http://sperling.com/
---End Message---
---BeginMessage---

At 12:40 AM -0500 2/22/11, Gary wrote:

Can someone tell me why this is not working?  I do not get an error message,
the results are called and echo'd to screen, the count does not work, I get
a 0 for a result...


$result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked') or
die(mysql_error());

if ( isset($_POST['submit']) ) {
for($i=1; $i=$_POST['counties']; $i++) {
if ( isset($_POST[county$i] ) ) {
echo You have chosen . $_POST[county$i]. br/;
}
}
}

$county_total=mysql_num_rows($result);

while($row = mysql_fetch_array($result))
{$i++;
echo $row['name'];
}
$county_total=mysql_num_rows($result);
echo $county_total;

echo 'You Have '  .  $county_total  .  ' Counties ';

?


Gary:

With regard of the count thing, why not let MySQL do the work?

$query = SELECT COUNT(*) AS total FROM 'counties' WHERE name = 'checked' ;
$result = mysql_query($query) or die(mysql_error());
$total = $rowcount['total'];

Cheers,

tedd


--
---
http://sperling.com/
---End Message---


Re: [PHP] Re: Simplest way of enforcing an array of instances of a specific class but treating the whole thing as an array.

2011-02-25 Thread Richard Quadling
On 24 February 2011 18:28, David Harkness davi...@highgearmedia.com wrote:
 If each array will contain a single type of object, but you need many of
 these arrays, each containing a different type of object, I recommend
 creating a generic instances-of-class array using ArrayObject. You can
 enforce the type in append(), offsetSet(), and exchangeArray() and then
 check the configured type in methods that want to enforce it.
     function drawMap(TypedArray $latLngs=null) {
         if ($latLngs  !$latLngs.containsOnly('LatLng')) {
             throw new InvalidArgumentException('$latLngs must contain only
 LatLngs');
         }
         ...
     }
 I guess since there are only three methods to override it wouldn't be too
 painful to create a separate class for each type to get method declaration
 type hinting. If you aren't containing too many classes and you pass them
 around a lot, it may be worth it since you won't have to test the container
 inside the method at all.
     function drawMap(LatLngArray $latLngs=null) ...
 Looks like someone beat us to it:
     http://liamgraham.wordpress.com/2007/05/21/typesafe-arrays-for-php/
 David


That's it and in the direction I was heading.

Thanks David - and liamgraham


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] Why is this array_walk_recursive action not working? [SOLVED]

2011-02-25 Thread Dave M G
Feln, Richard, Jim,

Thank you for responding.

I understand now that the problem wasn't with variable scope, but with
my lack of understanding of what array_walk_recursive returns.

Thank you all for your explanations.

-- 
Dave M G

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



Re: [PHP] Dynamically Created Checkboxes

2011-02-25 Thread tedd

At 5:06 PM -0500 2/22/11, Gary wrote:

-snip-

Would appriciate your help.

Thank you.
--
Gary


Gary:

This might help:

http://php1.net/b/form-checkbox1/

Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] How to write code: how wrong am I?

2011-02-25 Thread tedd

At 9:13 AM -0500 2/22/11, Robert Cummings wrote:

On 11-02-22 08:58 AM, Dotan Cohen wrote:

On Tue, Feb 22, 2011 at 14:11, Jay Blanchardjblanch...@pocket.com  wrote:

It is an interesting concept Dotan, what is the goal? Who is the page
targeted to?


The goal is to have every open and close bracket matched, and not have
to worry about what is still open.


This is why I use the bracing style I use in PHP. A cursory glance 
of the code will show you where you've forgotten a brace. Syntax 
highlighting is also nice.


HTML can trip you up with missing or superfluous tags, but a quick 
run through the W3C validator will catch those errors.


Cheers,
Rob.


Rob is exactly right on both counts.

Place braces on their own lines and use the W3C Validator to check 
both html and css.


Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] How to write code: how wrong am I?

2011-02-25 Thread tedd

At 11:04 AM -0700 2/22/11, Alexis wrote:

On 22/02/11 09:40, Dotan Cohen wrote:

On Tue, Feb 22, 2011 at 16:15, Robert Cummingsrob...@interjinn.com  wrote:

If you switch to vertically aligned braces you will have an easier time
matching up open and close braces...

if (something)
{
// Code here
}

It's trivial to match using this style since you only need to scan one axis.



That bracing style drives me nuts! But I have no problem scanning a
single axis for the close brace and any statement, be it an if, while,
switch, or something else.



Well the way you do it, drives me nuts  :)

Morale of the story, do whatever *you* are most comfortable 
with..personally I indent as well, has it's downsides I admit, but 
it's what I've done for the last 20 years and I'm comfortable with 
it.


Alexis



I agree with Alexis.

Furthermore, I place braces on their own lines AND I do it in all 
languages I program in, such as CSS, PHP, JavaScript, and others.


Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] mysql_num_rows()

2011-02-25 Thread tedd

At 12:40 AM -0500 2/22/11, Gary wrote:

Can someone tell me why this is not working?  I do not get an error message,
the results are called and echo'd to screen, the count does not work, I get
a 0 for a result...


$result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked') or
die(mysql_error());

if ( isset($_POST['submit']) ) {
for($i=1; $i=$_POST['counties']; $i++) {
if ( isset($_POST[county$i] ) ) {
echo You have chosen . $_POST[county$i]. br/;
}
}
}

$county_total=mysql_num_rows($result);

while($row = mysql_fetch_array($result))
{$i++;
echo $row['name'];
}
$county_total=mysql_num_rows($result);
echo $county_total;

echo 'You Have '  .  $county_total  .  ' Counties ';

?


Gary:

With regard of the count thing, why not let MySQL do the work?

$query = SELECT COUNT(*) AS total FROM 'counties' WHERE name = 'checked' ;
$result = mysql_query($query) or die(mysql_error());
$total = $rowcount['total'];

Cheers,

tedd


--
---
http://sperling.com/

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