php-general Digest 4 Jun 2006 16:16:38 -0000 Issue 4166

2006-06-04 Thread php-general-digest-help

php-general Digest 4 Jun 2006 16:16:38 - Issue 4166

Topics (messages 237334 through 237347):

Re: Delete
237334 by: benifactor
237335 by: Rabin Vincent
237337 by: George Babichev
237338 by: Larry Garfield
237339 by: Rabin Vincent
237341 by: tedd

Re: php java intregration
237336 by: Rabin Vincent

How do I make a HTML tree for a set of nodes?
237340 by: Niels
237342 by: tedd
237343 by: Niels
237344 by: tedd
237345 by: Niels
237346 by: Martin Alterisio
237347 by: Mike Bellerby

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

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


--
---BeginMessage---
when you insert each blog into your database, im assuming your not doing
this by hand each and every time, assign each blog an id.

in the place you want to delete the blog entries, list all of the blogs
titles and ids.
and then use mysql(delete);

example:
?
//create a variable for the delete blog entry of you control panel
if ($view == delete_blog) {
//this should be the value of your submit button
if ($deleteBlog) {
//this is the value of the blog entries to delete
if (!$idblog) {
//this is your error message, to be displayed if no blog was
chosen to delete
$de = font face=tahoma color=black size=1You Need To
Choose a post to delete/font;
 }
else {
//list the values of the array in which all the blog entries
you would like to delete are
$delBlog = implode(,, $idblog);
//do the actual deletion
mysql_query(delete From blogs where id
IN($delBlog)) or die(mysql_error());
//display the succesfull message if the blog
entries were deleted
echo(font face=tahoma color=black
size=1bcenterblog(s):/b $delBlog bhas/have been
deleted;/b/b/center);

//now we display the blog entries
//plus the sucsessfull message
?

form method=post
?php
$gn = mysql_query(Select * FROM blogs);
while ($d = mysql_fetch_array($gn)) {
?
INPUT TYPE=checkbox NAME=idBlog[] VALUE=? echo($d[id]); ??
echo(font face=tahoma color=black size=1bPost id:/b $d[id]b;/b
bPost Title:/b $d[title]b;/b bPosted by:/b
$d[poster]b;/bbr); ?
?php
 }
?
brbrinput type=submit name=deleteNerd value=Delete
class=button
/form
?php
}
}
else {
//display blog entries only
?
form method=post
?php
$gn = mysql_query(Select * FROM blogs);
while ($d = mysql_fetch_array($gn)) {
?
INPUT TYPE=checkbox NAME=idBlog[] VALUE=? echo($d[id]); ??
echo(font face=tahoma color=black size=1bPost id:/b $d[id]b;/b
bPost Title:/b $d[title]b;/b bPosted by:/b
$d[poster]b;/bbr); ?
?php
 }
?
brbrinput type=submit name=deleteNerd value=Delete class=button
/form
?php
}
?
this is a very rough example, however you should catch the drift, make your
id an array, implode that array and delete all the array data from the
database.

- Original Message - 
From: George Babichev [EMAIL PROTECTED]
To: PHP General list php-general@lists.php.net
Sent: Saturday, June 03, 2006 6:40 PM
Subject: [PHP] Delete


 Hello everyone! I wrote a blog application, but now for the admin panel, i
 am trying to add a feature to delete blog posts. It would show the title
of
 the post next to it, and have a delete link which would delete it. How
would
 I do this? I mean if I have multiple blog entry's, how would I delete them
 without using php my admin?

---End Message---
---BeginMessage---

On 6/4/06, George Babichev [EMAIL PROTECTED] wrote:

Hello everyone! I wrote a blog application, but now for the admin panel, i
am trying to add a feature to delete blog posts. It would show the title of
the post next to it, and have a delete link which would delete it. How would
I do this? I mean if I have multiple blog entry's, how would I delete them
without using php my admin?


Presumably, you have an id column in your blog posts table
which is the primary key. Then you can just delete posts by
doing something like:

mysql_query('DELETE FROM posts WHERE id = 2312');

Or if you want to delete multiple in one go

mysql_query('DELETE FROM posts WHERE id IN (23,34,12)');

Rabin
---End Message---
---BeginMessage---

Thank you for the help guys, but the I guess I kinda have another question.
So I do assign an id to each blog post, and it is auto_increment, so in my
blog delete page, it would display all the blog title's and a delete button
nex to it. So lets say I click delete on the third entry. How would my
program know to delete THAT entry and not another one?

On 6/3/06, benifactor [EMAIL PROTECTED] wrote:


when you insert each blog into your database, im assuming your not doing
this by hand each and every time, 

Re: [PHP] Delete

2006-06-04 Thread Larry Garfield
Make each button a separate form, with the id as a hidden value.  Like so:

div
form method='post'
pMy first entry/p
input type='hidden' name='id' value='1' /
input type='submit' value='Delete' /
/form
/div

div
form method='post'
pMy second entry/p
input type='hidden' name='id' value='2' /
input type='submit' value='Delete' /
/form
/div

Obviously you'd want something better formatted, but you get the idea.  Then 
on the receiving end, you'd simply DELETE FROM entries where id=$id;.  That 
is, AFTER you process and clean the submitted id value so that it's not an 
injection risk. :-)

On Sunday 04 June 2006 00:53, George Babichev wrote:
 Thank you for the help guys, but the I guess I kinda have another question.
 So I do assign an id to each blog post, and it is auto_increment, so in my
 blog delete page, it would display all the blog title's and a delete button
 nex to it. So lets say I click delete on the third entry. How would my
 program know to delete THAT entry and not another one?

 On 6/3/06, benifactor [EMAIL PROTECTED] wrote:
  when you insert each blog into your database, im assuming your not doing
  this by hand each and every time, assign each blog an id.
 
  in the place you want to delete the blog entries, list all of the blogs
  titles and ids.
  and then use mysql(delete);
 
  example:
  ?
  //create a variable for the delete blog entry of you control panel
  if ($view == delete_blog) {
  //this should be the value of your submit button
  if ($deleteBlog) {
  //this is the value of the blog entries to delete
  if (!$idblog) {
  //this is your error message, to be displayed if no blog
  was
  chosen to delete
  $de = font face=tahoma color=black size=1You Need To
  Choose a post to delete/font;
   }
  else {
  //list the values of the array in which all the blog
  entries
  you would like to delete are
  $delBlog = implode(,, $idblog);
  //do the actual deletion
  mysql_query(delete From blogs where id
  IN($delBlog)) or die(mysql_error());
  //display the succesfull message if the blog
  entries were deleted
  echo(font face=tahoma color=black
  size=1bcenterblog(s):/b $delBlog bhas/have been
  deleted;/b/b/center);
 
  //now we display the blog entries
  //plus the sucsessfull message
  ?
 
  form method=post
  ?php
  $gn = mysql_query(Select * FROM blogs);
  while ($d = mysql_fetch_array($gn)) {
  ?
  INPUT TYPE=checkbox NAME=idBlog[] VALUE=? echo($d[id]); ??
  echo(font face=tahoma color=black size=1bPost id:/b $d[id]b;/b
  bPost Title:/b $d[title]b;/b bPosted by:/b
  $d[poster]b;/bbr); ?
  ?php
  }
  ?
  brbrinput type=submit name=deleteNerd value=Delete
  class=button
  /form
  ?php
  }
  }
  else {
  //display blog entries only
  ?
  form method=post
  ?php
  $gn = mysql_query(Select * FROM blogs);
  while ($d = mysql_fetch_array($gn)) {
  ?
  INPUT TYPE=checkbox NAME=idBlog[] VALUE=? echo($d[id]); ??
  echo(font face=tahoma color=black size=1bPost id:/b $d[id]b;/b
  bPost Title:/b $d[title]b;/b bPosted by:/b
  $d[poster]b;/bbr); ?
  ?php
  }
  ?
  brbrinput type=submit name=deleteNerd value=Delete
  class=button
  /form
  ?php
  }
  ?
  this is a very rough example, however you should catch the drift, make
  your
  id an array, implode that array and delete all the array data from the
  database.
 
  - Original Message -
  From: George Babichev [EMAIL PROTECTED]
  To: PHP General list php-general@lists.php.net
  Sent: Saturday, June 03, 2006 6:40 PM
  Subject: [PHP] Delete
 
   Hello everyone! I wrote a blog application, but now for the admin
   panel,
 
  i
 
   am trying to add a feature to delete blog posts. It would show the
   title
 
  of
 
   the post next to it, and have a delete link which would delete it. How
 
  would
 
   I do this? I mean if I have multiple blog entry's, how would I delete
 
  them
 
   without using php my admin?

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] Delete

