[PHP] Re: WOT [PHP] REQUEST

2013-05-29 Thread Jay Blanchard

[snip]We're not your dudes/guyz/bros or anything like that.  [/snip]

Don't taze me bro'!

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



[PHP] Problems with array_push?

2013-05-07 Thread Jay Blanchard
I know that I must be missing something really ridiculous, but when I 
print_r these arrays they are empty. I have confirmed that $arrayElement 
is properly formed, it just seems that array_push is not working. I know 
I have done this before, but I cannot find my older code. Can someone 
clear the mud from my eyes?


$issueDifferently = array();
$issueProblem = array();
$issueComment = array();

function addToArray($id, $namecred, $product, $level, $type, $message) {
$arrayElement = $id 
.'|'.$namecred.'|'.$product.'|'.$level.'|'.$type.'|'.$message;


if('DoDifferently' == $type) {
array_push($issueDifferently, $arrayElement);
} elseif ('Problem' == $type){
array_push($issueProblem, $arrayElement);
} elseif ('Comments' == $type) {
array_push($issueComment, $arrayElement);
}
}
print_r($issueDifferently);
print_r($issueProblem);
print_r($issueComment);


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



Re: [PHP] Problems with array_push?

2013-05-07 Thread Jay Blanchard

[snip]Globals being used in a function. [/snip]

*smacks forehead*

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



Re: [PHP] mysqli nested queries - maybe I'm rusty...

2013-04-02 Thread Jay Blanchard

Anyone? I have not been able to find a solution online.

On 4/1/2013 11:33 AM, Jay Blanchard wrote:
I am putting together an application where we are almost exclusively 
using stored procedures in MySQL because most of the heavy lifting (as 
it should be) is done in the database.


I have exactly one situation where I need to execute a stored 
procedure and while returning the results if I run a across a 
particular value in those results I need to execute another SP to 
handle. Because I have forgotten which combination or store_result, 
use_result, fetch_row (not to mention that fetch row doesn't have the 
column names in the array, just the index) to use I am banging my head 
against the wall while getting the dastardly 2014 Commands out of 
sync; error. Can someone provide some insight please?


Assume that $mysqli is the connection -

$sql = CALL sp_ONE( . $product . , . $level . );
if(!$result = $mysqli-multi_query($sql)) {
echo Error: ( . $mysqli-errno . )  . $mysqli-error .  on 
Query  . $sql;

} else {
do {
if($side = $mysqli-store_result()) {

/* output the list */
echo 'ul';
while($row = $side-fetch_row()) {
/* careful, column names aren't carried over */
echo 'li data-page=' . $row[2] . '' . $row[1] . 
'/li';

/* do we need to do a another stored procedure? */
if(isset($row[3])) {
/* get the info */
$sql = CALL sp_TWO( . $product . , . $row[0] . 
);

if(!$subResult = $mysqli-multi_query($sql)) {
echo Error: ( . $mysqli-errno . )  . 
$mysqli-error .  on Query  . $sql;

}
/* output the extra info */
echo 'ul';
while($sub = mysqli_fetch_array($subResult)) {
echo 'li data-page=' . $sub[1] . '' . 
$sub[0] . '/li';

}
echo '/ul';
}
}
echo '/ul';
$side-close();
}
} while($mysqli-next_result());
}







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



Re: [PHP] {SOLVED] mysqli nested queries - maybe I'm rusty...

2013-04-02 Thread Jay Blanchard

[snip]
...stuff...
[/snip]

I rewrote everything so that I could get the data in a single query and 
then performed some manipulation with PHP to get the proper output. No 
need to call multiple queries in this case, just had to sleep on it.


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



[PHP] mysqli nested queries - maybe I'm rusty...

2013-04-01 Thread Jay Blanchard
I am putting together an application where we are almost exclusively 
using stored procedures in MySQL because most of the heavy lifting (as 
it should be) is done in the database.


I have exactly one situation where I need to execute a stored procedure 
and while returning the results if I run a across a particular value in 
those results I need to execute another SP to handle. Because I have 
forgotten which combination or store_result, use_result, fetch_row (not 
to mention that fetch row doesn't have the column names in the array, 
just the index) to use I am banging my head against the wall while 
getting the dastardly 2014 Commands out of sync; error. Can someone 
provide some insight please?


Assume that $mysqli is the connection -

$sql = CALL sp_ONE( . $product . , . $level . );
if(!$result = $mysqli-multi_query($sql)) {
echo Error: ( . $mysqli-errno . )  . $mysqli-error .  on 
Query  . $sql;

} else {
do {
if($side = $mysqli-store_result()) {

/* output the list */
echo 'ul';
while($row = $side-fetch_row()) {
/* careful, column names aren't carried over */
echo 'li data-page=' . $row[2] . '' . $row[1] . 
'/li';

/* do we need to do a another stored procedure? */
if(isset($row[3])) {
/* get the info */
$sql = CALL sp_TWO( . $product . , . $row[0] . );
if(!$subResult = $mysqli-multi_query($sql)) {
echo Error: ( . $mysqli-errno . )  . 
$mysqli-error .  on Query  . $sql;

}
/* output the extra info */
echo 'ul';
while($sub = mysqli_fetch_array($subResult)) {
echo 'li data-page=' . $sub[1] . '' . 
$sub[0] . '/li';

}
echo '/ul';
}
}
echo '/ul';
$side-close();
}
} while($mysqli-next_result());
}




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



[PHP] Undefined index....

2013-03-15 Thread Jay Blanchard
I have inherited a mess of a home-grown PHP framework that literally 
fills the error_log with 100's of thousands of messages each day. First 
order of business was rotating the logs, now we are working through each 
error to solve them. This is a fairly basic error, but I for the life of 
me cannot remember what the solution is.


I have a recursive function that reads from XML files and replaces xi: 
include directives. It looks like this -


function includeXML($file, $locale, $url, $level = 1) {
// stuff
while(($line = fgets($fp)) !== false) {
if($pos === false) {
$xml .= $line;
} else {
includeXML('repository/' . $included, $locale, (int)$level 
+ $pos - 1);

}
}
}

Why do I get the notice that $xml is an undefined index? I do not want 
to suppress the notice, I just want to take care of it properly. I 
attempted setting $xml within the function but then the whole function 
fails for some reason in the depths of this hideous framework. Can 
anyone provide any insight? TVMIA!


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



Re: [PHP] Undefined index....

2013-03-15 Thread Jay Blanchard

[snip]

Two questions:
Where is $xml defined and where is $pos defined?


[/snip]

$xml is defined in other functions, just not in this function. $pos is 
irrelevant to the question - it is just the string position within the 
file.


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



Re: [PHP] Undefined index....

2013-03-15 Thread Jay Blanchard

[snip]

