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
On 03/01/2012 06:20 PM, Jay Blanchard wrote:
[snip]
Can you show the output of the function above?
[/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?
At this point,
On Fri, Mar 2, 2012 at 7:43 AM, Jay Blanchard
jay.blanch...@sigmaphinothing.org wrote:
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
[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
[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:
On 03/02/2012 08:27 AM, Jay Blanchard wrote:
[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
[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
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
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
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 wrote:
I don't how how you keep your data in your database but there is no need
to issues that
On Thu, Mar 1, 2012 at 6:29 AM, Jay Blanchard
jay.blanch...@sigmaphinothing.org wrote:
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
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:
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
[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] =
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
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
On Thu, Mar 1, 2012 at 4:36 PM, Jay Blanchard
jay.blanch...@sigmaphinothing.org 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] =
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….
[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 =
On 2012-03-01, at 9:20 PM, Jay Blanchard jay.blanch...@sigmaphinothing.org
wrote:
[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
Anyone ever do a nested for loop?
$i =0;
$j =0;
for ($x=0; $x 50; $x++){
echo (1 to 50);
for ($j=0: $j 5; $j++) {
echo (less than 5);
}
}
I haven't seen a nested loop in PHP, so I'm not sure of the exact syntax.
thanks
--
PHP General Mailing List
your syntax is correct, just need to change for ($j=0: $j 5; $j++) to
for ($j=0; $j 5; $j++)
Micah Montoy [EMAIL PROTECTED] 07/09/03 12:56PM
Anyone ever do a nested for loop?
$i =0;
$j =0;
for ($x=0; $x 50; $x++){
echo (1 to 50);
for ($j=0: $j 5; $j++) {
echo (less
Hi,
I did one once. It was similar to what you typed out here. Are you having
troubles with this?
-Dan Joseph
-Original Message-
From: Micah Montoy [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 1:56 PM
To: [EMAIL PROTECTED]
Subject: [PHP] nested for loops
Also u can do nested foreach loops too...
Example:
while( $row = mysql_fetch_array( $result ) ) {
$rows[] = $row;
}
foreach( $rows as $row ) {
foreach( $row as $i = $value ) {
// do stuff here
echo $i = $value\n;
}
}
I do this tons...
--
bigdog
On Wed,
I did it similar but calling some variables and it would never work. I'll
give it a shot again and see what happens and if same thing, I'll post it.
thanks
Matt Matijevich [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
your syntax is correct, just need to change for ($j=0: $j 5;
On Wednesday, July 9, 2003, 8:56:17 PM, Micah wrote:
[ snip ]
MM for ($j=0: $j 5; $j++) {
that : needs to be a ;
[ snip ]
--
Regards,
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
Well, the for loop is now working but its not displaying what I want. I am
pulling data from a DB and for every new td I would like to get the next
result and if it reaches more then 2 columns, to start a new row. This I am
not initally having a problem with. That is the looping. The problem I
You're getting the data from your query outside of your loop. That needs to
be part of your loop, otherwise, as you've seen, it just displays the first
record. You could try something like this:
$cnt = 0;
while ($row = mysql_fetch_object($result))
{
echo td$row-file_name/tdtd$row-file_id/td;
snip
$result = mssql_query(SELECT * FROM files WHERE file_id = '$cat_name'
ORDER
BY file_name ASC);
$i = $col_num;
$j = 0;
$filename= mssql_result($result,0,file_name);
$fileID = mssql_result($result,0,file_id);
for ($k = 0; $k mssql_num_rows($result); $k++) {
//changes row color
if
Hi all,
I'm aware that this post is borderline MySQL, but the solution may be more
PHP-oriented, so I'm asking here first.
I have 4 related tables:
partner (id,name,url,desc)
category (id,name)
service (id,categoryid,name)
pid_to_sid (pid,sid)
To point out the obvious, a partner provides one
mailto:[EMAIL PROTECTED]
- Original Message -
From: Justin French [EMAIL PROTECTED]
To: php [EMAIL PROTECTED]
Sent: Thursday, January 23, 2003 11:26 AM
Subject: [PHP] nested queries/loops
Hi all,
I'm aware that this post is borderline MySQL, but the solution may be more
PHP-oriented
For me it seems it can be done with one mysql query:
SELECT * FROM partner p LEFT JOIN pid_to_sid p2s ON p.id=p2s.pid LEFT
JOIN service s ON p2s.sid=s.id LEFT JOIN category c ON s.categoryid=c.id
WHERE $your_conditions ORDER BY p.name, c.name, s.name
The important part is ORDER BY clause, so
Thanks Marek, That put me right on track :)
Justin
on 23/01/03 11:24 PM, Marek Kilimajer ([EMAIL PROTECTED]) wrote:
SELECT * FROM partner p LEFT JOIN pid_to_sid p2s ON p.id=p2s.pid LEFT
JOIN service s ON p2s.sid=s.id LEFT JOIN category c ON s.categoryid=c.id
WHERE $your_conditions ORDER BY
Howdy Y'all!
I'm trying to figure out why I'm having so much difficulty with
nested for loops.
As a test, I did this and it doesn't work. The script simply doesn't
give any output.
?
error_reporting(E_ALL);
for( $i=0; $i10; $i++ )
for( $j=0; $j10; $j++ )
{
$res = $i * $j;
A copy and paste into foo.php and then a php -q foo.php yielded results for
me.
--Joe
On Fri, Apr 06, 2001 at 10:44:59AM -0600, [EMAIL PROTECTED] wrote:
Howdy Y'all!
I'm trying to figure out why I'm having so much difficulty with
nested for loops.
As a test, I did this and it doesn't
I cut and pasted your code and it worked fine - ???
kirk
As a test, I did this and it doesn't work. The script simply doesn't
give any output.
?
error_reporting(E_ALL);
for( $i=0; $i10; $i++ )
for( $j=0; $j10; $j++ )
{
$res = $i * $j;
print(" result = $res br");
Joe Stump wrote:
A copy and paste into foo.php and then a php -q foo.php yielded results for
me.
Yeah, it's giving me results too today. I don't know what went wrong
yesterday.
To extend my question, I'm trying to work with multidimensional arrays.
For example, I would like to do this:
You just do something like this:
?
$arr = array(0,23,4,2,1);
for($i = 0 ; $i 10 ; ++$i)
$arrB[] = $arr;
while(list(,$my_array) = each($arrB))
while(list($key,$val) = each($my_array))
echo $key.' - '.$val."\n";
?
Just throw arrays into arrays :O)
--Joe
On Fri, Apr
While it's apparently not always required, I always reccommend (and always
do it personally) that you use a bracket around every function.
So it should lool like this:
?
error_reporting(E_ALL);
for( $i=0; $i10; $i++ )
{
for( $j=0; $j10; $j++ )
{
$res = $i * $j;
print("
39 matches
Mail list logo