2006-06-04 Thread Rabin Vincent

On 6/4/06, Larry Garfield [EMAIL PROTECTED] wrote:

Make each button a separate form, with the id as a hidden value.  Like so:

div
form method='post'
pMy first entry/p
input type='hidden' name='id' value='1' /
input type='submit' value='Delete' /
/form
/div

[snip]

You may find it easier to generate links of the form
delete.php?id=1, etc. Then you won't have to use a seperate
form for each link. The id will be available in delete.php
in $_GET. The same sanity checking applies in this case too.

Rabin

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



[PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread Niels
Hi,


I have a set of nodes. Each node has a parent and so the set can be thought
of as a tree. I want to show that tree somehow on a webpage, served by PHP.
I cannot use Dot/Graphwiz for various reasons. What I'm looking for is an
output of DIVs or tablecells, showing the nodes and their connections. It's
not a trivial task, IMO, but doable. Possibly somebody has already made
something similiar, but I can't find anything on Google. Can anybody point
me to helpful information?

Thanks,
Niels

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



Re: [PHP] Delete

2006-06-04 Thread tedd
At 10:53 PM -0700 6/3/06, George Babichev wrote:
Thank you for the help guys, but the I guess I kinda have another question.
So I do assign an id to each blog post, and it is auto_increment, so in my
blog delete page, it would display all the blog title's and a delete button
nex to it. So lets say I click delete on the third entry. How would my
program know to delete THAT entry and not another one?

Your specific question of how to delete I am sure other will provide, but 
consider this idea.

If you have a page that shows blog entries, then why not have an admin page 
that shows exactly the same thing except if has check-boxes next to the posts? 
And, if you check any of those and click Submit, then those entries will be 
deleted from the database -- simple, plus you already have most of the code. :-)

I had a similar problem and was designing an admin page that would do the 
things I wanted (add/delete/alter items) when it dawned on me that all I needed 
was a check-box and a submit button added to my main display page.

As to how to delete and such, you may find this useful:

http://www.weberdev.com/get_example-384.html

hth's

tedd

-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread tedd
At 2:07 PM +0200 6/4/06, Niels wrote:
Hi,


I have a set of nodes. Each node has a parent and so the set can be thought
of as a tree. I want to show that tree somehow on a webpage, served by PHP.
I cannot use Dot/Graphwiz for various reasons. What I'm looking for is an
output of DIVs or tablecells, showing the nodes and their connections. It's
not a trivial task, IMO, but doable. Possibly somebody has already made
something similiar, but I can't find anything on Google. Can anybody point
me to helpful information?

Thanks,
Niels


What, a binary-tree or linked-list sort of thing?

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread Niels
On Sunday 04 June 2006 14:58, tedd wrote:

 At 2:07 PM +0200 6/4/06, Niels wrote:
Hi,


I have a set of nodes. Each node has a parent and so the set can be
thought of as a tree. I want to show that tree somehow on a webpage,
served by PHP. I cannot use Dot/Graphwiz for various reasons. What I'm
looking for is an output of DIVs or tablecells, showing the nodes and
their connections. It's not a trivial task, IMO, but doable. Possibly
somebody has already made something similiar, but I can't find anything on
Google. Can anybody point me to helpful information?

Thanks,
Niels
 
 
 What, a binary-tree or linked-list sort of thing?
 
 tedd

Not binary -- a node can have several children. Each node has an id and a
parentId. The actual structure isn't important and can easily be objects,
arrays-of-arrays or whatever is handy.

//Niels

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread tedd
At 3:03 PM +0200 6/4/06, Niels wrote:
On Sunday 04 June 2006 14:58, tedd wrote:

 At 2:07 PM +0200 6/4/06, Niels wrote:
Hi,


I have a set of nodes. Each node has a parent and so the set can be
thought of as a tree. I want to show that tree somehow on a webpage,
served by PHP. I cannot use Dot/Graphwiz for various reasons. What I'm
looking for is an output of DIVs or tablecells, showing the nodes and
their connections. It's not a trivial task, IMO, but doable. Possibly
somebody has already made something similiar, but I can't find anything on
Google. Can anybody point me to helpful information?

Thanks,
Niels


 What, a binary-tree or linked-list sort of thing?

 tedd

Not binary -- a node can have several children. Each node has an id and a
parentId. The actual structure isn't important and can easily be objects,
arrays-of-arrays or whatever is handy.

//Niels

You can dynamically generate a table and place text (and/or color) the cells 
that are nodes -- that would be my approach. You would need to know the width 
and depth of the tree and then just fill in the cells that are nodes.

hth's

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread Niels
On Sunday 04 June 2006 15:30, tedd wrote:

[snip]

 You can dynamically generate a table and place text (and/or color) the
 cells that are nodes -- that would be my approach. You would need to know
 the width and depth of the tree and then just fill in the cells that are
 nodes.
 
 hth's
 
 tedd

Yes, well... It's a tad more complicated I think. Yes, I can make a table,
finding the dimensions shouldn't be a big problem. Placing the nodes in the
right cells isn't as easy, and making the connections is downright
difficult.

A problem with using a table is that cells can't be individually sized.
However DIVs or TDs is a minor problem. The major problem is to walk
through the tree properly (recursively probably), and remember the
connections. And then rendering them...


Thank you for your answer,
Niels

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread Martin Alterisio

2006/6/4, Niels [EMAIL PROTECTED]:


Hi,


I have a set of nodes. Each node has a parent and so the set can be
thought
of as a tree. I want to show that tree somehow on a webpage, served by
PHP.
I cannot use Dot/Graphwiz for various reasons. What I'm looking for is an
output of DIVs or tablecells, showing the nodes and their connections.
It's
not a trivial task, IMO, but doable. Possibly somebody has already made
something similiar, but I can't find anything on Google. Can anybody point
me to helpful information?

Thanks,
Niels

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



I had a similar problem that, although it was with a binary tree, it can be
used with your tree. PHP doesn't like too much the use of recursion, but
this time recursion is the way to go (if you want to keep the code
maintainable). Hopefully the tree will not span deep enough to cause any
problems... (hopefully).

The function will receive a node and return a table representation of the
branch started by this tree, if you point this function to the root node
you'll have your table. In each cell it will have to indicate whether it is
empty, it has a node or a line connecting neighbor cells. One important
thing to define here is the way the function will organize the nodes in the
table, in my function the root node was at the top in the center.

First, the trivial case: if the node doesn't have children return a table
with one cell, the node itself.
Then, the recursive case: if the node have children, call the function with
those nodes and store the tables returned. According to the representation I
used, it calculated the combined width of those tables, created a new table
where the first row contained the parent node centered, the second line an
horizontal line from the column where the first children would be to the
column where the last children would be. Then it build the rest of the table
pasting together, horizontally, the tables of the children. Voila! a nice
table representation of the tree.


Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread Mike Bellerby

You could do it by dynamically generating an image.

Mike


Niels wrote:


On Sunday 04 June 2006 15:30, tedd wrote:

[snip]

 


You can dynamically generate a table and place text (and/or color) the
cells that are nodes -- that would be my approach. You would need to know
the width and depth of the tree and then just fill in the cells that are
nodes.

hth's

tedd
   



Yes, well... It's a tad more complicated I think. Yes, I can make a table,
finding the dimensions shouldn't be a big problem. Placing the nodes in the
right cells isn't as easy, and making the connections is downright
difficult.

A problem with using a table is that cells can't be individually sized.
However DIVs or TDs is a minor problem. The major problem is to walk
through the tree properly (recursively probably), and remember the
connections. And then rendering them...


Thank you for your answer,
Niels

 





Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread Niels
On Sunday 04 June 2006 18:37, Mike Bellerby wrote:

 You could do it by dynamically generating an image.
 
 Mike

[snip]

Yes. But how? I've settled for a simpler solution -- see my answer to Martin
Alterisio.

Thanks,
Niels

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread Niels
Hi!