function includeXML($file, $locale, $url, $level = 1) {
 // stuff


$xml = '';
Should work here ...
Since the call below is ADDING to $xml you do need something existing 
to add to so what does that give?

[/snip]

Thanks Lester, that worked. I had just put that in the wrong place. 
*slaps forehead*


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



Re: [PHP] Introduction ... !

2013-03-02 Thread Jay Blanchard

[snip]
...good conversation...
[/snip]

I have been on this list for years and I have watched it ebb and flow. I 
have heard all the bad and good about PHP. The fact remains that we use 
PHP in some very heavy applications and it never fails us for what we 
want or need to do. I always encourage devs to use the proper tool for 
the job, and when using that tool use it to its maximum capability. Let 
each tool do the heavy lifting that it is designed to do. PHP can tote 
some really heavy loads when asked properly.



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



Re: [PHP] Introduction ... !

2013-03-02 Thread Jay Blanchard

[snip]
I've been on this list since the early 2000's.  I used to participate a lot
back then but then took up a non-php related job and I stopped paying
attention to the list.  I've been working again with php for the past 4.5
years but choose to just monitor the list and haven't participated much.
  Perhaps I should participate more.  But yeah, I've been here like 12 years
or so.  God I'm getting old.
[/snip]

No - Tedd is old. The rest of us are just Spring chickens.

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



Re: [PHP] Introduction ... !

2013-03-02 Thread Jay Blanchard

[snip]
Speak for yourself, I'm an autumn turkey! -Stuart
[/snip]

My body is an Autumn turkey, my head says differently - save on certain 
mornings when too much popping and cracking occurs.



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



Re: [PHP] Creating an Advanced Form

2012-11-02 Thread Jay Blanchard
[snip] Warning: mysql_fetch_assoc(): supplied argument is not a valid 
MySQL result resource in 
/var/www/vhosts/numyspace.co.uk/web_users/home/~unn_w11014928/public_html/search.php 
on line 261[/snip]


It would appear that your query is not returning a result. Echo out the 
query and try running it in MySQL to see what is happening.


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



Re: [PHP] URGENT! Need help with command line for list all new/modified files within the last 24 hours

2012-10-25 Thread Jay Blanchard

[snip]
Third, if it is Linux, man find and you will find the answer you seek
[/snip]

RTFMP

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



Re: [PHP] Round help needed

2012-09-28 Thread Jay Blanchard

On 9/27/2012 10:05 PM, Chris Payne wrote:

Hi everyone,

I'm having one of those nights where nothing is working, please help

What I have is this:

$rounded_number = round($test, -3);

Here's the problem i'm having, I need it to increment to the nearest 1000
but it seems to only work if the number is over 500.  For example:


123666  WILL round to 124000 BUT if I put 123085 (As an example) it doesn't
round it, it just stays at 123085 - I know it's probably something totally
ridiculously simple but i'm having a mental block tonight.

Any help would really be appreciated.

Chris
http://www.youtube.com/user/zoolook3264


I just tried it here - http://ideone.com/0icSG and it seems to work fine.

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



Re: [PHP] Creating drop-down menus - use AJAX and jQuery

2012-07-17 Thread Jay Blanchard
[snip]On 7/17/2012 4:55 PM, Daevid Vincent wrote: * jQuery for 
production (minified) is a scant 32k. http://jquery.com/ LOL That's like 
a TCP/IP packet. I bet your images are bigger than 32k. * Unlike stupid 
PHP frameworks (which everyone knows I detest) - JS frameworks are 
cached by the browser so there is no download on every page - JS 
frameworks take all the bullshit browser discrepancies out of your way * 
once you start using jQuery, you will 3 it and use it for many other 
tasks you'd beat your head against a wall in plain old JS to do. * All 
the plugins to add extra functionality make it that much more enticing 
I've not tried YUI or Google's JS framework, but I can tell you that 
jQuery pretty much rocks harder than Pantera and you're doing yourself, 
and your customers a disservice if you're not using it.[/snip]


This.

[snip]JQuery is a LOT of code to include if you're just going to do an 
AJAX call or two. [/snip]


jQuery 1.8 will allow you to create custom builds, including only the 
services that you want. That is coming out really soon. Besides, 
minified and gZippedwell see above.


Maybe I am biased. I am on the jQuery Developer Relations team, have 
authored one book on jQuery and I am currently writing another. But I 
think you'll love it.




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



Re: [PHP] Is this list less busy than it used to be?

2012-07-04 Thread Jay Blanchard
[snip] Is this list less busy than it used to be? Or is it just me? When 
I used to be on this list ISTR sometimes being overwhelmed by email. [/snip]


One other factor is Stackoverflow - there is a tremendous amount of 
traffic there for PHP related questions. I have been a subscriber to 
this list for over a decade (wow) and have seen the traffic cycle up and 
down but it does feel as if this is the least amount of traffic in a 
while. I am unsure of how many are actually still subscribed.




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



Re: [PHP] What's happened to our newsgroup?

2012-06-28 Thread Jay Blanchard

[snip]
We now all have php.net open all the time so no more questions need to 
be asked! :

[/snip]

You mean everyone finally RTFM?

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



Re: [PHP] test

2012-06-07 Thread Jay Blanchard

On 6/7/12 1:07 PM, Sven Kowalski wrote:

does it work now?


It pretty much always did.


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



Re: [PHP] Re: PHP: a fractal of bad design

2012-04-17 Thread Jay Blanchard

[snip]

a simple +1 will do

[/snip]

Ahthe good old days.

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



Re: [PHP] Re: php in windows

2012-04-11 Thread Jay Blanchard

On 4/11/2012 9:42 AM, Steven Staples wrote:

-Original Message-
From: Kirk Bailey [mailto:kbai...@howlermonkey.net]
Sent: April 11, 2012 1:02 AM
To: php-general@lists.php.net
Subject: Re: [PHP] Re: php in windows

ok, there is a copy of index.php ion the cgibin, and this got WAY

different

results.
It puked an error.


   CGI script /cgi-bin/index.php returned nothing

NOW W.T.F., over?
I think that it's time for some rack time. 'Night all.


On 4/11/2012 12:50 AM, Kirk Bailey wrote:

ok, I just installed 5.2.17 VC6X86. I have a simple test page,
index.php; it spews the content code at me.

On 4/10/2012 11:13 AM, Bogdan Ribic wrote:

On 4/10/2012 04:05, Kirk Bailey wrote:

The edition of php for windows I instaklled does not work. Which
flavor
of windows php DOES work properly in windows?

Trust me, it does work :)

