Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread John Butler

What a lot of good ideas spawned from the OP!
I am learning many things,.. while also actually working (paying  
bills), so I regularly have to just go with what I know well.


Anyway, I already have the forearch { loop (for other reasons it is  
necessary), and I only needed one color to alternate with the default  
white..  so I used this:


 forearch { ...
$tableRowBGcolorBoolCounter = !$tableRowBGcolorBoolCounter; //-boolean  
on and off


(which then sticks in one CSS class or another for that tr.

thanks for everyone's feedback.
-John

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



Re: [PHP] Embedding foreach loops

2009-08-11 Thread John Butler

Allen, you off and running again?


Sure am, thanks, on to the next set of issues. Seems like  
programming is always moving on from one error to the next :)


Currently, I am having trouble with echo and php line-returns.

It works on one part of the code, but not on another (instead,  
prints it to html).


For example:

[code]

$show[show_01][price] * $show_01_qty = $Total_show_01;
 echo \ntr\n\t;
 echo tda.$show[show_01][price]./td/n/ttd*/td/n/ttdb. 
$show_01_qty./td/n/ttd=/td\n\ttdc.$Total_show_01./td;

 echo \n/tr;

[/code]

outputs this html

[code]

tr
   tda/td/n/ttd*/td/n/ttdb/td/n/ttd=/td
   tdc/td
/tr

[/code]
Additionally, it won't display the variables, as you can see, even  
though they will echo out further above in the document. Odd...



well you escape a newline char with this slash:
\
and not this one:
/
notice you were not consistent with your use of them.
as for the array not being parsed inside your echo statement -  I  
don't see the issue by looking now.  Are you saying the EXACT same  
code does output the expected value for those array elements higher up  
the script?  Show us the code where it is working and again where it  
is not..  side by side (pasted just after each other in a new post to  
the list).


I assume you are past this next point, but always remember
var_dump($myArray);
is your friend.  Put it just before where you try to echo out some  
part of the array..  check to be sure the value is there is that  
element of the multi-dimensional array the way you think it is.


-John

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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread John Butler

What a lot of good ideas spawned from the OP!
I am learning many things,.. while also actually working (paying  
bills), so I regularly have to just go with what I know well.


Anyway, I already have the forearch { loop (for other reasons it is  
necessary), and I only needed one color to alternate with the  
default white..  so I used this:


forearch { ...
$tableRowBGcolorBoolCounter = !$tableRowBGcolorBoolCounter; //- 
boolean on and off


(which then sticks in one CSS class or another for that tr.

thanks for everyone's feedback.
-John


Yeah, but forearch ain't going to work.



what do you mean?  I must have neglected to include more of the  
relevant code to show you that it IS working just fine.   I will  
certainly explain more if you ask..  but the whole point of me  
starting the thread was just to be reminded how to inverse a boolean  
var's value.  Tony answered me; I am happy.   I assume you don't want  
me (the newbie) to show how I have it working. (?)



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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread John Butler

He's pointing out a typo... forearch instead of foreach :)


LOL!

I almost always miss the jokes.

Thanks for the smiley face to get my (lighter) attention ;-)

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



Re: [PHP] reason for a Notice:.. on one site but not another? (Same code.)

2009-08-10 Thread John Butler



If you switch it around you'll get a notice because the IF evaluates
from left to right.  So you just want to make sure you check isset()  
first.


This would throw a notice:

if($_POST['UserWishesDateRange']  == 'T' 
isset($_POST['UserWishesDateRange'])) {


Aha!  That must be what I tried and was still getting the notice!   
Interesting that it works (without notice) if we check against the  
isset () one first.   It makes if() look more intelligent that I would  
think... as if it saying, good now that we've established that the  
var isset, now is it also equal to '___'., as opposed to just, is var  
set, and is var equal to ___'.

Re: [PHP] reason for a Notice:.. on one site but not another? (Same code.)

2009-08-10 Thread John Butler



If you switch it around you'll get a notice because the IF evaluates
from left to right.  So you just want to make sure you check isset()
first.

This would throw a notice:

if($_POST['UserWishesDateRange']  == 'T' 
isset($_POST['UserWishesDateRange'])) {


Aha!  That must be what I tried and was still getting the notice!
Interesting that it works (without notice) if we check against the
isset () one first.   It makes if() look more intelligent that I  
would

think... as if it saying, good now that we've established that the
var isset, now is it also equal to '___'., as opposed to just, is  
var

set, and is var equal to ___'.




this is not intelligence its just pure math. the '' says if BOTH
expressions are true then the whole expression is true.

so if the first one is false, the whole is false, why checking the  
next one

in the underlaying C it would be something like this
{
if ( expression == false ) return false;
if ( expression == false) return false;
return true;
}


I would have thought both would have to be true on their own (without  
notice) in order for the the combined expression to be true (without  
notice).  But Shawn pointed out that the order matters; if we check  
for the var's value before checking if it isset then we get a notice,  
but if the order is reversed, then we get no notice.

Re: [PHP] Embedded foreach loops

2009-08-10 Thread John Butler


On Aug 10, 2009, at 3:43 PM, Jim Lucas wrote:


Allen McCabe wrote:
I am creating an order form for tickets for a list of performances  
at a

performing arts center.

Currently, the form is on paper, and is set up as follows:
-Nutcracker - Tues 10/13 - 11am - $4.00



Thanks for letting us know about your new order form.

Did you have a question about something?  Or simply wanted to let us  
know?


Jim


I was thinking free tickets!




Re: [PHP] Embedding foreach loops

2009-08-10 Thread John Butler
I can't seem to get my foreach loops to work, will PHP parse  
embedded loops?


yes.


Is this something I need to have in a database to work?


no, you can do it with the arrays...  but it may be easier to work  
with over the long run if that data was in a db.


Anyway right after you finish creating the array and it's embedded  
arrays, in your code, then add this:
var_dump($shows); //--so you can see what you just created.  If it  
looks right, THEN go on bothering to try and parse it with your  
(embedded) foreach's {



John Butler (Govinda)
govinda.webdnat...@gmail.com




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



[PHP] how to say inverse your value (to a boolean)?

2009-08-10 Thread John Butler

quick Q:
I have this inside a foreach{}  that I want to alternate between on  
and off so I can alternate the background-color of my tr's.


$tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; //-boolean  
on and off


I am looking thru' docs and books, but can't remember (nor find now)  
in PHP how to say inverse your value (to a boolean).

?

TIA! -G


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



Re: [PHP] Embedding foreach loops

2009-08-10 Thread John Butler


I did this, and got my arrays dumped (on one line). After adding  
line returns, here is a snippet:



it looks OK.  Note that you can see (copy/paste) that array which you  
just dumped, much better, if you view the source code of the html  
page.  OR you can use pre to make that format persist thru' to what  
you see without viewing the source., Like so:


echo hr /pre\n;
var_dump($theArray);
echo /pre\n;
echo hr /\n;

My brain is so full of my own work..  and I am newbie compared to most  
lurking here.. but I am sure we'll figure out your issue if we work on  
it systematically.  OK, your OP just said, ..I can't seem to get my  
foreach loops to work..  , but you never said exactly what is the  
problem.  Break the problem down to the smallest thing that you can  
find that is not behaving as you expect it to, and explain  THAT to  
me.  We'll do this step by step.


-John

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



Re: [PHP] Embedding foreach loops

2009-08-10 Thread John Butler
I am using the print function to display my html. I cannot get the  
line return ( \n ) character to actually push the html onto the next  
line, it just gets displayed instead. Should I be using echo?



Allen, you off and running again?

echo blah..  \n; //-- this will print  the literal 'blah..  '  and  
then a newline into your HTML *source code*
echo 'blah..  \n'; //-- this will print the literal 'blah..  \n' into  
your HTML *source code*


IIRC print is the same as echo.  That is not your apparent issue.

Say if you are stuck again, and on what exactly.

-John

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



Re: [PHP] Re: how to say inverse your value (to a boolean)?

2009-08-10 Thread John Butler

 echo something  . (($a = $a^1) ? red\n : green\n);


Re: The ? char in this  line above..
where in the php docs can I read about what that is doing?
I have not come across this construct before today, from you guys.

thanks
-John

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



[PHP] reason for a Notice:.. on one site but not another? (Same code.)

2009-08-09 Thread John Butler

Hi sunday  coders,

I've been using this kind of logic on one PHP site I work on to  
display one thing or another depending on whether the form was  
submitted or not:


if($_POST['UserWishesDateRange']) {  //--line 79
echo'submitted';
} else {
echo'NOT submitted';
}

and it works great on that site.

But on another site it still works, but gives this error:
Notice: Undefined index: UserWishesDateRange in /home/vs/site/phvs/bl/ 
7solarsecrets/admin/trackingcode.html on line 79


I assume that is because the error display settings are set to a more  
rigorous level in this latter site.

Is this correct?

(Both sites reside on servers where I am not the admin.)


John Butler (Govinda)
govinda.webdnat...@gmail.com




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



Re: [PHP] reason for a Notice:.. on one site but not another? (Same code.)

2009-08-09 Thread John Butler

http://us3.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting


Thank you guys for the isset() heads up.  And Ben, for this good  
explanation of error reporting!



As others have pointed out, it's a good idea to call isset() on a
POST-variable before trying to get at its value. This will avoid a
notice being thrown.


OK, and I can work around all this anyway, but I would love to get it  
all in one line of code, that essentially says: (pseudocode)

if  ($IamNotEmpty  $IamEqualto='T') {
(where those are both the same var)



http://us2.php.net/manual/en/function.filter-input.php
The filter_* functions are only available in core since 5.2.0, though.


OK, ..good to plant seeds, but since that server is PHP 4.3, I'll save  
my brain now for until I can actually integrate that study.



John Butler (Govinda)
govinda.webdnat...@gmail.com





Re: [PHP] reason for a Notice:.. on one site but not another? (Same code.)

2009-08-09 Thread John Butler
if(isset($_POST['UserWishesDateRange'])   
$_POST['UserWishesDateRange']

== 'T') {



Thought I tried that.  Apparently not exactly; it works now!  Thanks.   
I know it is clunky but I wanted to see how compact it could be done.


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



Re: [PHP] Re: does array_slice not work on multidimensional arrays?

2009-08-08 Thread John Butler

does array_slice not work on multidimensional arrays?

I have one multidimensional array, and when I run it thru'
array_slice() nothing happens, that I can tell.

If it does not work on multidimensional arrays, what is the  
*simplest*

workaround?  (I am already working past what was budgeted for this
this script..  so I really want to avoid anything but the most newbie
of hacks to achieve this.)

//PHP Version 4.3.9


Works for me in PHP 5:



cat a.php


?php

 echo phpversion(), \n;
 $a1 = array (array (1,2,3,4), array ('a','b','c'), array (true,  
false));

 $a2 = array_slice ($a1, 1, 2);
 var_dump ($a2);


php5 a.php


5.2.5
array(2) {
 [0]=
 array(3) {
   [0]=
   string(1) a
   [1]=
   string(1) b
   [2]=
   string(1) c
 }
 [1]=
 array(2) {
   [0]=
   bool(true)
   [1]=
   bool(false)
 }
}


It seems clear to me, but do you also agree that my evidence is that  
array_slice() does NOT work on multi-dimmed arrays on v.4.3.9?

Here is the evidence:

this:

var_dump($BuildPerUniqueDateArray);
echo\n\n~\n\n;
array_slice($BuildPerUniqueDateArray, 1, 2);
var_dump($BuildPerUniqueDateArray);

returns:
array(12) {
  [2009-08-08]=
  array(2) {
[t7solar_landing]=
string(1) 2
[aweber_7solar_aw]=
string(1) 1
  }
  [2009-08-07]=
  array(3) {
[t7solar_landing]=
string(1) 2
[aweber_7solar_aw]=
string(1) 1
[aweber_7solar_confirm]=
string(1) 1
  }
  [2009-08-06]=
  array(3) {
[aweber_7solar_confirm]=
string(1) 5
[t7solar_landing]=
string(1) 6
[aweber_7solar_aw]=
string(1) 3
  }
  [2009-08-05]=
  array(3) {
[aweber_7solar_confirm]=
string(1) 1
[t7solar_landing]=
string(1) 3
[aweber_7solar_aw]=
string(1) 4
  }
...
~

array(12) {
  [2009-08-08]=
  array(2) {
[t7solar_landing]=
string(1) 2
[aweber_7solar_aw]=
string(1) 1
  }
  [2009-08-07]=
  array(3) {
[t7solar_landing]=
string(1) 2
[aweber_7solar_aw]=
string(1) 1
[aweber_7solar_confirm]=
string(1) 1
  }
  [2009-08-06]=
  array(3) {
[aweber_7solar_confirm]=
string(1) 5
[t7solar_landing]=
string(1) 6
[aweber_7solar_aw]=
string(1) 3
  }
  [2009-08-05]=
  array(3) {
[aweber_7solar_confirm]=
string(1) 1
[t7solar_landing]=
string(1) 3
[aweber_7solar_aw]=
string(1) 4
  }
...


John Butler (Govinda)
govinda.webdnat...@gmail.com




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



Re: [PHP] Re: does array_slice not work on multidimensional arrays?

2009-08-08 Thread John Butler

It seems clear to me, but do you also agree that my evidence is that
array_slice() does NOT work on multi-dimmed arrays on v.4.3.9?
Here is the evidence:

this:

var_dump($BuildPerUniqueDateArray);
echo\n\n~\n\n;
array_slice($BuildPerUniqueDateArray, 1, 2);
var_dump($BuildPerUniqueDateArray);


It seems clear to me that you are dumping /the same/
array twice.



Aha.  I see  now.   I had to *assign* the results of the array_slice  
to a [new] array and then use that ...
(trying to do something and expecting the results to stick even  
without assigning them to a var,  bites me every week or so.  I'll get  
it through my old habits-from-other-languages skull eventually.)


Thank you Nisse,

-Govinda

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



[PHP] does array_slice not work on multidimensional arrays?

2009-08-07 Thread John Butler

does array_slice not work on multidimensional arrays?

I have one multidimensional array, and when I run it thru'
array_slice() nothing happens, that I can tell.


If it does not work on multidimensional arrays, what is the *simplest*  
workaround?  (I am already working past what was budgeted for this  
this script..  so I really want to avoid anything but the most newbie  
of hacks to achieve this.)


//PHP Version 4.3.9

thank you for any reply!


John Butler (Govinda)
govinda.webdnat...@gmail.com




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



[PHP] does array_slice not work on multidimensional arrays?

2009-08-07 Thread John Butler
I worked around the issue by running the too fat multi-dimed array  
through a foreach{ ...  if($counter = $myArrLength)  
{ $MyNowSlicedMultiDimArr[$key]=$value; }} ,
 but I'd still (always!) love to hear from you seasoned PHPers on  
this topic (anytime actually!).

I learn the most from your commentary.


John Butler (Govinda)
govinda.webdnat...@gmail.com




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