On Sunday 04 June 2006 18:13, Martin Alterisio wrote:
[snip]

 I had a similar problem that, although it was with a binary tree, it can
 be used with your tree. PHP doesn't like too much the use of recursion,
 but this time recursion is the way to go (if you want to keep the code
 maintainable). Hopefully the tree will not span deep enough to cause any
 problems... (hopefully).
 
 The function will receive a node and return a table representation of the
 branch started by this tree, if you point this function to the root node
 you'll have your table. In each cell it will have to indicate whether it
 is empty, it has a node or a line connecting neighbor cells. One important
 thing to define here is the way the function will organize the nodes in
 the table, in my function the root node was at the top in the center.
 
 First, the trivial case: if the node doesn't have children return a table
 with one cell, the node itself.
 Then, the recursive case: if the node have children, call the function
 with those nodes and store the tables returned. According to the
 representation I used, it calculated the combined width of those tables,
 created a new table where the first row contained the parent node
 centered, the second line an horizontal line from the column where the
 first children would be to the column where the last children would be.
 Then it build the rest of the table pasting together, horizontally, the
 tables of the children. Voila! a nice table representation of the tree.

This sounds fine -- recursion is obviously the way to go. Where can I see
your function?

I tried several different solutions over the last couple of hours, and I've
settled on only using indentation (like a nested ul/ul list), not a
fancy graph with antialised branches. It's the simplest possible recursion
but I like the results, even if it's a bit harder to grasp without
connections clearly marked.


function tree($nodes, $start, $indent=-30) {
$indent+=30;
global $tree;
foreach ($nodes as $nodeID = $node) {
if ($node['parent']!=$start) {continue;}
$tree.=div 
style='margin-left:{$indent}px'{$node['name']}/div;
tree($nodes, $nodeID, $indent);
}
return $tree;
}



Thanks!

//Niels

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



[PHP] Re: How do I make a HTML tree for a set of nodes?

2006-06-04 Thread Rafael
	Well, if you're asking for some recommendation on how to show it, I 
would suggest to use lists (either ordered -OL- or unordered -UL- 
depends on you), or maybe even data-lists (DL), so you would get

  +- parent 1
  |  +- child 1
  |  \- child 2
  +- parent 2
 \- sub-parent1
+- sub-child 1
\- sub-child 2
into something like
  ul
li parent 1
 ul
   lichild 1/li
   lichild 2/li
 /ul
/li
li parent 2
 ul
   li sub-parent 1
ul
  lisub-child 1/li
  lisub-child 2/li
/ul
   /li
 /ul
/li
  /ul

	Now, if you're asking for code, send what you've tried so far, and 
maybe someone will be able to help you (either correcting your code, or 
sending another way to do it)


Niels wrote:

I have a set of nodes. Each node has a parent and so the set can be thought
of as a tree. I want to show that tree somehow on a webpage, served by PHP.
I cannot use Dot/Graphwiz for various reasons. What I'm looking for is an
output of DIVs or tablecells, showing the nodes and their connections. It's
not a trivial task, IMO, but doable. Possibly somebody has already made
something similiar, but I can't find anything on Google. Can anybody point
me to helpful information?

--
Atentamente / Sincerely,
J. Rafael Salazar MagaƱa

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread Martin Alterisio

2006/6/4, Niels [EMAIL PROTECTED]:


Hi!

On Sunday 04 June 2006 18:13, Martin Alterisio wrote:
[snip]

 I had a similar problem that, although it was with a binary tree, it can
 be used with your tree. PHP doesn't like too much the use of recursion,
 but this time recursion is the way to go (if you want to keep the code
 maintainable). Hopefully the tree will not span deep enough to cause any
 problems... (hopefully).

 The function will receive a node and return a table representation of
the
 branch started by this tree, if you point this function to the root node
 you'll have your table. In each cell it will have to indicate whether it
 is empty, it has a node or a line connecting neighbor cells. One
important
 thing to define here is the way the function will organize the nodes in
 the table, in my function the root node was at the top in the center.

 First, the trivial case: if the node doesn't have children return a
table
 with one cell, the node itself.
 Then, the recursive case: if the node have children, call the function
 with those nodes and store the tables returned. According to the
 representation I used, it calculated the combined width of those tables,
 created a new table where the first row contained the parent node
 centered, the second line an horizontal line from the column where the
 first children would be to the column where the last children would be.
 Then it build the rest of the table pasting together, horizontally, the
 tables of the children. Voila! a nice table representation of the tree.

This sounds fine -- recursion is obviously the way to go. Where can I see
your function?

I tried several different solutions over the last couple of hours, and
I've
settled on only using indentation (like a nested ul/ul list), not a
fancy graph with antialised branches. It's the simplest possible recursion
but I like the results, even if it's a bit harder to grasp without
connections clearly marked.


function tree($nodes, $start, $indent=-30) {
$indent+=30;
global $tree;
foreach ($nodes as $nodeID = $node) {
if ($node['parent']!=$start) {continue;}
$tree.=div
style='margin-left:{$indent}px'{$node['name']}/div;
tree($nodes, $nodeID, $indent);
}
return $tree;
}



Thanks!

//Niels

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



Sorry, I can't show you the code. Anyway you don't seem to need it. One
recommendation, don't rely on global vars, look at this:

function tree($nodes, $start, $indent=-30) {
   $indent+=30;
   $tree = ;
   foreach ($nodes as $nodeID = $node) {
   if ($node['parent']!=$start) {continue;}
   $tree .= div
style='margin-left:{$indent}px'{$node['name']}/div;
   $tree .= tree($nodes, $nodeID, $indent);
   }
   return $tree;
}


Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread tedd
At 3:38 PM +0200 6/4/06, Niels wrote:
On Sunday 04 June 2006 15:30, tedd wrote:

[snip]

 You can dynamically generate a table and place text (and/or color) the
 cells that are nodes -- that would be my approach. You would need to know
 the width and depth of the tree and then just fill in the cells that are
 nodes.

 hth's

 tedd

Yes, well... It's a tad more complicated I think. Yes, I can make a table,
finding the dimensions shouldn't be a big problem. Placing the nodes in the
right cells isn't as easy, and making the connections is downright
difficult.

A problem with using a table is that cells can't be individually sized.
However DIVs or TDs is a minor problem. The major problem is to walk
through the tree properly (recursively probably), and remember the
connections. And then rendering them...

I've done this before, but not with html.

My demo is at:

http://www.sperling.com/freeware.php

So, I have an idea of what's involved.

If this just for display, then it shouldn't be too difficult to display the end 
results in a table -- provided, you know in advance the largest any row will 
be. It will be a simple grid, unless you want to play with column spacing, 
which will be very difficult indeed to manage.

As for cells not being individually sized, you're right they can't be sized, 
but they do automatically size to their contents and that can be varied as well 
shown with different background colors.

Are you going to use this for something other than display, is it functional in 
some way? Because if you're going to add functionality, such as editing, 
deleting, sorting, then you have a big chore in front of you.

As for using recursive functions, absolutely -- they make the process (and 
code) much less. However, you need to wrap your mind around things spinning 
around to their conclusion, which is sometimes difficult to imagine.

Good luck.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread Niels
Hi,

On Sunday 04 June 2006 19:02, Martin Alterisio wrote:

[snip]
 Sorry, I can't show you the code. Anyway you don't seem to need it. One
 recommendation, don't rely on global vars, look at this:
Quite right, I'd have gotten around to fixing that later.

Thank you for your answer, I appreciate it!
Niels

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



Re: [PHP] Delete

2006-06-04 Thread Larry Garfield
On Sunday 04 June 2006 03:11, Rabin Vincent wrote:
 On 6/4/06, Larry Garfield [EMAIL PROTECTED] wrote:
  Make each button a separate form, with the id as a hidden value.  Like
  so:
 
  div
  form method='post'
  pMy first entry/p
  input type='hidden' name='id' value='1' /
  input type='submit' value='Delete' /
  /form
  /div

 [snip]

 You may find it easier to generate links of the form
 delete.php?id=1, etc. Then you won't have to use a seperate
 form for each link. The id will be available in delete.php
 in $_GET. The same sanity checking applies in this case too.

 Rabin

Only  if delete.php is a confirmation page.  Never ever ever have a delete 
function that operates solely by GET.

Here's why: http://thedailywtf.com/forums/thread/66166.aspx

:-)

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread Niels
Hi,

On Sunday 04 June 2006 19:08, tedd wrote:

 At 3:38 PM +0200 6/4/06, Niels wrote:
On Sunday 04 June 2006 15:30, tedd wrote:

[snip]

 You can dynamically generate a table and place text (and/or color) the
 cells that are nodes -- that would be my approach. You would need to
 know the width and depth of the tree and then just fill in the cells
 that are nodes.

 hth's

 tedd

Yes, well... It's a tad more complicated I think. Yes, I can make a table,
finding the dimensions shouldn't be a big problem. Placing the nodes in
the right cells isn't as easy, and making the connections is downright
difficult.

A problem with using a table is that cells can't be individually sized.
However DIVs or TDs is a minor problem. The major problem is to walk
through the tree properly (recursively probably), and remember the
connections. And then rendering them...
 
 I've done this before, but not with html.
 
 My demo is at:
 
 http://www.sperling.com/freeware.php
 
 So, I have an idea of what's involved.
 
 If this just for display, then it shouldn't be too difficult to display
 the end results in a table -- provided, you know in advance the largest
 any row will be. It will be a simple grid, unless you want to play with
 column spacing, which will be very difficult indeed to manage.
 
 As for cells not being individually sized, you're right they can't be
 sized, but they do automatically size to their contents and that can be
 varied as well shown with different background colors.
 
 Are you going to use this for something other than display, is it
 functional in some way? Because if you're going to add functionality, such
 as editing, deleting, sorting, then you have a big chore in front of you.
 
 As for using recursive functions, absolutely -- they make the process (and
 code) much less. However, you need to wrap your mind around things
 spinning around to their conclusion, which is sometimes difficult to
 imagine.
 
 Good luck.
 
 tedd

Thank you for your answer, I appreciate it!

Years ago I made Javascript navigation tree -- like a file browser, with
expandable branches and so on. It was a big problem to parse all the
relationships to img tags and links. I just had a looks at that code -- 10
years old, and it works! I couldn't change it to my current needs though.

As I said elsewhere on this thread, I've settled for a simple, indented
tree-view. Each node is a link and some text, and it's all reasonably easy
to understand. And it's a small function -- I know about the dangers of
recursion.

Choosing this simple layout will also make it easier to render the output to
PDF at a later stage.

If I were to make a real tree, I wouldn't use a table. It's too difficult
to manage IMO. I'd probably look for a generic graph algorithm somewhere,
and try some dhtml voodoo with flying DIVs.


Thanks again,
Niels

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



Re: [PHP] Delete

2006-06-04 Thread George Babichev

Yes, that checkbox idea is exactly what I was thinking about. Exept I have
no idea how my program would tell one checkbox from the other, and delete
the wrong thing...

On 6/4/06, tedd [EMAIL PROTECTED] wrote:


At 10:53 PM -0700 6/3/06, George Babichev wrote:
Thank you for the help guys, but the I guess I kinda have another
question.
So I do assign an id to each blog post, and it is auto_increment, so in
my
blog delete page, it would display all the blog title's and a delete
button
nex to it. So lets say I click delete on the third entry. How would my
program know to delete THAT entry and not another one?

Your specific question of how to delete I am sure other will provide,
but consider this idea.

If you have a page that shows blog entries, then why not have an admin
page that shows exactly the same thing except if has check-boxes next to the
posts? And, if you check any of those and click Submit, then those entries
will be deleted from the database -- simple, plus you already have most of
the code. :-)

I had a similar problem and was designing an admin page that would do the
things I wanted (add/delete/alter items) when it dawned on me that all I
needed was a check-box and a submit button added to my main display page.

As to how to delete and such, you may find this useful:

http://www.weberdev.com/get_example-384.html

hth's

tedd

--


http://sperling.com  http://ancientstones.com  http://earthstones.com



[PHP] When is z != z ?

2006-06-04 Thread tedd
Hi gang:

Here's your opportunity to pound me again for not knowing the basics of php.

I vaguely remember something like this being discussed a while back, but can't 
find the reference.

In any event, if one uses --

for ($i=a; $iz; $i++)
  {
  echo($i);
   }

-- it stops at y

But, if you use --

for ($i=a; $i=z; $i++)
  {
  echo($i);
   }

-- it prints considerably more characters after z than what one would 
normally expect -- why is that?

Just stopping at z would seem to make more sense, wouldn't it? After all, 
when $i = z in the first expression, then wouldn't $i be equal to z in the 
second expression and thus halt the operation?

What am I missing here?

Thanks.

tedd

-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Delete

2006-06-04 Thread tedd
At 10:30 AM -0700 6/4/06, George Babichev wrote:
Yes, that checkbox idea is exactly what I was thinking about. Exept I have no 
idea how my program would tell one checkbox from the other, and delete the 
wrong thing...

George:

You're going to have to play around with forms and find out how check-boxes 
work.

One you can figure out how to pass a confirm/not-confirm via a list of 
check-boxes, then we can proceed to the next step.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread tedd
At 7:26 PM +0200 6/4/06, Niels wrote:
If I were to make a real tree, I wouldn't use a table. It's too difficult
to manage IMO. I'd probably look for a generic graph algorithm somewhere,
and try some dhtml voodoo with flying DIVs.


Thanks again,
Niels

Niels:

The below link may not at first look like what you're after, but belive me, 
you'll find stuff that will make you think how you can use it to do what you 
want.

http://www.cssplay.co.uk/index.html

Happy exploring.

Using a combination of css and php will do what you want, I'm sure of it.

tedd


-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread Niels
On Sunday 04 June 2006 19:49, tedd wrote:

 At 7:26 PM +0200 6/4/06, Niels wrote:
If I were to make a real tree, I wouldn't use a table. It's too
difficult to manage IMO. I'd probably look for a generic graph algorithm
somewhere, and try some dhtml voodoo with flying DIVs.


Thanks again,
Niels
 
 Niels:
 
 The below link may not at first look like what you're after, but belive
 me, you'll find stuff that will make you think how you can use it to do
 what you want.
 
 http://www.cssplay.co.uk/index.html
 
 Happy exploring.
Very cool!!!
I've also started using the Javascript library from
http://script.aculo.us/ -- that certainly saves me a lot of headaches.
 
 Using a combination of css and php will do what you want, I'm sure of it.
I want world peace...


Thanks again,
Niels

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf

tedd wrote:

Hi gang:

Here's your opportunity to pound me again for not knowing the basics of php.

I vaguely remember something like this being discussed a while back, but can't 
find the reference.

In any event, if one uses --

for ($i=a; $iz; $i++)
  {
  echo($i);
   }

-- it stops at y

But, if you use --

for ($i=a; $i=z; $i++)
  {
  echo($i);
   }

-- it prints considerably more characters after z than what one would 
normally expect -- why is that?

Just stopping at z would seem to make more sense, wouldn't it? After all, when $i = z 
in the first expression, then wouldn't $i be equal to z in the second expression and thus halt 
the operation?

What am I missing here?


It's a bit of a quirk.  z++ is aa and aa  z.  I would guess 
this would loop until until just before za which would be yz.


It's a bit like looping through the hexadecimal characters.  You would 
have the same effect.  However instead of being base-16 with 0-9-a-f you 
have base-26 using a-z.


-Rasmus

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Martin Alterisio

2006/6/4, Rasmus Lerdorf [EMAIL PROTECTED]:


tedd wrote:
 Hi gang:

 Here's your opportunity to pound me again for not knowing the basics of
php.

 I vaguely remember something like this being discussed a while back, but
can't find the reference.

 In any event, if one uses --

 for ($i=a; $iz; $i++)
   {
   echo($i);
}

 -- it stops at y

 But, if you use --

 for ($i=a; $i=z; $i++)
   {
   echo($i);
}

 -- it prints considerably more characters after z than what one would
normally expect -- why is that?

 Just stopping at z would seem to make more sense, wouldn't it? After
all, when $i = z in the first expression, then wouldn't $i be equal to z
in the second expression and thus halt the operation?

 What am I missing here?

It's a bit of a quirk.  z++ is aa and aa  z.  I would guess
this would loop until until just before za which would be yz.



What?
z++  z returns true? =S
Is there a reason for this? Why aren't they handled like C chars?

It's a bit like looping through the hexadecimal characters.  You would

have the same effect.  However instead of being base-16 with 0-9-a-f you
have base-26 using a-z.



0xF++  would be 0x10 which is greater than 0xF (0xF  0x10). It's not the
same.

-Rasmus


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




Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread tedd
At 8:00 PM +0200 6/4/06, Niels wrote:

 
 Using a combination of css and php will do what you want, I'm sure of it.