I'm running PHP 5.3.10 thread-safe, as apache module on apache
2.4.1 from apache lounge (not official apache builds, as
instructed on PHP's download site), all of that on Win XP. Read
the instruction in php bundle on setting it up with apache 2.2
branch.


Kirk,

[snip]

You have to tell your tinyweb what to do with the .php extensions... in
the config of the webserver, you will have to add a line saying where the
php binary is, or uncomment it (as it probably already exists) and restart
the webserver.


As it appears to me, since you can have some code on the screen, your
server does not know how to deal with it, so it will treat it like a text
file, and just spew the code out.   Once you have it pointing to the php
binary, it will work.

[/snip]

Maybe this will help - 
http://itsecuritylab.eu/index.php/2010/09/24/tinyweb-pocket-size-portable-web-server-with-cgi-and-php-support/


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



Re: [PHP] PHP: a fractal of bad design

2012-04-11 Thread Jay Blanchard

On 4/11/2012 7:06 PM, Daevid Vincent wrote:

http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/

Can't say he doesn't have some good points, but he sure goes about it in a
dickish way.

Yes, he does have some good points and most, if not all, of those points 
have been discussed on this list more than once. The problem with people 
like this is that they choose not to contribute to solving the issues by 
working with the dev team and perhaps even taking a leadership role.


I really am tired of hearing how bad PHP is. I use it every day and I 
have used it for over a decade. Some things are difficult to accomplish 
(re: the thread where Robert helped me tremendously over the past couple 
of weeks). I have been tasked lately with updating and maintaining some 
.net and classic ASP sites and believe me when I say that bad 
programmers/developers make any language crap. I would love it of 
languages were more consistent and concise across the board! For a 
simple website C# is just as much overkill as anything else, not to 
mention that the developer tools are expensive and come with a learning 
curve all of their own.


Yes, there are nuances and inconsistencies. The same goes for any 
language you care to trot out.


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



Re: [PHP] php in windows

2012-04-10 Thread Jay Blanchard

On 4/9/2012 9:05 PM, Kirk Bailey wrote:
The edition of php for windows I instaklled does not work. Which 
flavor of windows php DOES work properly in windows?


You need to give us more details than this. What version did you 
install? What do you mean by does not work? All flavors of PHP will 
work on a Windows server if installed properly.


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



Re: [PHP] desk top interactive environment

2012-04-09 Thread Jay Blanchard
[snip]
On Apr 9, 2012, at 8:38 PM, Kirk Bailey wrote:

 Php would (IMHO) benefit from an interactive desktop application where you 
 can test and experiment with code interactively, instead of edit, dsave, 
 run, view webpage result, edit...
 
 Python has this; why not php?
[/snip]

Because you haven't built it yet?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-04-02 Thread Jay Blanchard
[snip]
 function getTiersJson( $company )
 {
$tiers = getTiers( $company );
$json = JSON_encode( $tiers );
 }
 
 $tiersJson = getTiersJson( 1 );
 
 ?
 
 This will output JSON with the following structure:
 
[/snip]

OK, now I know I am being dense - but don't I have to add return $json; to 
getTiersJson() ?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-31 Thread Jay Blanchard

[snip]
On 3/30/2012 1:14 PM, Robert Cummings wrote:

On 12-03-27 11:11 AM, Jay Blanchard wrote:

[snip]On 3/27/2012 12:21 AM, Robert Cummings wrote:

 [-- SNIP --]

Essentially, entries at the root and entries for the children are just
auto indexed array items but the actual entries in those arrays retain
the associative index structure for retrieval of the specific
information. let me know and I can probably whip you up something.


Robert that looks correct. Here is an example of the JSON that the guy
provided for me -

   var json = {
  id: node02,
  name: 0.2,
  data: {},
  children: [{
  id: node13,
  name: 1.3,
  data: {},
  children: [{
  id: node24,
  name: 2.4,
  data: {},
  children: [{
  id: node35,
  name: 3.5,
  data: {},
  children: [{
  id: node46,
  name: 4.6,
  data: {},
  children: []
  }]
  }, {
  id: node37,
  name: 3.7,
  data: {},
  children: [{
  id: node48,
  name: 4.8,
  data: {},
  children: []
  }, {
  id: node49,
  name: 4.9,
  data: {},
  children: []
  }, {
  id: node410,
  name: 4.10,
  data: {},
  children: []
  }, {
  id: node411,
  name: 4.11,
  data: {},
  children: []
  }]
  },
Of course he properly closes up the JSON. I inserted id's (just an
auto-incrementing number) and the data portion where needed. The name:
is the part that has been the result of what you did before.


Here's the code... I did a bit of shuffling and actually tested 
against a test db table:


?mysql :)

DROP TABLE IF EXISTS tiers;
CREATE TABLE tiers
(
company INT NOT NULL,
tier1   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier2   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier3   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier4   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier5   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier6   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier7   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier8   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier9   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier10  VARCHAR( 32 )   NOT NULLDEFAULT '',
tier11  VARCHAR( 32 )   NOT NULLDEFAULT '',
tier12  VARCHAR( 32 )   NOT NULLDEFAULT '',
tier13  VARCHAR( 32 )   NOT NULLDEFAULT '',
tier14  VARCHAR( 32 )   NOT NULLDEFAULT ''
);

INSERT INTO tiers (company, tier1, tier2, tier3) VALUES
(1, 'exec-001','sub-exec-011','sub-sub-exec-111'),
(1, 'exec-001','sub-exec-011','sub-sub-exec-112'),
(1, 'exec-001','sub-exec-012','sub-sub-exec-121'),
(1, 'exec-001','sub-exec-012','sub-sub-exec-122'),
(1, 'exec-002','sub-exec-021','sub-sub-exec-211'),
(1, 'exec-002','sub-exec-021','sub-sub-exec-212'),
(1, 'exec-002','sub-exec-022','sub-sub-exec-221'),
(1, 'exec-002','sub-exec-022','sub-sub-exec-222');

?

And here's the code:

?php

function getTiers( $company )
{
//
// Establish the root.
//

$sDb = ijinn_getServiceRef( 'dbManager' );
$db = $sDb-getConnectionRef();

$query =
SELECT DISTINCT 
   .   * 
   .FROM 
   .   tiers 
   .WHERE 
   .   company = {$company} ;

$root = array();
if( $db-query( $query ) )
{
while( ($row = $db-fetchRow()) )
{
$focus = $root;
for( $i = 1; $i = 14; $i++ )
{
$name = trim( $row['tier'.$i] );
if( $name === '' )
{
break;
}

if( !isset( $focus[$name] ) )
{
$focus[$name] = array
(
'name' = $name,
'children' = array(),
);
}

$focus = $focus[$name]['children'];
}
}
}

$wrapper = array
(
'children' = $root
);

postProcessTiers( $wrapper );

return $root;
}

function postProcessTiers( $root )
{
$root['children'] = array_values

Re: [PHP] Thinking out loud - a continuation...

2012-03-27 Thread Jay Blanchard

[snip]On 3/27/2012 12:21 AM, Robert Cummings wrote:
I think you need two things... the recursive post processor that 
removes the string indexes for the children. And then a function that 
creates a JavaScript array expression from an object or array. The 
question I have for you... is given the following array structure that 
might be generated from my previous code:


?php

array
(
'exec-001' = array
(
'name' = 'exec-001',
'children' = array
(
'sub-exec-011' = array
(
'name' = 'sub-exec-011',
'children' = array
(
'sub-sub-exec-111' = array
(
'name' = 'sub-sub-exec-111',
'children' = array()
),
'sub-sub-exec-112' = array
(
'name' = 'sub-sub-exec-112',
'children' = array()
)
)
),
'sub-exec-012' = array
(
'name' = 'sub-exec-012',
'children' = array
(
'sub-sub-exec-121' = array
(
'name' = 'sub-sub-exec-121',
'children' = array()
),
'sub-sub-exec-122' = array
(
'name' = 'sub-sub-exec-122',
'children' = array()
)
)
)
)
),
'exec-002' = array
(
'name' = 'exec-002',
'children' = array
(
'sub-exec-021' = array
(
'name' = 'sub-exec-021',
'children' = array
(
'sub-sub-exec-211' = array
(
'name' = 'sub-sub-exec-211',
'children' = array()
),
'sub-sub-exec-212' = array
(
'name' = 'sub-sub-exec-212',
'children' = array()
)
)
),
'sub-exec-022' = array
(
'name' = 'sub-exec-022',
'children' = array
(
'sub-sub-exec-221' = array
(
'name' = 'sub-sub-exec-221',
'children' = array()
),
'sub-sub-exec-222' = array
(
'name' = 'sub-sub-exec-222',
'children' = array()
)
)
)
)
)
);

?

On first blush, I think you want the following structure (from your 
recent posts):


?php

array
(
0 = array
(
'name' = 'exec-001',
'children' = array
(
0 = array
(
'name' = 'sub-exec-011',
'children' = array
(
0 = array
(
'name' = 'sub-sub-exec-111',
'children' = array()
),
1 = array
(
'name' = 'sub-sub-exec-112',
'children' = array()
)
)
),
1 = array
(
'name' = 'sub-exec-012',
'children' = array
(
0 = array
(
'name' = 'sub-sub-exec-121',
'children' = array()
),
1 = array
(
'name' = 'sub-sub-exec-122',
'children' = array()
)
)
)
)
),
1 = array
(
'name' = 'exec-002',
'children' = array
(
0 = array
(
'name' = 'sub-exec-021',
'children' = array
(
0 = array
(
'name' = 'sub-sub-exec-211',
'children' = array()
),
1 = array
(
'name' = 'sub-sub-exec-212',
'children' = array()
)
)
),
1 = array
(
'name' = 'sub-exec-022',
'children' = array
(
0 = array
(
'name' = 'sub-sub-exec-221',
'children' = array()
),
1 = array
  

Re: [PHP] Thinking out loud - a continuation...

2012-03-27 Thread Jay Blanchard

[snip]On 3/27/2012 12:21 AM, Robert Cummings wrote:
I think you need two things... the recursive post processor that 
removes the string indexes for the children. And then a function that 
creates a JavaScript array expression from an object or array. The 
question I have for you... is given the following array structure that 
might be generated from my previous code:


?php

array
(
'exec-001' = array
(
'name' = 'exec-001',
'children' = array
(
'sub-exec-011' = array
(
'name' = 'sub-exec-011',
'children' = array
(
'sub-sub-exec-111' = array
(
'name' = 'sub-sub-exec-111',
'children' = array()
),
'sub-sub-exec-112' = array
(
'name' = 'sub-sub-exec-112',
'children' = array()
)
)
),
'sub-exec-012' = array
(
'name' = 'sub-exec-012',
'children' = array
(
'sub-sub-exec-121' = array
(
'name' = 'sub-sub-exec-121',
'children' = array()
),
'sub-sub-exec-122' = array
(
'name' = 'sub-sub-exec-122',
'children' = array()
)
)
)
)
),
'exec-002' = array
(
'name' = 'exec-002',
'children' = array
(
'sub-exec-021' = array
(
'name' = 'sub-exec-021',
'children' = array
(
'sub-sub-exec-211' = array
(
'name' = 'sub-sub-exec-211',
'children' = array()
),
'sub-sub-exec-212' = array
(
'name' = 'sub-sub-exec-212',
'children' = array()
)
)
),
'sub-exec-022' = array
(
'name' = 'sub-exec-022',
'children' = array
(
'sub-sub-exec-221' = array
(
'name' = 'sub-sub-exec-221',
'children' = array()
),
'sub-sub-exec-222' = array
(
'name' = 'sub-sub-exec-222',
'children' = array()
)
)
)
)
)
);

?

On first blush, I think you want the following structure (from your 
recent posts):


?php

array
(
0 = array
(
'name' = 'exec-001',
'children' = array
(
0 = array
(
'name' = 'sub-exec-011',
'children' = array
(
0 = array
(
'name' = 'sub-sub-exec-111',
'children' = array()
),
1 = array
(
'name' = 'sub-sub-exec-112',
'children' = array()
)
)
),
1 = array
(
'name' = 'sub-exec-012',
'children' = array
(
0 = array
(
'name' = 'sub-sub-exec-121',
'children' = array()
),
1 = array
(
'name' = 'sub-sub-exec-122',
'children' = array()
)
)
)
)
),
1 = array
(
'name' = 'exec-002',
'children' = array
(
0 = array
(
'name' = 'sub-exec-021',
'children' = array
(
0 = array
(
'name' = 'sub-sub-exec-211',
'children' = array()
),
1 = array
(
'name' = 'sub-sub-exec-212',
'children' = array()
)
)
),
1 = array
(
'name' = 'sub-exec-022',
'children' = array
(
0 = array
(
'name' = 'sub-sub-exec-221',
'children' = array()
),
1 = array
  

Re: [PHP] List working?

2012-03-27 Thread Jay Blanchard
[snip]
 y u no help me  !!  i have white page withg my php codes in my page !
 help please !!  asap please  i put codes in my file and is white
 
[/snip]

You put code in your e-mail? Or code in your web page? If it is your web page 
you need to start a new thread and post the code that you used so that we can 
help trouble-shoot.


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



Re: [PHP] Thinking out loud - a continuation...

2012-03-26 Thread Jay Blanchard
[snip]
This is one of those projects. It is apparently going to be trying every step 
of the way.
[/snip]

I was proven right this morning after all of Robert's good work and what I had 
added to make this work.  It turns out that the one service who was anxious to 
consume the JSON output expects that the JSON be a certain format. When I run 
their format through jslint it does not validate unless I add quotes around the 
name portion of the name:value pairs. In addition they use (perfectly valid) 
square brackets around the children groups that the output from json_encode() 
does not contain.

I am ready to take a loss on this one but I really didn't lose - Robert gave me 
a great way to retrieve the data with one query and create valid JSON from it. 
Thanks again Robert!


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



Re: [PHP] Thinking out loud - a continuation...

2012-03-26 Thread Jay Blanchard
[snip]
 Square brackets in JSON represent arrays. Take their JSON, run it through 
 json_decode, and assuming it decodes correctly compare the structure to what 
 you already have. You should then be able to modify what you have so it 
 generates JSON in the format they are expecting.
[/snip]

Done. I knew about the square brackets. In the code being used the array, if 
blank, gets square brackets. For some reason an array containing actual data 
does not.


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



Re: [PHP] Thinking out loud - a continuation...

2012-03-26 Thread Jay Blanchard
[snip]
 *lol* No worries... it's all about solving problems :)
[/snip]

the other folks who needed to consume the JSON have all done so successfully 
today - just this one. The guy who runs it was plenty arrogant when I discussed 
with him. He is the one who wanted me to remove the extra array name. I cooked 
up some regex to do that but then all of the opening/closing curlies were out 
of whack. If I had kept going it would have been maddening. I told him he 
needed to fix his JSON parsing. He said I needed to add the square brackets. 
Programmer stand-off.


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



Re: [PHP] Thinking out loud - a continuation...

2012-03-26 Thread Jay Blanchard
[snip]
 Did you end up with a satisfactory output? It's not overly difficult to 
 generate an array instead of an object.
[/snip]

I did for all but this one instance. Are you saying that it would be easy to 
make of the children arrays? I thought they were already - am I missing 
something?


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



Re: [PHP] Thinking out loud - a continuation...

2012-03-26 Thread Jay Blanchard
[snip]
On Mar 26, 2012, at 5:58 PM, Robert Cummings wrote:

 On 12-03-26 06:52 PM, Jay Blanchard wrote:
 [snip]
 Did you end up with a satisfactory output? It's not overly difficult to 
 generate an array instead of an object.
 [/snip]
 
 I did for all but this one instance. Are you saying that it would be easy to 
 make of the children arrays? I thought they were already - am I missing 
 something?
 
 They are arrays... but JSON_encode is creating objects. You can create arrays 
 by traversing the array structure recursively and outputing your own 
 JavaScript code to build a JavaScript array. I don't know if that would serve 
 the purpose, but you would end up with an array.
[/snip]

I'm listening - so could this be added to the code that you just wrote? Or do I 
need to recurse the output from json_encode()? 


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



Re: [PHP] Thinking out loud - a continuation...

2012-03-25 Thread Jay Blanchard
[snip]
a necessary part of building the structure. It can be removed but only as a 
post process. Why does it have to be removed? You can loop through the 
structure in JavaScript without paying heed to the key's value.
 
 If it absolutely must go... you need to recurse through the final structure 
 replacing each children entry with the results of passing it through 
 array_values().
[/snip]

Unfortunately the user of the JSON will not make a change to their app. I have 
looked through the JSON to confirm that this has a particular pattern so I 
think I can just do a little regex and get it squared away. This is one of 
those projects. It is apparently going to be trying every step of the way.


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



Re: [PHP] Thinking out loud - a continuation...

2012-03-24 Thread Jay Blanchard
[snip]
 Did you send me a sample dump for your table :)
[/snip]

I'll do that today. I got side-tracked last night.


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



Re: [PHP] Thinking out loud - a continuation...

2012-03-24 Thread Jay Blanchard

On Mar 23, 2012, at 11:24 PM, Robert Cummings wrote:

 On 12-03-23 05:41 PM, Jay Blanchard wrote:
 [-- DELETED GARBAGE --]  :)
 
 I just realized... I've been stuck in a thinking rut. I latched onto one 
 solution that works well in some case but didn't fully examine the nuances of 
 your own scenario. Given the way you are creating your hierarchy you will 
 ultimately retrieve all rows. As such the following simple solution will do 
 what you need:
 
 ?php
 
$company = 1;
 
$query =
SELECT DISTINCT 
   .   * 
   .FROM 
   .   tiers 
   .WHERE 
   .   company = {$company} ;
 
$root = array();
if( $db-query( $query ) )
{
while( ($row = $db-fetchRow()) )
{
$focus = $root;
for( $i = 1; $i = 14; $i++ )
{
$name = $row['tier'.$i];
 
if( !isset( $focus[$name] ) )
{
$focus[$name] = array();
}
 
$focus = $focus[$name];
}
}
}
 
$json = JSON_encode( $root );
 
 ?
 
 Cheers,
 Rob.
 -- 

At first blush I'm not sure how this would work - but I haven't had any coffee 
yet either. I'll give this a shot in a little while. Seems almost too easy.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-24 Thread Jay Blanchard
[snip]The crux of it is:
 
$focus = $focus[$name];
 [/snip]

It works as I expect so far. All I have to do is figure out how to make the 
element a name: element in the JSON. for instance an element would look like 
this

{
   name: Bob,
   children: []
}

So the PHP array would have to look like this - 

$json = array (
name = Bob,
children = array (
name = Angie
)
)

and so on. This is for one of the services that will consume the JSON.



Re: [PHP] Thinking out loud - a continuation...

2012-03-24 Thread Jay Blanchard
[snip]
 A little tweak here... a little tweak there:
[/snip]
 
 
if( !isset( $focus[$name] ) )
{
$focus[$name] = array
(
'name' = $name,
'children' = array(),
);
}
 
$focus = $focus[$name]['children'];
}
}
}
[/snip]

Bingo! We have a winner! I had already started on the $focus[$name] array as 
you have shown, I just hadn't figured out the $focus[$name]['children'] part. 
Thank you so much Robert - you're a real asset to the PHP community!



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



Re: [PHP] Thinking out loud - a continuation...

2012-03-24 Thread Jay Blanchard
[snip]
 A little tweak here... a little tweak there:
[/snip]

One more little tweak may be required. The JSON looks like this

{Executives and Management:{name:Executives and Management,children:{

The first part {Executives and Management: needs to be removed. I think I 
know what to do.



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



Re: [PHP] Thinking out loud - a continuation...

2012-03-24 Thread Jay Blanchard
[snip]
 One more little tweak may be required. The JSON looks like this
 
 {Executives and Management:{name:Executives and Management,children:{
 
 The first part {Executives and Management: needs to be removed. I think I 
 know what to do.
[/snip]

It has become painfully obvious that I do not know what to do. Ready to call it 
a day. Besides I just burned my finger setting up the smoker for the ribs.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
[snip]
 Your data structure doesn't appear to be very ummm normalized... Nonetheless, 
 the following should do it:
[/snip]

You're absolutely correct. Unfortunately I am not the designer and cannot 
really do anything about it. I just have to work with what I have. Thank you 
very much for this - I will test it out this afternoon and let you know how it 
all goes.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
[snip]
$json = JSON_encode( $root );
[/snip]

Update on my test. This works perfectly Robert - thank you very much! But there 
is one small problem that I am trouble-shooting: it only goes one layer and 
doesn't progress any further. I suspect it is on this section of code that I am 
going to add some stuff to to see what is happening.

if( !($parents = $children) ){
   break;
   }

Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard

 [snip]
   $json = JSON_encode( $root );
 [/snip]
 
 Update on my test. This works perfectly Robert - thank you very much! But 
 there is one small problem that I am trouble-shooting: it only goes one layer 
 and doesn't progress any further. I suspect it is on this section of code 
 that I am going to add some stuff to to see what is happening.
 
 if( !($parents = $children) ){
   break;
   }

It would appear that both arrays are empty on the next cycle through so the 
break occurs.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard

On Mar 23, 2012, at 2:25 PM, Robert Cummings wrote:

 On 12-03-23 03:17 PM, Jay Blanchard wrote:
 [snip]
$json = JSON_encode( $root );
 [/snip]
 
 Update on my test. This works perfectly Robert - thank you very much! But 
 there is one small problem that I am trouble-shooting: it only goes one 
 layer and doesn't progress any further. I suspect it is on this section of 
 code that I am going to add some stuff to to see what is happening.
 
 if( !($parents =$children) ){
break;
}
 
 I didn't actually test it... if you have trouble figuring out the problem 
 feel free to send me a copy of your table (in private) and I'll debug :)

I had it backwards. Both arrays are empty and the break should not occur 
because they are equal to each other. Let me send you a portion of the table 
Robert. 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
[snip]
 Did you get any results form the database on the second run through the query 
 loop?
[/snip]

Actually, no. I just ran the raw query - 

SELECT DISTINCT `TIER3DATA` AS id, `TIER2DATA` AS parentId FROM 
`POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER2DATA` IN ('Executives and 
Management','Professionals','Technicians','Craft 
Workers-Skilled','Operatives','Contractor','Sales Workers','Laborers and 
Helpers','Admin Support')

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
[snip]
 No, I'm performing assignment... intentionally. Parent's becomes the previous 
 children to move down a level. The following:
 
if( !($parents = $children) )
 
 performs assignment and an empty array check in one statement.
[/snip]

Gotcha'. 

So all I am ever getting back right now is the result of the first query.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
 [snip]
 SELECT DISTINCT `TIER3DATA` AS id, `TIER2DATA` AS parentId FROM 
 `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER2DATA` IN ('Executives and 
 Management','Professionals','Technicians','Craft 
 Workers-Skilled','Operatives','Contractor','Sales Workers','Laborers and 
 Helpers','Admin Support')
 
 and it is empty. 
[/snip]

I figured out part of the problem - the for loop starts at tier2 instead of 
tier1

Once I made that change I get the following error:

Fatal error: Cannot use string offset as an array in 
/home/orcadept/public_html/poschart/json_chart.php on line 139

Line 139 is $item['children'][$id] = $child;

Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
[snip]
 $item['children'] should be an array, somehow a string has been assigned :/
[/snip]

Yep. I am trying to figure that out now. I'm sure it is something really small. 

BTW, after making the change to the for loop there are results returned as we 
expected.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
 [snip]
 $item['children'] should be an array, somehow a string has been assigned :/
 [/snip]
 
 Yep. I am trying to figure that out now. I'm sure it is something really 
 small. 
[/snip]

I have been hammering away at it for a while now and still cannot find the 
issue. I'll push away for a while and come back to it. Robert I owe you so many 
thinks for getting me this far and opening me up to making this more efficient. 
I just have to push on through and get to the point where  the JSON can be 
created and consumed. If any light bulb goes on over your head would you let me 
know. I have tried everything that I know works to keep this from being a 
string - I am just missing something.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
[snip]
…stuff….
[/snip]

For those interested here is where the problem seems to occur - 

$child = array
   (
   'id'   = $id,
   'parentId' = $pid,
   'children' = array()
   );
   
   $children[$id][] = $child;
   
   foreach( $parents[$pid] as $items ){
   foreach( $items as $item ){   
 $item['children'][$id] = $child; // error: Cannot use 
string offset as an array
   }
   }

Maybe someone will see this and know what's going on. Before the foreach 
$children is an array. 



Re: [PHP] Thinking out loud - a continuation...

2012-03-22 Thread Jay Blanchard
[snip]
Would it not be easier to get the data from a view which has the tables joined? 
Then it would be one query and it's a simple matter to format the results into 
the multi dimensional array then json?
[/snip]

The data is all from one table. I'll write up a more thorough explanation in a 
little while.


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



Re: [PHP] Thinking out loud - a continuation...

2012-03-22 Thread Jay Blanchard

[snip]
...stuff...
[/snip]

Here is the explanation for what I have done and what I am trying to do 
- (based on the customer's request).


A week or so ago I took a set of queries from one table and made them 
into an unordered list. This will be pseudo-code so that you get idea.


SELECT DISTINCT column1 FROM table
WHERE company = '1'

while($column1 = mysql_fetch_array($query1results)){
SELECT DISTINCT column2 FROM table
WHERE company = '1'
AND column1 = $column1[0]

while($column2 = mysql_fetch_array($query2results)){
SELECT DISTINCT column3 FROM table
WHERE company = '1'
AND column2 = $column2[0]
}
}

This continues for up to 14 columns of data. I'm not worried about the 
recursive data retrieval, I have that part and like I said - I can 
output a nested unordered list from it quite handily.


Now the customer wants JSON as the output. The JSON must reflect the 
children properly.


So I have two choices, a multidimensional array that I can use 
json_encode() on or output a string that ultimately forms the JSON. We 
have all agreed that doing an array would be the best thing but I cannot 
wrap my head around it.


If you have more questions fire away - I'd love to get this solved and 
off of my plate.


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



Re: [PHP] Thinking out loud - a continuation...

2012-03-22 Thread Jay Blanchard

[snip]
Fix this code... I've come across codebases that did this specific 
type of nested querying and it resulted in 1 queries to the 
database on every page. Instead, create a layered approach:


1. Select your root elements.
2. Loop over in PHP and create an array of child IDs.
3. Select the children from the database.
4. Go to step 2.

This way you will only every perform depth number of queries.

[/snip]

I see what you're saying but I don't know that this reduces the number 
of queries - it just handles them in a different order. How do I get to 
the output that I need?


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



Re: [PHP] Thinking out loud - a continuation...

2012-03-22 Thread Jay Blanchard

[snip]
On 3/22/2012 11:17 AM, Robert Cummings wrote:

On 12-03-22 11:58 AM, Jay Blanchard wrote:

[snip]

Fix this code... I've come across codebases that did this specific
type of nested querying and it resulted in 1 queries to the
database on every page. Instead, create a layered approach:

 1. Select your root elements.
 2. Loop over in PHP and create an array of child IDs.
 3. Select the children from the database.
 4. Go to step 2.

This way you will only every perform depth number of queries.

[/snip]

I see what you're saying but I don't know that this reduces the number
of queries - it just handles them in a different order. How do I get to
the output that I need?


It definitely reduces the queries... your current method gets all the 
first level nodes in one query, then performs a query for every single 
parent node. Mine only performs a query for each level in the tree. If 
you have 5 nodes at the first level you will perform 6 queries. Mine 
will perform 2.

[/snip]

How so? A query must be performed for each parent node to get its children.

 parent
   |
childchildchildchild
|
grandchild grandchild


[snip]
To generate the nesting structure at each level you track the level 
members. Something like the following (untested pseudoish):


?php

$parents = query_for_first_level();
$root = $parents;

while( $parents )
{
$parentIds = array();
foreach( $parents as $parent )
{
$parentIds[$parent['id']] = $parent['id'];
}

$children = query_for_children( $parentIds );
foreach( $children as $child )
{
$parents[$child['parentId']]['children'][] = $child;
}

$parents = $children;
}

$jsonData = JSON_encode( $root );

?

[/snip]

I'll try to apply this and see what I run into.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-22 Thread Jay Blanchard

[snip]
Sorry, I just realized I didn't make the optimization explicitly 
obvious... when I say Select the children I mean to select them 
using an IN( id1, id2, id3 ) clause instead of a query for each. This 
is why we build the array of parent IDs (also I wrote build an array 
of child IDs, it should have read parent IDs and has been fixed 
above :).

[/snip]

SELECT DISTINCT children FROM table WHERE column1 IN(id1, id2, id3) ?

I am sure I am not following you now. Maybe I didn't explain clearly?

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-22 Thread Jay Blanchard

On 3/22/2012 11:40 AM, Robert Cummings wrote:

On 12-03-22 12:34 PM, Jay Blanchard wrote:

[snip]

Sorry, I just realized I didn't make the optimization explicitly
obvious... when I say Select the children I mean to select them
using an IN( id1, id2, id3 ) clause instead of a query for each. This
is why we build the array of parent IDs (also I wrote build an array
of child IDs, it should have read parent IDs and has been fixed
above :).

[/snip]

SELECT DISTINCT children FROM table WHERE column1 IN(id1, id2, 
id3) ?


I am sure I am not following you now. Maybe I didn't explain clearly?


What's the field for which you are selecting data? I've written this 
up as a parent/child relationship but it works for data/sub-data 
relationships also.


SELECT itemId, otherData FROM table WHERE some condition;

SELECT itemId, subData FROM otherTable WHERE itemId IN (id1, id2, ...);

Then just link up the sub-data to the primary data in a loop and 
finally generate your JSON.


Does that clarify?

[/snip]

I must confess that the raging sinus headache and my general confusion 
makes this really unclear for me today. Maybe I should just set it aside 
for a day or so. I am super dense today.


For each level I am selecting for each parent in the level above. Let's 
say that level 2 contains 8 people. Level 3 contains 14 people. Only 
some of the 14 belong to the 8 and must be associated properly. So how 
can I, with one query, associate level 3' 8th, 9th and 10th people with 
level 2's 6th person keeping in mind that the 9th person might also 
belong to level 2's 4th person.


Just link up the sub-data? Place this array into a child array of the 
parent array? Again I apologize - maybe I should push away and let the 
customer know that it'll be a couple of more days.


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



Re: [PHP] Thinking out loud - a continuation...

2012-03-22 Thread Jay Blanchard
[snip]
 At one point you indicated all the data was coming from one table. Can you 
 send me the table fields and indicate which fields are used to determine 
 parent child relationship? Also 2 sample rows of data which have a 
 relationship would be helpful.
[/snip]

Columns - tier1, tier2, tier3, tier4 etc. (ends with tier14)

Children of tier1 are tier2 -

select distinct tier2 from table where tier1 = foo and company = 1
select distinct tier2 from table where tier1 = bar and company = 1
etc.

Children of tier2 are tier3, etc.

tier1   tier2   tier3
1,  executive,  ceo,ceo
1,  executive,  vp-ops, vp-ops
1,  executive,  vp-admin,   vp-admin mgr
1,  executive,  vp-admin,   vp-admin ops mgr
1,  executive,  vp-admin,   vp-admin mgr
1,  executive,  vp-admin,   vp-admin clerk
1,  professionalpro-mgr pro-admin
1,  professionalpro-IT  pro-dev
1,  professionalpro-IT  pro-infra
1,  professionalpro-IT  pro-dev
1,  technician  tech-admin  tech-admin mgr
1,  technician  tech-opstech-ops mgr

Thanks for all of your help. I know I am being a PITA.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Thinking out loud - a continuation...

2012-03-21 Thread Jay Blanchard
This is a continuation of the nested query thing I posted to the list a while 
back. I was finally able to output a nested unordered array that worked out 
well, but scope-creep has come in the door and I have to change gears.

I have a project where I have multiple queries and each query uses the results 
from the previous query to get it's results. I need to do one of two things, 
either out put a multidimensional array that I can use json_encode() on or I 
have to format the output from the queries as a JSON string. The resulting JSON 
will be used by a JavaScript widget and must be formed correctly. I created the 
following array by hand:

$userList = array(John = array(
 email = j...@demo.com,
 website = www.john.com,
 age = 22,
 password = pass,
 description = array(
hair = blonde,
eyes = blue,
build = medium
 )),
  Anna = array(
 email = a...@demo.com,
 website = www.anna.com,
 age = 24,
 password = pass,
 description = array(
hair = brunette,
eyes = hazel,
build = petite
)
 ));  

I ran it through json_encode() and got the following output

{John:{email:j...@demo.com,website:www.john.com,age:22,password:pass,description:{hair:blonde,eyes:blue,build:medium}},Anna:{email:a...@demo.com,website:www.anna.com,age:24,password:pass,description:{hair:brunette,eyes:hazel,build:petite}}}

jslint.com verifies this as good JSON (although I thought there had to be 
square brackets around child arrays).

If you were me would you just generate the JSON? If not what is he best way to 
output an array that will nest properly for each subsequent query?

Thanks for any insight!




Re: [PHP] Thinking out loud - a continuation...

2012-03-21 Thread Jay Blanchard
[snip]
I would, yes, but that's not the point.  Is Anna single?  I'm
 ready to trade Debs in for a newer model.
[/snip]

I'm thinking that Debs would upset your array if you traded her in. 

Anyhow, I have spent the last hour trying to output valid JSON but the whole 
thing is making me barking mad. I may try create a multidimensional array here 
in a little bit. After I go for a walk.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-21 Thread Jay Blanchard
[snip]
 Why are you trying to create the JSON structure in parts? When I have nesting 
 like this i build the full nested structure as PHP, then export to JSON.
[/snip]

As PHP? An array?


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



[PHP] PHP 5.3.2 on IIS Fast CGI Timeout error

2012-03-20 Thread Jay Blanchard

Good afternoon PHP gurus,

I am trying to troubleshoot a problem on a Windows server (*UGH*). This 
is the error -


The FastCGI Handler was unable to process the request.


Error Details:

 * The FastCGI process exceeded configured activity timeout
 * Error Number: 258 (0x80070102).
 * Error Description: The wait operation timed out.


   HTTP Error 500 - Server Error.
   Internet Information Services (IIS)


Here is the code it appears to be choking on -

/* open the file for reading and/or writing */
$csvFile = fopen(CSV_FILE, rb);
$csvTemp = fopen(CSV_TEMP_FILE, wb);
if(!$csvTemp) {
echo 'failed tp open '.CSV_TEMP_FILE;
}

/* create the edit vehicle info */

/* create a stock number for this vehicle */
$vinPart = substr($_POST['vin-number'], -6);
$stockNumber = 'EC'.$vinPart;

/* create a line to be inserted into the .csv file */
$csvContent = $stockNumber.',';
$csvContent .= mysql_real_escape_string($_POST['vehUser']).',';
$csvContent .= mysql_real_escape_string($_POST['vmake']).',';
$csvContent .=mysql_real_escape_string($_POST['vmodel']).',';
$csvContent .= mysql_real_escape_string($_POST['vyear']).',';
$csvContent .=
mysql_real_escape_string($_POST['vin-number']).',';

$csvContent .=mysql_real_escape_string($_POST['vprice']).',';
$csvContent .= 
mysql_real_escape_string($_POST['vdescription']).\r\n;


/* loop through and write edited lines back in while 
maintaining non-edited lines */

while(!FEOF($csvFile)) {

/* get current line information */
$originalLineArray = fgetcsv($csvFile, 4096, ',');

/* test and replace as required */
if(is_array($originalLineArray)) {
if($stockNumber == $originalLineArray[0]) {
fwrite($csvTemp, $csvContent);
} else {
$currentLine = implode(,, $originalLineArray);
$currentLine = $currentLine.\r\n;
fwrite($csvTemp, $currentLine);
}
}
}
/* close the files */
fclose($csvFile);
fclose($csvTemp);

/* rename the temp file */
rename(CSV_TEMP_FILE, CSV_FILE);

Anyone have any clue why this might be happening? I have followed the 
events using Process Monitor which doesn't complain at all, yet the temp 
file gets created but never written to. I have been all over the web for 
a couple of hours now with no clue as to what is going on. I'd really 
appreciate any hints or tips.


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



Re: [PHP] PHP 5.3.2 on IIS Fast CGI Timeout error (SOLVED)

2012-03-20 Thread Jay Blanchard
[snip]
..the craziness of it all
[/snip]

Found out that the PostGreSQL .dll was not loaded and that the server had been 
configured to not give up any errors regardless of how I set error reporting. 
Reconfigured the server and restarted it. Viola'! It all works now.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Got HTML5 History API + caching LICKED, I think, grin

2012-03-17 Thread Jay Blanchard
[snip]
 As for minifying the javascripts, it would take me another day, maybe 2, to
 build a script for that.
 And I don't think it would matter much, all the animatedJavascriptWidgets
 JS is gzipped 25kb and if I shave 5kb off that (upper estimate) then I
 don't consider that worth the effort, at this particular time. I have other
 things (content creation and compatibility) I want to get done atm.
[/snip]

Really? A day or two? Minifiying also tends to reduce code size by 50% or more 
depending on the author. If you only get a 25% reduction it is time to take a 
look at your coding practices.

[snip]
 I wrote this library because I have been unable to find anything like it on
 the interwebs.
 I put it out for free because I think it's cool to give something back to
 the opensource community.
 But, again, I'm not interested in having my priority list hijacked by
 experts who won't bother just to give me back the fix.
[/snip]

Put it on Github and see how many free labor….uh, er…code fixers you can 
attract.

Giving back to the community is a great thing, it is why many expert PHP coders 
are on this list. They are already providing you with fixes that you aren't 
listening to regardless of the language that these fixes are couched in. 
Community is about give and take and you have started your foray into the 
community by disallowing take. 

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



Re: [PHP] fgetcsv doesn't return an array?

2012-03-16 Thread Jay Blanchard

[snip]
 Not sure why, but ok. Thanks everyone!

An empty line would lead to $csvCurrentLine == array() which as a boolean would 
be false but would not necessarily mean EOF. By using === to check the value 
the expression will only evaluate to false at EOF or an error.

-Stuart

[/snip]

Makes perfect sense! I just wasn't reading it right.

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



[PHP] fgetcsv doesn't return an array?

2012-03-15 Thread Jay Blanchard
I thought that fgetcsv returned an array. I can work with it like an 
array but I get the following warning when using it


|Warning:  implode(): Invalid arguments passed on line 155

154 $csvCurrentLine = fgetcsv($csvFile, 4096, ',');
155 $currentLine = implode(,, $csvCurrentLine);
|

Everything that I have read online indicates that it is because 
$csvCurrentLine is not declared as an array. Adding a line to the code


153 |$csvCurrentLine = array();

Does not get rid of the warning. The warning isn't interfering with the 
script working, but it us annoying. Does anyone know the solution?


Thanks!

Jay
|


Re: [PHP] fgetcsv doesn't return an array?

2012-03-15 Thread Jay Blanchard

On 3/15/2012 12:23 PM, Matijn Woudt wrote:

On Thu, Mar 15, 2012 at 6:09 PM, Jay Blanchard
jay.blanch...@sigmaphinothing.org  wrote:

I thought that fgetcsv returned an array. I can work with it like an array
but I get the following warning when using it

|Warning:  implode(): Invalid arguments passed on line 155

154 $csvCurrentLine = fgetcsv($csvFile, 4096, ',');
155 $currentLine = implode(,, $csvCurrentLine);
|

Everything that I have read online indicates that it is because
$csvCurrentLine is not declared as an array. Adding a line to the code

153 |$csvCurrentLine = array();

Does not get rid of the warning. The warning isn't interfering with the
script working, but it us annoying. Does anyone know the solution?

Thanks!

Jay
|

Are you using this in a loop or something? fgetcsv returns FALSE on
errors, including End Of File.

[/snip]

I am using it in a loop. End Of File is an error?


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



Re: [PHP] fgetcsv doesn't return an array?

2012-03-15 Thread Jay Blanchard
[snip]
 Please, don't do that. Use this instead:
 while (($csvCurrentLine = fgetcsv($csvFile, 4096, ',')) !== FALSE) {
 }
 [/snip]

Not sure why, but ok. Thanks everyone!

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



[PHP] Converting an unordered list into JSON

2012-03-05 Thread Jay Blanchard

Good morning PHP groupies!

I am off on my next tangent now and I have not really thought about this 
too much yet but have you seen a method to convert a nested unordered 
list into JSON using PHP?


Thanks!

Jay

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



Re: [PHP] Converting an unordered list into JSON

2012-03-05 Thread Jay Blanchard

On 3/5/2012 9:53 AM, Stuart Dallas wrote:

On 5 Mar 2012, at 15:50, Jay Blanchard wrote:


I am off on my next tangent now and I have not really thought about this too 
much yet but have you seen a method to convert a nested unordered list into 
JSON using PHP?

There's a very useful search function for the PHP manual on the PHP site. 
Typing json into that would have got you to http://php.net/json_encode. If that 
can't natively handle your variable type then you'll need to massage the data 
into simple types first.


Stuart I have RTFM, I was hoping that someone had an example handy. :)

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



Re: [PHP] Converting an unordered list into JSON

2012-03-05 Thread Jay Blanchard

[snip]
$json = json_encode($nested_unordered_list); As I said, whether that 
works or not depends on what type $nested_unordered_list is. If it's not 
made of standard types you'll need to massage it into a structure using 
standard types. :D

[/snip]

Stewie, Stewie, Stewie. :)

So what you're saying is that I will need to turn the nested unordered 
list into an array? Because an array would more accurately represent the 
data.


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



Re: [PHP] Converting an unordered list into JSON

2012-03-05 Thread Jay Blanchard

[snip]
Difficult to answer without knowing how your data is currently stored. 
Gimme a var_dump or var_export of your data and I'll be able to give you 
an answer. -Stuart

[/snip]

It is an unordered nested list as in the following example -

ul
lifoo/li
libar
ul
liglorp/li
/ul
/li
/ul


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



Re: [PHP] Converting an unordered list into JSON

2012-03-05 Thread Jay Blanchard

[snip]
Sounds like your tangents are efforts to accomplish things that you know 
too little about and don't want to spend too much time getting 
acquainted with. To borrow from your crude response to Mr. Dallas: You 
may have RTFM, now try DTFW. :)

[/snip]

Seriously Jim? I have been a member and contributor to this very list 
for a very long time. I do know about my tangents and I am quite 
acquainted with what is entailed but hoping that the community might 
have some insight that would cause me to look at things in a fresh light.


I appreciate your rude response to my rude response. You are quite clever :)


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



Re: [PHP] Converting an unordered list into JSON

2012-03-05 Thread Jay Blanchard

[snip]
Ahh, the list is in an HTML document, suddenly it all becomes clear. 
DOMDocument is probably your best bet here. Other HTML parsers are also 
available. -Stuart

[/snip]

Ah! Thanks for the heads up on that Stuart - I'll start my work there 
this afternoon.



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



Re: [PHP] iphone php

2012-03-05 Thread Jay Blanchard
[snip]In the last few mins I re-booted my phone and it is now doing 
something even worse! [/snip]


Have you also cleared the cache and the cookies?

You can also add Firebug to your iPhone - 
http://www.iphone-my.com/ipad/geting-firebug-iphone-ipad/


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



Re: [PHP] Nested database loops and completing an unordered list....

2012-03-02 Thread Jay Blanchard
 My usual approach to a problem like this to to includes a parent column in 
 the table
 
 ID (int pk)
 Parent ( default null ) // no parent
 Item
 Itemtype
 [etc]
 
 Parent will then hold either a null if a top level item, or a structured path 
 ( 1/10/24 ) that notes the parents of the item all the way up to the parent. 
 That way, a single query will get you all items in that parent's lineage to 
 whatever depth is needed by using the child's value
 
 Select * from table where parent = '1/10' 
 
 Would retrieve all items that are children of a top level of 1 and a second 
 level of 10

I would do that under normal circumstance but I cannot modify the client's 
table in any way shape or form. I am considering the COMPANY_ID to be the 
parent at this point and I can get all who belong to a company. I just need to 
turn that lineage into a tree.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Nested database loops and completing an unordered list....

2012-03-02 Thread Jay Blanchard

[snip]
Doesn't this SQL query return everything that has company_id set to 3 
which would it not contain all the data from the other queries combined 
into one large data set?

[/snip]

I could do that, I can return one large dataset for all of the columns 
shown in the tiers array. I have to remove the DISTINCT's. When I return 
that dataset in this case I return seven columns of data with the parent 
being in the leftmost column and descending to the right. The goal with 
the the recursive function was to get each descendant line so that it 
could be formatted in a nested unordered list. So in the SQL below you 
get 9 records. For each of the 9 records you could get any number of 
children depending on which of the 9 you're looking at. Then for each of 
those children you could get their descendants and so on.


I was doing it the long way at first, until a recursive function was 
suggested. The problem that I was having there was formatting the ul's 
and li's properly.


Now I feel as if I am really close to a better solution than the brute 
force method. I may just be a little too frustrated to see what is a 
simple answer.


Thanks for your help!





At this point, I don't believe you have shown your output.  Please 
show the output of your function.



0
SELECT DISTINCT `TIER1DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` 
= '3'

Executives and Management

Normally this query alone returns 9 rows of data. Each of these rows 
should be included in the next query where TIER1DATA = each of the 
nine in succession


1
SELECT DISTINCT `TIER2DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` 
= '3' AND `TIER1DATA` = 'Executives and Management'

  Executives and ManagementLeadership



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



Re: [PHP] Nested database loops and completing an unordered list....

2012-03-02 Thread Jay Blanchard

[snip] ...stuff ... [/snip]

A thought occurred to me - I need to call the function at the end of the 
while loop and then again with different criteria after the while loop? 
I'll have to test that later today.


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



Re: [PHP] Nested database loops and completing an unordered list....

2012-03-02 Thread Jay Blanchard
[snip]
 I'm not saying you should get rid of the recursive function calls, but 
 rather, why not pull all your data in one SQL call, then use recursive 
 functions on the returned array of data.  It will save a little time by not 
 hitting the DB on each function call too.
 [/snip]

I'll just need to wrap my head around using a recursive function to iterate 
through the array.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Nested database loops and completing an unordered list....

2012-03-01 Thread Jay Blanchard

Good morning PHP groupies!

I am working on this tool that will ultimately display a collapsible org 
chart. The org chart is based on a nested unordered list and that is the 
heart of my question.


The NUL(nested unordered list) is based on a set of database queries - 
sometimes as many as 14 queries. Each query relies on data returned by 
all of the the queries before it. So what I am doing right now is this -


query generates a list item
while this list item get the next level dependent upon this item
query generates this list item
while this list item get the next level dependent on 
each list item above


...and so on. (I have written about this before and thought I had it 
solved, but alas, that is not the case.) The result needs to be 
something like this:


ul
lilevel a
ul
lilevel b/li // has no children
lilevel b
ul
lilevel c/li
/ul
/li
/ul
/li
/ul

This is a semantically and syntacticallycorrect UL. Keep in mind that 
this can go many levels deeper. The hardest part, and the part that I am 
looking to accomplish, is closing the list items properly regardless of 
how deep the tree is. If properly handled this could even be made into 
JSON with the proper syntax, but I am not worried about that now. I was 
hoping that a fresh set of eyes would point me to a solution that I 
obviously cannot see at the moment.


Thanks!

Jay

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



Re: [PHP] Nested database loops and completing an unordered list....

2012-03-01 Thread Jay Blanchard
Thanks FeIn, I'll give these articles and methods a look this afternoon. 
I'm sure that it will lead to more questions, so I'll be back.


On 3/1/2012 9:16 AM, FeIn wrote:
And see also this, which focuses only on the database part of the 
problem: 
http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/


On Thu, Mar 1, 2012 at 5:08 PM, FeIn aci...@gmail.com 
mailto:aci...@gmail.com wrote:


I don't how how you keep your data in your database but there is
no need to issues that many queries to retrieve your data. From
what I understand the data you want to display is hierarchical.
Here's an article that will hopefully point you to a solution
(there are more out there, some better than other, google mysql
hierchical data or database hierarchical data). The article I was
talking about is here:
http://www.sitepoint.com/hierarchical-data-database/





Re: [PHP] Nested database loops and completing an unordered list....

2012-03-01 Thread Jay Blanchard

On 3/1/2012 9:59 AM, Jay Blanchard wrote:
Thanks FeIn, I'll give these articles and methods a look this 
afternoon. I'm sure that it will lead to more questions, so I'll be back.


I also forgot to say that I cannot modify the database structure - the 
client is very strict about that. But it does look like the adjacency 
list model - each records list each of its tiers from 1 to 14.


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



Re: [PHP] Nested database loops and completing an unordered list....

2012-03-01 Thread Jay Blanchard
[snip]…stuff…[/snip]

I am getting close, but I am also getting frustrated. I probably need to walk 
away for a bit.

I have an array of tiers….

Array
(
[0] = TIER1DATA
[1] = TIER2DATA
[2] = TIER3DATA
[3] = BUSTIER1DATA
[4] = BUSTIER2DATA
[5] = BUSTIER3DATA
[6] = BUSTIER4DATA
)
Each of the tiers which represent parents in children in pairs. TIER1DATA is 
the parent of TIER2DATA, etc. representing 7 columns of data. Here is my code 
so far - any insight would be valuable and extremely appreciated by me.

function display_children($i, $child) {
global $dbc;
global $tierArray;
echo $i.br /;
/* retrieve children of parent */
$get = SELECT DISTINCT `. $tierArray[$i] .` FROM `POSITION_SETUP` ;
$get .= WHERE `COMPANY_ID` = '3' ;
if($i  0) {
$get .= AND ` . $tierArray[$i - 1] . ` = ' . $child . ' ;
}
echo $get.br /;
if(!($result = mysql_query($get, $dbc))) {
echo mysql_errno() . \t . mysql_error() . \n;
exit();
}

while($row = mysql_fetch_array($result)) {

/* indent and display the title of this child */
echo str_repeat('nbsp;',$i).$row[$tierArray[$i]].br /\n;

/* get the children's children */
display_children($i + 1, $row[$tierArray[$i]]);
}
}

It does produce the right query for only the first child in each case, I cannot 
get it to go deeper. I have just been looking at it for too long. TVMIA!

Re: [PHP] Nested database loops and completing an unordered list....

2012-03-01 Thread Jay Blanchard

On Mar 1, 2012, at 6:36 PM, Jay Blanchard wrote:

 [snip]…stuff…[/snip]
 
 I am getting close, but I am also getting frustrated. I probably need to walk 
 away for a bit.
 
 I have an array of tiers….
 
 Array
 (
[0] = TIER1DATA
[1] = TIER2DATA
[2] = TIER3DATA
[3] = BUSTIER1DATA
[4] = BUSTIER2DATA
[5] = BUSTIER3DATA
[6] = BUSTIER4DATA
 )
 Each of the tiers which represent parents in children in pairs. TIER1DATA is 
 the parent of TIER2DATA, etc. representing 7 columns of data. Here is my code 
 so far - any insight would be valuable and extremely appreciated by me.
 
 function display_children($i, $child) {
   global $dbc;
   global $tierArray;
   echo $i.br /;
   /* retrieve children of parent */
   $get = SELECT DISTINCT `. $tierArray[$i] .` FROM `POSITION_SETUP` ;
   $get .= WHERE `COMPANY_ID` = '3' ;
   if($i  0) {
   $get .= AND ` . $tierArray[$i - 1] . ` = ' . $child . ' ;
   }
   echo $get.br /;
   if(!($result = mysql_query($get, $dbc))) {
   echo mysql_errno() . \t . mysql_error() . \n;
   exit();
   }
   
   while($row = mysql_fetch_array($result)) {
   
   /* indent and display the title of this child */
   echo str_repeat('nbsp;',$i).$row[$tierArray[$i]].br /\n;
   
   /* get the children's children */
   display_children($i + 1, $row[$tierArray[$i]]);
   }
 }
 
 It does produce the right query for only the first child in each case, I 
 cannot get it to go deeper. I have just been looking at it for too long. 
 TVMIA!

Forgot to say that if I isolate any one level without recursion I get all of 
the results for that level.


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



Re: [PHP] Nested database loops and completing an unordered list....

2012-03-01 Thread Jay Blanchard

On Mar 1, 2012, at 7:45 PM, Jim Lucas wrote:

 On 03/01/2012 04:39 PM, Jay Blanchard wrote:
 
 On Mar 1, 2012, at 6:36 PM, Jay Blanchard wrote:
 
 [snip]…stuff…[/snip]
 
 I am getting close, but I am also getting frustrated. I probably need to 
 walk away for a bit.
 
 I have an array of tiers….
 
 Array
 (
[0] =  TIER1DATA
[1] =  TIER2DATA
[2] =  TIER3DATA
[3] =  BUSTIER1DATA
[4] =  BUSTIER2DATA
[5] =  BUSTIER3DATA
[6] =  BUSTIER4DATA
 )
 Each of the tiers which represent parents in children in pairs. TIER1DATA 
 is the parent of TIER2DATA, etc. representing 7 columns of data. Here is my 
 code so far - any insight would be valuable and extremely appreciated by me.
 
 function display_children($i, $child) {
 global $dbc;
 global $tierArray;
 echo $i.br /;
 /* retrieve children of parent */
 $get = SELECT DISTINCT `. $tierArray[$i] .` FROM `POSITION_SETUP` ;
 $get .= WHERE `COMPANY_ID` = '3' ;
 if($i  0) {
 $get .= AND ` . $tierArray[$i - 1] . ` = ' . $child . ' ;
 }
 echo $get.br /;
 if(!($result = mysql_query($get, $dbc))) {
 echo mysql_errno() . \t . mysql_error() . \n;
 exit();
 }
 
 while($row = mysql_fetch_array($result)) {
 
 /* indent and display the title of this child */
 echo str_repeat('nbsp;',$i).$row[$tierArray[$i]].br /\n;
 
 /* get the children's children */
 display_children($i + 1, $row[$tierArray[$i]]);
 }
 }
 
 It does produce the right query for only the first child in each case, I 
 cannot get it to go deeper. I have just been looking at it for too long. 
 TVMIA!
 
 Forgot to say that if I isolate any one level without recursion I get all of 
 the results for that level.
 
 
 
 How are you calling this?  What are your initial arguments?
 
 What does your DB schema look like?
 
 Can you show a brief example of the data in the table?
  Dump: SELECT * FROM position_setup WHERE company_id='3'
 
 Can you show the output of the function above?

I initialize it by calling the function like this:

display_children(0, 0)

Each of the tiers is located in adjacent columns in a single table

tier1data, tier2data, tier 3 data……bustier1data, bustier2data…..

The array retrieves only the relevant tiers for this company and that is the 
output of that array at the top of my example.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Nested database loops and completing an unordered list....

2012-03-01 Thread Jay Blanchard
 [snip]
 Can you show the output of the function above?
 [/snip]

0
SELECT DISTINCT `TIER1DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' 
Executives and Management

Normally this query alone returns 9 rows of data. Each of these rows should be 
included in the next query where TIER1DATA = each of the nine in succession

1
SELECT DISTINCT `TIER2DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND 
`TIER1DATA` = 'Executives and Management' 
 Executives and ManagementLeadership
2
SELECT DISTINCT `TIER3DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND 
`TIER2DATA` = 'Executives and ManagementLeadership' 
  Executives and ManagementLeadershipManager
3
SELECT DISTINCT `BUSTIER1DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' 
AND `TIER3DATA` = 'Executives and ManagementLeadershipManager' 
   Knee
4
SELECT DISTINCT `BUSTIER2DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' 
AND `BUSTIER1DATA` = 'Knee' 
KneeDIV01
5
SELECT DISTINCT `BUSTIER3DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' 
AND `BUSTIER2DATA` = 'KneeDIV01' 
 KneeDIV01DEPT02
6
SELECT DISTINCT `BUSTIER4DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' 
AND `BUSTIER3DATA` = 'KneeDIV01DEPT02' 
  KneeDIV01DEPT02GRP04
7
SELECT DISTINCT `` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND 
`BUSTIER4DATA` = 'KneeDIV01DEPT02GRP04' 
1054Unknown column '' in 'field list' 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SimpleXML and the Single String (SOLVED)

2012-02-22 Thread Jay Blanchard

On 2/22/2012 8:32 AM, ma...@behnke.biz wrote:

  There is another nice way.
You can pass a second value to the simple xml constructor which is a class
name to be used instead of SimpleXMLElement.
You can write your own class that extends SimpleXMLElement and override the
magic methods to skip the casting

I don't really see a need to add an extra layer or class extension when 
casting works fine. Am I wrong? Why add several lines of code in an 
extension class?


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



Re: [PHP] SimpleXML and the Single String (SOLVED)

2012-02-22 Thread Jay Blanchard
 I don't really see a need to add an extra layer or class extension
 when casting works fine. Am I wrong? Why add several lines of code in
 an extension class?
 
 To keep the code readable?
 
 $value = $xml-node;
 
 vs.
 
 $value = (String)$xml-node;
 
 I like the first one. Plus you handle it to dynamically to the right type
 
 function __get($value)
 {
if is float return float casted value
if is boolean ...
and so on
 }

The code is no less readable my way, YMMV

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



Re: [PHP] Test

2012-02-21 Thread Jay Blanchard
It's like coming home, I knew I could count on certain of you to make 
light of this and that makes me strangely happy.


On 2/21/2012 7:55 AM, Tedd Sperling wrote:

On Feb 20, 2012, at 2:49 PM, Daniel Brown wrote:


On Mon, Feb 20, 2012 at 14:40, Bastienphps...@gmail.com  wrote:

Definitely doesn't work

The list works just fine, it's you goofs who need to work now!  ;-P

It still doesn't work and I didn't get this. :-)

Cheers,

tedd


_
tedd.sperl...@gmail.com
http://sperling.com




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



[PHP] Test

2012-02-20 Thread Jay Blanchard

Does this work?

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



Re: [PHP] Test

2012-02-20 Thread Jay Blanchard
I'll be darned - it finally works. What's up with that?

On Feb 20, 2012, at 1:49 PM, Daniel Brown wrote:

 On Mon, Feb 20, 2012 at 14:40, Bastien phps...@gmail.com wrote:
 Definitely doesn't work
 
The list works just fine, it's you goofs who need to work now!  ;-P
 
 -- 
 /Daniel P. Brown
 Network Infrastructure Manager
 http://www.php.net/
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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



[PHP] SimpleXML and the Single String (SOLVED)

2012-02-20 Thread Jay Blanchard
Howdy,

My PHP chops are a little rough around the edges so I know that I am missing 
something. I am working with SimpleXML to retrieve values from an XML file like 
this - 

$xmlCompany = $xml-SignonRq-SignonTransport-CustId-SPName;

If I echo $xmlCompany I get the proper information.

If I use $xmlCompany as an array value though, I get this object - 

$arrayLead[0]-Company = $xmlCompany; // what I did
[Company] = SimpleXMLElement Object // what I got
(
[0] = Dadgummit
)
I tried casting AND THEN AS I TYPED THIS I figured it out...

$xmlCompany = array((string) $xml-SignonRq-SignonTransport-CustId-SPName); 
// becomes an array
$arrayLead[0]-Company = $xmlCompany[0]; // gets the right bit of the array

and the result is

 [Company] = Dadgummit
Thanks for bearing with me!






RE: [PHP] Fwd: ezmlm warning

2011-07-20 Thread Jay Blanchard
[snip]
I got it too, so its not just limited to gmail. Maybe a server in
between not working correctly. I'm in the UK, are the rest of you who
had problems this way too?
[/snip]

I'm in Texas and got it.

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



RE: [PHP] best ways to recruit volunteers for a PHP framework

2011-06-28 Thread Jay Blanchard
[snip]
I have developed an ORM framework in PHP for the last 2 years and it's
becoming a more professional and nice solution so before doing a
new complete revamp I am going to look for volunteer developers to do a
real
good version.
[/snip]

https://github.com/

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



RE: [PHP] php hide menu

2011-06-07 Thread Jay Blanchard
[snip]
I would like to pass the value from the prior menu to the next. Would
you please show me how to handle this?
[/snip]

As several have mentioned, this is a job for AJAX and JavaScript. Here
is a good tutorial:
http://www.yourinspirationweb.com/en/how-to-create-chained-select-with-p
hp-and-jquery/

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



RE: [PHP] iPhone sadness

2011-05-31 Thread Jay Blanchard
[snip]
I can remember when it first started, no moaning about this or that,
just pure PHP, and no sarcastic comments either, bring back the good old

days :)
[/snip]

I beg to differ - the sarcastic remarks have been here since day one. 

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



RE: [PHP] iPhone sadness WOT

2011-05-31 Thread Jay Blanchard
[snip]
 I beg to differ - the sarcastic remarks have been here since day one.

Yeah *SHSH* What was he thinking?!

;)
[/snip]

I know huh? Whatevs.

I added something to the subject so that those who don't want to read
these can send them to /dev/null appropriately.

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



RE: [PHP] How to change list settings

2011-05-31 Thread Jay Blanchard
[snip] 
How do I change my email settings to digest please as I am fed up with 
receiving all this individual crap that has nothing to do with PHP 
whatsoever.
[/snip]

http://lmgtfy.com/?q=php+mailing+list


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



RE: [PHP] How to change list settings

2011-05-31 Thread Jay Blanchard
[snip]
Yes I did. Perhaps you can show me the bit that I have missed that tells

me where I change my settings from receiving individual messages to 
receiving a digest format, rather than just sending out these links to 
something I have already said I looked at.
[/snip]

1. Look next to the list you wish to receive the digest (php-general)
from and you will find 2 radio selectors.

2. Scroll down to the bottom of the page and enter your email address.

3. Click subscribe.

Now you must unsubscribe from the full version of the list. In order to
do that you must click the following link and, read and follow the
instructions.

http://www.php.net/unsub.php



FROM THE ORIGINAL E-MAIL - 
-Original Message-
From: Alexis Antonakis [mailto:ad...@antonakis.co.uk] 
Sent: Tuesday, May 31, 2011 9:56 AM
To: Jay Blanchard
Subject: Re: [PHP] How to change list settings
On 31/05/11 08:51, Jay Blanchard wrote:
 Did you even read it? http://php.net/mailing-lists.php

 -Original Message-
 From: Alexis Antonakis [mailto:ad...@antonakis.co.uk]
 Sent: Tuesday, May 31, 2011 9:49 AM
 To: Jay Blanchard
 Subject: Re: [PHP] How to change list settings

 And how exactly does that TELL me how to change settings? I have
already

 used the automated emzlm help system but that does not say a thing on
 the subject

 On 31/05/11 08:47, Jay Blanchard wrote:
 [snip]
 How do I change my email settings to digest please as I am fed up
with
 receiving all this individual crap that has nothing to do with PHP
 whatsoever.
 [/snip]

 http://lmgtfy.com/?q=php+mailing+list






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



RE: [PHP] How to change list settings

2011-05-31 Thread Jay Blanchard
[snip]
Thanks for that straight forward response, shame other people cannot do 
likewise ;)
[/snip]

The real shame is that folks cannot RTFI :)

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



  1   2   3   4   5   6   7   8   9   10   >