I want world peace...

Well, if we were all programming php, we wouldn't have any war, but we wouldn't 
have any peace either.  :-)

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf

Martin Alterisio wrote:

2006/6/4, Rasmus Lerdorf [EMAIL PROTECTED]:


tedd wrote:
 Hi gang:

 Here's your opportunity to pound me again for not knowing the basics of
php.

 I vaguely remember something like this being discussed a while back, 
but

can't find the reference.

 In any event, if one uses --

 for ($i=a; $iz; $i++)
   {
   echo($i);
}

 -- it stops at y

 But, if you use --

 for ($i=a; $i=z; $i++)
   {
   echo($i);
}

 -- it prints considerably more characters after z than what one would
normally expect -- why is that?

 Just stopping at z would seem to make more sense, wouldn't it? After
all, when $i = z in the first expression, then wouldn't $i be equal 
to z

in the second expression and thus halt the operation?

 What am I missing here?

It's a bit of a quirk.  z++ is aa and aa  z.  I would guess
this would loop until until just before za which would be yz.



What?
z++  z returns true? =S
Is there a reason for this? Why aren't they handled like C chars?


Because PHP is not C.  If you want them handled by their char codes, 
then do so with chr() calls.



It's a bit like looping through the hexadecimal characters.  You would

have the same effect.  However instead of being base-16 with 0-9-a-f you
have base-26 using a-z.



0xF++  would be 0x10 which is greater than 0xF (0xF  0x10). It's not the
same.


Sure it is.  If you treat 0x10 as a string the same way he is treating 
these as strings, then 0x10 is going to be smaller than 0xF.


The fact is that there is just no right answer for what z++ should do.

-Rasmus

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread Niels
On Sunday 04 June 2006 20:39, tedd wrote:

 At 8:00 PM +0200 6/4/06, Niels wrote:

 
 Using a combination of css and php will do what you want, I'm sure of
 it.
I want world peace...
 
 Well, if we were all programming php, we wouldn't have any war, but we
 wouldn't have any peace either.  :-)
 
 tedd

There's always the good old Vi / Emacs war, if we get bored...


//Niels

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Martin Alterisio

2006/6/4, Rasmus Lerdorf [EMAIL PROTECTED]:


Martin Alterisio wrote:
 2006/6/4, Rasmus Lerdorf [EMAIL PROTECTED]:

 tedd wrote:
  Hi gang:
 
  Here's your opportunity to pound me again for not knowing the basics
of
 php.
 
  I vaguely remember something like this being discussed a while back,
 but
 can't find the reference.
 
  In any event, if one uses --
 
  for ($i=a; $iz; $i++)
{
echo($i);
 }
 
  -- it stops at y
 
  But, if you use --
 
  for ($i=a; $i=z; $i++)
{
echo($i);
 }
 
  -- it prints considerably more characters after z than what one
would
 normally expect -- why is that?
 
  Just stopping at z would seem to make more sense, wouldn't it?
After
 all, when $i = z in the first expression, then wouldn't $i be equal
 to z
 in the second expression and thus halt the operation?
 
  What am I missing here?

 It's a bit of a quirk.  z++ is aa and aa  z.  I would guess
 this would loop until until just before za which would be yz.


 What?
 z++  z returns true? =S
 Is there a reason for this? Why aren't they handled like C chars?

Because PHP is not C.  If you want them handled by their char codes,
then do so with chr() calls.



That's cool, but you missed my point, I was just wondering why the ++
operator for string was handled that way. I used the C comparison becuase
it's more usual for coders to think as chars in terms of their position in
the ASCII table, allowing loops such as the mentioned above. I'm not trying
to start another witch hunt, there are enough rantings around for that
purpose.


It's a bit like looping through the hexadecimal characters.  You would
 have the same effect.  However instead of being base-16 with 0-9-a-f
you
 have base-26 using a-z.


 0xF++  would be 0x10 which is greater than 0xF (0xF  0x10). It's not
the
 same.

Sure it is.  If you treat 0x10 as a string the same way he is treating
these as strings, then 0x10 is going to be smaller than 0xF.

The fact is that there is just no right answer for what z++ should do.

-Rasmus



Still:
anything  ++anything
should be true, or at least that's what they taught me on abstract data
types design, and I think they're right (at least this time)


Re: [PHP] When is z != z ?

2006-06-04 Thread tedd
At 11:08 AM -0700 6/4/06, Rasmus Lerdorf wrote:
tedd wrote:
But, if you use --

for ($i=a; $i=z; $i++)
  {
  echo($i);
   }

-- it prints considerably more characters after z than what one would 
normally expect -- why is that?

Just stopping at z would seem to make more sense, wouldn't it? After all, 
when $i = z in the first expression, then wouldn't $i be equal to z in 
the second expression and thus halt the operation?

What am I missing here?

It's a bit of a quirk.  z++ is aa and aa  z.  I would guess this 
would loop until until just before za which would be yz.

It's a bit like looping through the hexadecimal characters.  You would have 
the same effect.  However instead of being base-16 with 0-9-a-f you have 
base-26 using a-z.

-Rasmus

-Rasmus:

Ahhh -- I see -- sort of.

However, if it has to be a base then it's more like base-676, going from a to 
yz. Like DEC has 10 elements and HEX has 16 elements, this has 676 elements.

But, what brothers me about the routine, is that is DOES print z where it is 
supposed to. In other words, the characters a-z are output before continuing 
with aa and so on. The operation doesn't end with z.

Shouldn't the expression $i =z be true when $i=z and if $i is greater, then 
be false?

For example, please review:

http://xn--ovg.com/a1.php

You can here that when $i = z, then the condition is true and it prints 
Look. One would think that anything greater than that point would be false 
and thus end the loop. But here we have an example of how we can have something 
equal to something and then by adding 1 to it, it becomes smaller. That's not 
logical.

Furthermore, if it was to work like a base, then I would expect z to the the 
last character, not the 26th.

Here's another way to look at it. All characters before z are less than z 
-- correct? So, what value are all characters after z (i.e., aa-yz)? They 
cannot be greater than, nor can they be less than. So, what are they?

tedd

PS: It was just a day, or so ago, that I said I didn't want disagree with you 
and now what have you got me into? running for cover looking for rock to 
program with
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-04 Thread tedd
At 8:59 PM +0200 6/4/06, Niels wrote:
On Sunday 04 June 2006 20:39, tedd wrote:

 At 8:00 PM +0200 6/4/06, Niels wrote:


 Using a combination of css and php will do what you want, I'm sure of
 it.
I want world peace...

 Well, if we were all programming php, we wouldn't have any war, but we
 wouldn't have any peace either.  :-)

 tedd

There's always the good old Vi / Emacs war, if we get bored...

Out of the xml camp, I liked this expression.

/world

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf

tedd wrote:

But, what brothers me about the routine, is that is DOES print z where it is supposed 
to. In other words, the characters a-z are output before continuing with aa and so on. The 
operation doesn't end with z.


Your condition for the loop to continue is $i=z.

When $i = y it will obviously continue because y  z
When $i = z it will obviously continue because z = z
When $i = aa it will obviously continue because aa  z

It doesn't stop until you get to z+something.  As in za because at 
that point za  z so the last thing you see is the one before za 
which would be yz.



Here's another way to look at it. All characters before z are less than z -- correct? So, what 
value are all characters after z (i.e., aa-yz)? They cannot be greater than, nor can they be 
less than. So, what are they?


But you are not comparing things in the same context here.  Strings are 
naturally compared alphabetically while you are thinking they are 
compared numerically somehow.  Think of sorting a set of words.  Would 
you expect aa to sort before or after z ?


So yes, like I said, it is a bit of a quirk, but there is no good answer 
to what z++ should be and we certainly don't want to change the 
default comparison mechanism to not compare strings alphabetically 
because that would screw up all sorts of stuff including usorts and 
peoples' expectations.  It's just in this case where you have gotten it 
into your head that incrementing strings is a good thing to do.


You'd be much better off with a range call to quickly generate a range 
of characters.  You could then loop through that character by character. 
 Or use the chr() function to work with character codes instead.


-Rasmus

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf

Martin Alterisio wrote:


Still:
anything  ++anything
should be true, or at least that's what they taught me on abstract data
types design, and I think they're right (at least this time)


In loosely typed languages that is not always true.  Operators have to 
guess at the type and try to do what the user expects.  There will 
always be edge cases.  Being able to increment strings is pretty handy 
when you need to create sequences for unique file and directory names.


For example, this also works:

$filename = file1;
$filename++;
echo $filename;

You would get file2 from this.  Think about the amount of code you 
would need to write in C to make that work?


Then change $filename to fileA and increment it.  And you get fileB. 
 When we get to fileZ we don't want to go off into unprintable 
character land, we want to try to stick with the pattern.


-Rasmus

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Martin Alterisio

2006/6/4, Rasmus Lerdorf [EMAIL PROTECTED]:


Martin Alterisio wrote:

 Still:
 anything  ++anything
 should be true, or at least that's what they taught me on abstract data
 types design, and I think they're right (at least this time)

In loosely typed languages that is not always true.  Operators have to
guess at the type and try to do what the user expects.  There will
always be edge cases.  Being able to increment strings is pretty handy
when you need to create sequences for unique file and directory names.

For example, this also works:

$filename = file1;
$filename++;
echo $filename;

You would get file2 from this.  Think about the amount of code you
would need to write in C to make that work?

Then change $filename to fileA and increment it.  And you get fileB.
  When we get to fileZ we don't want to go off into unprintable
character land, we want to try to stick with the pattern.

-Rasmus



I still don't see why this functionality should be a native operator of the
language.
It doesn't seem natural that ++ operator understands that the string could
be an enumeration of some kind. I believe that such things should be left to
the coder who knows what the string is really representing, not to the
language.


Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf

Martin Alterisio wrote:
I still don't see why this functionality should be a native operator of 
the language.
It doesn't seem natural that ++ operator understands that the string 
could be an enumeration of some kind. I believe that such things should 
be left to the coder who knows what the string is really representing, 
not to the language.


That's the strictly typed argument.  If you always force people to 
declare their types and you never automatically convert them, then you 
have a strictly typed language.  You have the same thing happening for 
something like:


 echo 2+3;

In a strictly typed language that would spew an error.  In a loosely 
typed language like PHP you get 5


And yes, I agree that ++ on strings is getting near the edge of that, 
but there has to be an edge somewhere and not everyone is going to agree 
on exactly where to draw the line.


-Rasmus

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



Re: [PHP] When is z != z ?

2006-06-04 Thread tedd
At 12:27 PM -0700 6/4/06, Rasmus Lerdorf wrote:
tedd wrote:
But, what brothers me about the routine, is that is DOES print z where it 
is supposed to. In other words, the characters a-z are output before 
continuing with aa and so on. The operation doesn't end with z.

Your condition for the loop to continue is $i=z.

[1] When $i = y it will obviously continue because y  z
[2] When $i = z it will obviously continue because z = z
[3] When $i = aa it will obviously continue because aa  z

I agree with [1] and [2], but [3] is where we part company. You see, if you are 
right, then aaa would also be less than z, but that doesn't appear so.

It doesn't stop until you get to z+something.  As in za because at that 
point za  z so the last thing you see is the one before za which would 
be yz.

See above -- plus, I would expect that in evaluating a character, that 
character(s) would not enter the mix. If I was to evaluate a single digit, it 
would seem odd if double digits were allowed in that evaluation.

Here's another way to look at it. All characters before z are less than z 
-- correct? So, what value are all characters after z (i.e., aa-yz)? They 
cannot be greater than, nor can they be less than. So, what are they?

But you are not comparing things in the same context here.  Strings are 
naturally compared alphabetically while you are thinking they are compared 
numerically somehow.  Think of sorting a set of words.  Would you expect aa 
to sort before or after z ?


Not meaning to infer that you don't know this, because I know you do -- so I 
must be confused.

Yes, it is my contention that strings are numerical -- you don't store A in 
memory, you store 0100 001, or ASCII DEC 65.

Likewise a is DEC 97 (0110 0001) and z is DEC 122 (0111 1010) and if I 
compare a to z , it will always be less by numeric definition.

However, if I compare aa with z, then what? Is the numerical translation of 
the strings --

0110 0001 0110 0001  0111 1010

equal to TRUE -- I don't think so.

Likewise, is the string aaa greater than z -- yep, I can buy that. But, if 
you hold that aa is less than z, then everything must be less than z 
(except z stuff). So, the loop would continue until you hit the maximum 
allowable for strings -- that doesn't sound good.

I can't see the logic that says aa is less than z while aaa is greater. 
That sounds like something our government would dream up.

So yes, like I said, it is a bit of a quirk, but there is no good answer to 
what z++ should be and we certainly don't want to change the default 
comparison mechanism to not compare strings alphabetically because that would 
screw up all sorts of stuff including usorts and peoples' expectations.  It's 
just in this case where you have gotten it into your head that incrementing 
strings is a good thing to do.

Oh, I'm not saying to change anything. I've seen and worked with worse.

You'd be much better off with a range call to quickly generate a range of 
characters.  You could then loop through that character by character.  Or use 
the chr() function to work with character codes instead.

I figured a way around it, I just thought it was odd.

Thanks for your insight.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] When is z != z ?

2006-06-04 Thread tedd
At 12:40 PM -0700 6/4/06, Rasmus Lerdorf wrote:
For example, this also works:

$filename = file1;
$filename++;
echo $filename;

You would get file2 from this.  Think about the amount of code you would 
need to write in C to make that work?

I would rather not. :-)

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf

tedd wrote:

At 12:27 PM -0700 6/4/06, Rasmus Lerdorf wrote:

tedd wrote:

But, what brothers me about the routine, is that is DOES print z where it is supposed 
to. In other words, the characters a-z are output before continuing with aa and so on. The 
operation doesn't end with z.

Your condition for the loop to continue is $i=z.

[1] When $i = y it will obviously continue because y  z
[2] When $i = z it will obviously continue because z = z
[3] When $i = aa it will obviously continue because aa  z


I agree with [1] and [2], but [3] is where we part company. You see, if you are right, then 
aaa would also be less than z, but that doesn't appear so.


Of course it is.

php -r 'echo aaa  z;'
1


Not meaning to infer that you don't know this, because I know you do -- so I 
must be confused.

Yes, it is my contention that strings are numerical -- you don't store A in 
memory, you store 0100 001, or ASCII DEC 65.

Likewise a is DEC 97 (0110 0001) and z is DEC 122 (0111 1010) and if I compare a to 
z , it will always be less by numeric definition.

However, if I compare aa with z, then what? Is the numerical translation of 
the strings --

0110 0001 0110 0001  0111 1010

equal to TRUE -- I don't think so.


No, but we are talking about collation here, not representation.

Likewise, is the string aaa greater than z -- yep, I can buy that. 


Well, it isn't.  So the bulk of your rant is rather meaningless.

-Rasmus

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



Re: [PHP] When is z != z ?

2006-06-04 Thread tedd
At 1:09 PM -0700 6/4/06, Rasmus Lerdorf wrote:
I agree with [1] and [2], but [3] is where we part company. You see, if you 
are right, then aaa would also be less than z, but that doesn't appear so.

Of course it is.

php -r 'echo aaa  z;'
1

You missed the point, why does --

for ($i=a; $i=z; $i++)
  {
  echo($i);
   }

-- not continue past aaa? Clearly, if aaa is less than z then why does 
the loop stop at yz?

In any event, I'll stop my rant now, I thought we were having a discussion.

tedd

-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Robert Cummings
On Sun, 2006-06-04 at 16:45, tedd wrote:
 At 1:09 PM -0700 6/4/06, Rasmus Lerdorf wrote:
 I agree with [1] and [2], but [3] is where we part company. You see, if you 
 are right, then aaa would also be less than z, but that doesn't appear 
 so.
 
 Of course it is.
 
 php -r 'echo aaa  z;'
 1
 
 You missed the point, why does --
 
 for ($i=a; $i=z; $i++)
   {
   echo($i);
}
 
 -- not continue past aaa? Clearly, if aaa is less than z then why does 
 the loop stop at yz?

Because right after 'yz' there is 'zz' and 'z' is neither less than nor
equal to 'zz'.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Robert Cummings
On Sun, 2006-06-04 at 16:53, Robert Cummings wrote:

  
  -- not continue past aaa? Clearly, if aaa is less than z then why 
  does the loop stop at yz?
 
 Because right after 'yz' there is 'zz' and 'z' is neither less than nor
 equal to 'zz'.

Err, that should say 'zz' is neither less than nor equal to 'z' :B

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Robert Cummings
On Sun, 2006-06-04 at 15:10, Martin Alterisio wrote:
 Still:
 anything  ++anything
 should be true, or at least that's what they taught me on abstract data
 types design, and I think they're right (at least this time)

There's always limitations :)

int main( char *argv[], int argc )
{
int i  = 0;
char c = 0x00;
char t = 0x00;

for( i = 0; i  129; i++ )
{
t = c;
++c;

if( t  c )
{
printf( Less than!\n );
}
else
{
printf( Not less than!\n );
}
}

return 0;
}

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] Garbage collection and strange session behaviour

2006-06-04 Thread BNR - IT Department
Hi,
Here is a simple script:

? // BEGIN OF A SCRIPT
/* #1 */ ini_set('session.gc_maxlifetime', '3');
/* #2 */ ini_set('session.gc_probability',1);
/* #3 */ ini_set('session.gc_divisor',1);
/* #4 */ sleep(5);
/* #5 */ session_start();

$sessvar = empty;
if (!isset($_SESSION['a_sess_string'])) { /* #6 */
/* #7 */ $_SESSION['a_sess_string']= abcd;
/* #8 */ echo This is a newly created session, so we put a fresh
variable in it!;
} else {
$sessvar = $_SESSION['a_sess_string'];
/* #9 */ print(We have sessvar = '.$sessvar.' here, so - Is the
session OK??? Maybe, but the session file '/tmp/sess_?' has been
deleted!);
}
/* #10 */ print(br.session_id(). -that's our session id, hmmm);
? // END OF A SCRIPT

The lines from #1 to #3 intentionally set these parameters to the garbage 
collector just to speed up the results of the problem.
#4 - we're sleeping 

So, after first run we have: after #5 - a new session, #7 puts a variable 
in the session and #8 tells us about that.
After #5 we also have the session file /tmp/sess_? written out
there anywhere.

On second run after #5 (we've been sleeping enough on #4 to have our
session announced old, ...dead-man-walking... - quotation from 'The
Green Mile' movie), the gc-monster is awaken and hungry for eating old
session files. Finally we have the session file /tmp/sess_? deleted 
by the garbage collector after #5.
That's guaranteed by #1 - #4.

[If we put another 'sleep' after /* #5 */session_start(),
we may have time to switch to '/tmp' directory and persuade ourselves
that there is no session file any more after the execution of #5.]

No session file - no session variables anymore, no session at all???
WRONG ANSWER!
We are sent to the 'else' clause, so $_SESSION['a_sess_string] is set
and alive , and its value - additionally - is the one before the session
file has gone (deleted) - abcd in my example.

Obviously 'session_start()' first fills all of the sesion variables into
memory, and after that shoots the garbage collector to go to finish its
cleaning work. The session file is deleted, but inside the session, in
our script, we are not acquainted with that... Until the end of script we 
are happy that everything is all right, but probably this self-confidence 
could lead us to some troubles later.

Is there a workaround? Without going to the file system to check if the
file still exists? A smart and elegant PHP session way, without any
if-file-exists-checking functions?

P.S. (To the administrators/moderators/whatever of this mailing list) - Please 
tell the people - write it somewhere on http://www.php.net/mailing-lists.php - 
that there is no chance to get subscribed if they are using any public mail 
address like @yahoo.com. It took me 2 days, I struggled like a pig with a 
pumpkin to find out...

-
Bulgarian National Radio
IT Department
(+359 2) 9336 615
BNR - Sofia, Bulgaria

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Larry Garfield
On Sunday 04 June 2006 15:04, tedd wrote:

 Yes, it is my contention that strings are numerical -- you don't store A
 in memory, you store 0100 001, or ASCII DEC 65.

In a low-level language like C, that matters.  One doesn't have strings, one 
has numbers that happen to map to a symbol.

In PHP and other high-level languages, strings are their own datatype.  They 
may or may not even be stored as standard ascii number codes in order 
internally.  You have to think of them as strings, not as numbers.  There are 
no numbers involved here.  There are only strings.  

 Likewise a is DEC 97 (0110 0001) and z is DEC 122 (0111 1010) and if I
 compare a to z , it will always be less by numeric definition.

In C or C++, yes.  In PHP, do not assume the same string-number mapping.  
Numeric definition is irrelevant.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Ryan A
clip
 There will  always be edge cases.  Being able to
increment
 strings is pretty handy  when you need to create
sequences for unique file
 and directory names.
 
 For example, this also works:
 
 $filename = file1;
 $filename++;
 echo $filename;
 
 You would get file2 from this.  Think about the
 amount of code you  would need to write in C to make
that work?
 
 Then change $filename to fileA and increment it. 
 And you get fileB. 
   When we get to fileZ we don't want to go off
 into unprintable 
 character land, we want to try to stick with the
 pattern.

/clip

Hmmm, didnt know about the $filename++; thingy, I used
to do things the hard (C) way. 
Learnt something new...thanks!

Cheers,
Ryan

--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



Re: [PHP] When is z != z ?

2006-06-04 Thread tedd
At 4:53 PM -0400 6/4/06, Robert Cummings wrote:
On Sun, 2006-06-04 at 16:45, tedd wrote:

  -- not continue past aaa? Clearly, if aaa is less than z then why 
  does the loop stop at yz?

Because right after 'yz' there is 'zz' and 'z' is neither less than nor
equal to 'zz'.

and

At 4:37 PM -0500 6/4/06, Larry Garfield wrote:
On Sunday 04 June 2006 15:04, tedd wrote:
 Likewise a is DEC 97 (0110 0001) and z is DEC 122 (0111 1010) and if I
 compare a to z , it will always be less by numeric definition.

In C or C++, yes.  In PHP, do not assume the same string-number mapping. 
Numeric definition is irrelevant.

It's a sign of genius to make the complicated simple. Learning new things about 
php every day.

Thank you both.

tedd

PS: Great language. -- thanks Lerdorf.
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] php, eclipse, dbg, oh my

2006-06-04 Thread Tod Thomas

Eclipse - 3.1.2
Linux   - 2.6.16-1.2111_FC4
PHP - 5.1.2, I built it.
DBG - 2.13.1, I tried the binary, then built it on my own
Apache  - 2.0.55, I built it. PHP is running as a module but I've 
configured Eclipse to use the standard PHP5 executable instead.



I wonder if anyone has gotten Eclipse debugging of PHP to work under 
Linux and if so what was used - dbg or some other tool?


I've read pretty much of the available documentation, and tried most of 
the contained suggestions but nothing has worked yet.  A lot of the 
suggestions are also geared towards windows users running Eclipse on 
that platform.


Everything seems to be firing up but I get no presentation in the 
debugger screen except for the console which indicates my program ran 
and all the breakpoints were ignored.


Any ideas?


Thanks - Tod

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf

tedd wrote:

At 1:09 PM -0700 6/4/06, Rasmus Lerdorf wrote:

I agree with [1] and [2], but [3] is where we part company. You see, if you are right, then 
aaa would also be less than z, but that doesn't appear so.

Of course it is.

php -r 'echo aaa  z;'
1


You missed the point, why does --

for ($i=a; $i=z; $i++)
  {
  echo($i);
   }

-- not continue past aaa? Clearly, if aaa is less than z then why does the loop 
stop at yz?


I thought I explained that a few times.  The sequence is:

a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab

Your loop stops at yz and doesn't get anywhere near aaa because za  z

-Rasmus

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



Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf

Larry Garfield wrote:

On Sunday 04 June 2006 15:04, tedd wrote:


Yes, it is my contention that strings are numerical -- you don't store A
in memory, you store 0100 001, or ASCII DEC 65.


In a low-level language like C, that matters.  One doesn't have strings, one 
has numbers that happen to map to a symbol.


In PHP and other high-level languages, strings are their own datatype.  They 
may or may not even be stored as standard ascii number codes in order 
internally.  You have to think of them as strings, not as numbers.  There are 
no numbers involved here.  There are only strings.  


Likewise a is DEC 97 (0110 0001) and z is DEC 122 (0111 1010) and if I
compare a to z , it will always be less by numeric definition.


In C or C++, yes.  In PHP, do not assume the same string-number mapping.  
Numeric definition is irrelevant.


Right, and now bring Unicode into the picture and this becomes even more 
true.


-Rasmus

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



Re: [PHP] Garbage collection and strange session behaviour

2006-06-04 Thread Rasmus Lerdorf
Are you actually hitting this race condition in the real world?  With a 
decently long maxlifetime setting I can't really see this being a 
realistic problem.  Remember the timer is reset on every access.


-Rasmus

BNR - IT Department wrote:

Hi,
Here is a simple script:

? // BEGIN OF A SCRIPT
/* #1 */ ini_set('session.gc_maxlifetime', '3');
/* #2 */ ini_set('session.gc_probability',1);
/* #3 */ ini_set('session.gc_divisor',1);
/* #4 */ sleep(5);
/* #5 */ session_start();

$sessvar = empty;
if (!isset($_SESSION['a_sess_string'])) { /* #6 */
/* #7 */ $_SESSION['a_sess_string']= abcd;
/* #8 */ echo This is a newly created session, so we put a fresh
variable in it!;
} else {
$sessvar = $_SESSION['a_sess_string'];
/* #9 */ print(We have sessvar = '.$sessvar.' here, so - Is the
session OK??? Maybe, but the session file '/tmp/sess_?' has been
deleted!);
}
/* #10 */ print(br.session_id(). -that's our session id, hmmm);
? // END OF A SCRIPT

The lines from #1 to #3 intentionally set these parameters to the garbage 
collector just to speed up the results of the problem.

#4 - we're sleeping 

So, after first run we have: after #5 - a new session, #7 puts a variable 
in the session and #8 tells us about that.

After #5 we also have the session file /tmp/sess_? written out
there anywhere.

On second run after #5 (we've been sleeping enough on #4 to have our
session announced old, ...dead-man-walking... - quotation from 'The
Green Mile' movie), the gc-monster is awaken and hungry for eating old
session files. Finally we have the session file /tmp/sess_? deleted 
by the garbage collector after #5.

That's guaranteed by #1 - #4.

[If we put another 'sleep' after /* #5 */session_start(),
we may have time to switch to '/tmp' directory and persuade ourselves
that there is no session file any more after the execution of #5.]

No session file - no session variables anymore, no session at all???
WRONG ANSWER!
We are sent to the 'else' clause, so $_SESSION['a_sess_string] is set
and alive , and its value - additionally - is the one before the session
file has gone (deleted) - abcd in my example.

Obviously 'session_start()' first fills all of the sesion variables into
memory, and after that shoots the garbage collector to go to finish its
cleaning work. The session file is deleted, but inside the session, in
our script, we are not acquainted with that... Until the end of script we 
are happy that everything is all right, but probably this self-confidence 
could lead us to some troubles later.


Is there a workaround? Without going to the file system to check if the
file still exists? A smart and elegant PHP session way, without any
if-file-exists-checking functions?

P.S. (To the administrators/moderators/whatever of this mailing list) - Please 
tell the people - write it somewhere on http://www.php.net/mailing-lists.php - 
that there is no chance to get subscribed if they are using any public mail 
address like @yahoo.com. It took me 2 days, I struggled like a pig with a 
pumpkin to find out...

-
Bulgarian National Radio
IT Department
(+359 2) 9336 615
BNR - Sofia, Bulgaria



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



[PHP] Explicit Stream Flush with fsockopen()

2006-06-04 Thread Oliver John V. Tibi

Hi Guys,

I know this may sound fundamental to some of you, but do you know any 
way of explicitly flushing out stream buffers off to the socket using 
fsockopen()/fputs() combos? Hope to hear from you soon.


Note: I'm not using http, and I'm connecting to some other arbitrary 
port other than http, so I don't know if ob_flush() and its family of 
functions will work.


Thanks! :)

--
Oliver John V. Tibi
Software Programmer/Web Application Developer
IAMD Software Solutions
[EMAIL PROTECTED]
Live free() or die().

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



[PHP] Displaying data a certian way.

2006-06-04 Thread Rob W.
Ok, here's my issue that I have.

Inside my database I have something that look's like this

idserveridcabinetidect...
-
1 server11
2 server21
3 server31

I am trying to get it to display the servers 1 2  3 under a display bar of 
cabinet 1.

Anybody have any solutions to this? I am a novis to php and mysql but i know 
the majority of the basics.


Re: [PHP] Displaying data a certian way.

2006-06-04 Thread Rob W.
Just to clarify a little more, I want the output to do something like 
this...


--
| Cabinet 1  |
--
Server 1
Server 2
Server 3

and so forth...


- Original Message - 
From: Rob W. [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Sunday, June 04, 2006 10:47 PM
Subject: [PHP] Displaying data a certian way.


Ok, here's my issue that I have.

Inside my database I have something that look's like this

idserveridcabinetidect...
-
1 server11
2 server21
3 server31

I am trying to get it to display the servers 1 2  3 under a display bar of 
cabinet 1.


Anybody have any solutions to this? I am a novis to php and mysql but i know 
the majority of the basics.


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



Re: [PHP] Displaying data a certian way.

2006-06-04 Thread Chris

Rob W. wrote:

Ok, here's my issue that I have.

Inside my database I have something that look's like this

idserveridcabinetidect...
-
1 server11
2 server21
3 server31

I am trying to get it to display the servers 1 2  3 under a display bar of 
cabinet 1.

Anybody have any solutions to this? I am a novis to php and mysql but i know 
the majority of the basics.


Remember the previous cabinet and you can use that for checking whether 
to display another heading:




$previous_cabinet = '';
while($row = mysql_fetch_assoc($query_result)) {
  if ($row['cabinetid'] != $previous_cabinet) {
echo Cabinet id  . (int)$row['cabinetid'];
$previous_cabinet = $row['cabinetid'];
  }
  echo Server  . htmlentities($row['serverid']) . br/;
}

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Displaying data a certian way.

2006-06-04 Thread Rob W.

That worked. Thanks.


- Original Message - 
From: Chris [EMAIL PROTECTED]

To: Rob W. [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Sunday, June 04, 2006 10:59 PM
Subject: Re: [PHP] Displaying data a certian way.



Rob W. wrote:

Ok, here's my issue that I have.

Inside my database I have something that look's like this

idserveridcabinetidect...
-
1 server11
2 server21
3 server31

I am trying to get it to display the servers 1 2  3 under a display bar 
of cabinet 1.


Anybody have any solutions to this? I am a novis to php and mysql but i 
know the majority of the basics.


Remember the previous cabinet and you can use that for checking whether to 
display another heading:




$previous_cabinet = '';
while($row = mysql_fetch_assoc($query_result)) {
  if ($row['cabinetid'] != $previous_cabinet) {
echo Cabinet id  . (int)$row['cabinetid'];
$previous_cabinet = $row['cabinetid'];
  }
  echo Server  . htmlentities($row['serverid']) . br/;
}

--
Postgresql  php tutorials
http://www.designmagick.com/

--
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



Re: [PHP] Delete

2006-06-04 Thread Rabin Vincent

On 6/4/06, Larry Garfield [EMAIL PROTECTED] wrote:

Only  if delete.php is a confirmation page.  Never ever ever have a delete
function that operates solely by GET.

Here's why: http://thedailywtf.com/forums/thread/66166.aspx


Yes, I've seen that one before. IMO the main problem there
is the faulty authentication system. If you put delete links
public, and fail to put proper authentication in place, someone's
going to delete your content, no matter if the delete action
is a POST submit button or a GET link.

I don't see how POST is better/more secure for a delete action.

Rabin

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



Re: [PHP] Delete

2006-06-04 Thread Larry Garfield
On Monday 05 June 2006 00:41, Rabin Vincent wrote:
 On 6/4/06, Larry Garfield [EMAIL PROTECTED] wrote:
  Only  if delete.php is a confirmation page.  Never ever ever have a
  delete function that operates solely by GET.
 
  Here's why: http://thedailywtf.com/forums/thread/66166.aspx

 Yes, I've seen that one before. IMO the main problem there
 is the faulty authentication system. If you put delete links
 public, and fail to put proper authentication in place, someone's
 going to delete your content, no matter if the delete action
 is a POST submit button or a GET link.

 I don't see how POST is better/more secure for a delete action.

 Rabin

Data-modification actions should always be made via POST, not GET, because 
they're harder to make by accident that way.  They can't be bookmarked or 
easily picked up by spiders and search engines.  GET should be used only for 
read-only actions.  That's what it's for (GETting data).

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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