Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




How To Append A Child Dynamically


i m new in both things php and in this group.
but i have some basic knowledge of php and DOM in php.

here is my problem,
i have one textfield for add a new main node (not main like:
<root><this_one></this_one></root>) in my php page and i m able to save
the xml file correct with this, and in the bottom of that i have one
new textfield for add new child in dynamically create node (which i
descibe above),and one combo box for show the all dynamically create
nodes.now i want that when user give the value in child textfield and
then select a root node for that child from combo box.i want to append
a child dynamically to root node.

but i m not able to do this. plz try to solve my prob...




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
DOM XML - How To Append A Link Element As A Child
I'm trying to generate a RSS newsfeed using the DOM XML functions, but you
already know that if you read my previous post .

I'm able to create rss, channel and title elements but not a link element.
The following code sample doesn't generated
<link>http://www.websitetitle.com</link> but <link> like if the DOM XML
forgot to close the element :

<?php
$link_el = $dom_doc->create_element ('link');
$link_el = $channel_el->append_child ($link_el);
$link_el->set_content ('http://www.websitetitle.com');
?>

Then I got some crazy idea. I thought that maybe DOM XML was thinking the
link element I created was a specially element, not an enclosed one, like in
XHTML for example :

<link rel="stylesheet" type="text/css" href="styles.css" />

Crazy crazy because I don't see why DOM XML would handle my elements as HTML
elements... But then I tried with a meta tag, and guess what... It also
doesn't work ! It works with enclosed elements, tags, like title, head,
html, body or unknown ones like channel or item. But it doesn't work with
link, meta and input elements !

And I have no clue why it handles these elements as special elements...

Here is the full script :

Dynamically Populate Drop-down List And Dynamically Include Html File
We have a drop down list on a PHP page, with several product names, and
when people click one item, we will refresh the same page with the
product name as parameter, and in turn we want to include a HTML file
into the content area of the same page.

I know it is recommended to put everything into database, but we want
the web site to be very "portable", so the drop-downlist and the
content should both in text files.

Let's say the drop-down list will be poplulated from the product.txt
file, and there will be a file for each corresponding item in the
drop-down list. From the user point of view, if he wants to add a new
product, he will just need to open the product.txt file, and add a new
line with the product name, "Laptop", then add a new text file named
"laptop" in the same folder which contains the HTML fragment to be
included in the content area.

What is the easiest way to do this?

Append To String
I've got 3 variables in a form: products[], ib, wl. products[] contains whichever values where checked from about 20 checkboxes, and the other two (ib, wl) are either "yes" or "no". The reason for this is that there is a limit of 4 products to order, except for ib/wl which don't count as part of the 4. Now, want the values to be sent by e-mail: "Products: ql, ba, wl".

I did [b]$prod = implode (",",$products);[b], and then I would like to append ", wl" to $prod IF the value is "yes" and also ", ib" if the value is "yes". How would I do that? Thanks!

Array Append
How may I programatically append and create the following predefined
array in PHP?

Although the example has all the data and the subsequent arraw
predifined I must create an array while iterating through the rows in an
RDBMS.

array(
array('name' => 'bob', 'phone' => óS-3425'),
array('name' => 'jim', 'phone' => óS-4364'),
array('name' => 'joe', 'phone' => óS-3422'),
array('name' => 'jerry', 'phone' => óS-4973'),
array('name' => 'fred', 'phone' => óS-3235')
)

Header Append Question
I am trying to avoid using frames when people click on my links section to see other sites outside of my site, but I don't want to have them leave in a new window. Sort of the way that yahoo shopping works where it can bring in other sites, like KMart, Jcrew etc. and have the yahoo header on top of them but all be in the same scrollable page. How is this done?

My problem thus far has been that if I put my header on let's say Kmart's site. The minute someone clicks a link in the kmart page I can't still have my header there, but Yahoo can?

Treemenu Append Automatically
Here i got a problem to append my treemenu file automatically. this mean that the user haven't need to click the main title of menu to display their subtitle(allow the user to done other funtions on it).

Loop Through And Append To String
The following code: for ($i = 0; $i < $varcount; $i = $i + 1) {echo "," . "$parts[$i]";}

Will output: ,$parts[0],$parts[1],$parts[2],$parts[3],$parts[4],$parts[5],$parts[6],$parts[7],$parts[8]
What is a good way to append or save the resulting output to a variable?

Append Two Textfields Into A Third One With A Space
i dont know if its a stupid question but im so new to php you can forgive  me
well the thing is i have 3 text fields

textfield1
textfield2
textfield3

I want to add textfield 1 with textfield 2 and display it in a hidden textfield3 with a space between the text.

Textfield1(Sam) + Textfield2(Yam) = Textfield3 (Sam Yam)

Append To A Temporary File?
Is it possible to append to a temporary file?

I'm iterating through a file and when a condition becomes true, I want to append the content to a temporary file.  I want to display the contents once the loop completes. If there's a better suggestion on how to go about this, please let me know.

Error Check Before Append To File.
I want to be able to append my httpd.conf file from a web browser to make adding virtual hosts a little easier. I've got a simple form that passes two variables. $virtualhost and $subdirectory.

what I want to be able to do is read the file and make sure that there is not already a domain name and subdirectory in the file. Code:

DOM Child Finding
Is there any faster/easier way of finding a child node of a certain
DOMNode object than doing something like

function getChildByTagname($curnode, $name)
{
foreach($curnode->childNodes as $node)
{
if($node->nodeName==$name)
{
return $node;
}
}
}

?

it seems fairly slow and cumbersome. i was thinking xpath, but i can
hardly imagine that to be a lot faster, with all the DOMXpath object
creation and all, though I didn't benchmark.

Check For XML Child
I need some help for checking for the following:

<?xml version="1.0" encoding="ISO-8859-1"?>
<error>
<err type="2">Invalid location provided.</err>
</error>

Heres my PHP code:

$hold = array();
$v_URL = "http://xoap.weather.com/weather/local/{$loc}?cc=*&prod=xoap&par={$par}&key={$key}";
$o_XML = new SimpleXMLElement(file_get_contents($v_URL));
$err = $o_XML->error;
if($err){
$fcity[0] = 'Check Your ZipCode'
$deg[0] = 'n/a'
$icon[0] = 'error'
}
else{
$hrm ="<FONT FACE="Symbol">°</FONT>F";
$city = $o_XML->loc->dnam;
$fcity = explode(',',$city);
$deg = $o_XML->cc->tmp; // Temperture
$icon = $o_XML->cc->icon; // Weather Icon
$lat = $o_XML->loc->lat; // Latitude of City
$lon = $o_XML->loc->lon; // Lonatitude of City
$vis = $o_XML->cc->vis; // The Visibilty
}
$hold[0] = $fcity;
$hold[1] = $deg;
$hold[2] = $icon;
// Output the Weather Array of $hold
return $hold;

Any ideas for checking for that? also heres a working zipcode xml output

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--This document is intended only for use by authorized licensees of The Weather Channel. Unauthorized use is prohibited. Copyright 1995-2005, The Weather Channel Interactive, Inc. All Rights Reserved.-->
<weather ver="2.0">
<head>
<locale>en_US</locale>
<form>MEDIUM</form>
<ut>F</ut>
<ud>mi</ud>
<us>mph</us>
<up>in</up>
<ur>in</ur>
</head>
<loc id="04537">
<dnam>Boothbay, ME (04537)</dnam>
<tm>10:10 AM</tm>
<lat>43.88</lat>
<lon>-69.63</lon>
<sunr>6:07 AM</sunr>
<suns>7:06 PM</suns>
<zone>-4</zone>
</loc>
<cc>
<lsup>9/6/07 9:45 AM EDT</lsup>
<obst>Boothbay Harbor, ME</obst>
<tmp>62</tmp>
<flik>62</flik>
<t>Mostly Cloudy</t>
<icon>28</icon>
<bar>
<r>30.34</r>
<d>steady</d>
</bar>
<wind>
<s>9</s>
<gust>N/A</gust>
<d>160</d>
<t>SSE</t>
</wind>
<hmid>95</hmid>
<vis>10.0</vis>
<uv>
<i>2</i>
<t>Low</t>
</uv>
<dewp>61</dewp>
<moon>
<icon>24</icon>
<t>Waning Crescent</t>
</moon>
</cc>
</weather>

I was trying to figure out how to check for <error></error>. but can't quite figure it out.

Children Of Child Node??
Is there any function or way to access the children of a child node using DOM???

I mean if i have the xml structure as:
<app>
<app_data>
<data name='method'><value>sum_dif</value></data>
<data name='val1'><value>123</value></data>
<data name='val2'><value>456</value></data>
<app_data> // child of child node
<data name='coool'><value>divo9</value></data>
<data name='sands'><value>007</value></data>
<data name='make'><value>bond</value></data>
</app_data>
</app_data>
</app>
How can I access the data in the child node <app_data>?

Child Construct Parent
I'm building out a OO based app in PHP 5 but I'm getting a little
confused on children contructing parents.

I have a parent that looks like this:
abstract Class State {
protected $database;
protected $user;
protected $output;
public function __construct($database,$user,$output) {
$this->database = $database;
$this->user = $user;
$this->output = $output;
}
}

And a child that looks like this:
Class Status extends State {
public function __construct($database,$user,$output) {
parent::__construct($database,$user,$output);
}
}

This seems to work OK. But I'm getting confused when thinking about
adding a new child who then has to contruct the parent again. Isn't
this getting away from the whole purpose of inheritence? It seems like
this is recreating the parent with every new child that come along.
Would it be possible to just have a single instance of the parent that
all children extended or am I missing the point here?

Child Object On Demand?
I have an application that suffers from my amateur coding
inefficiencies, and I am trying to clean a few things up. I have an
extremely database intensive object, which I have tried breaking into
smaller child objects to reduce database queries when they aren't
needed.

I currently have something that looks a bit like this:

class Object {
function Object() {
$this->attribute1 = dbQuery("foo");
$this->attribute2 = "bar";
$this->child = new SomeOtherObject($attribute1);
}
}

$foo = new Object();
if ($foo->attribute1 == "X") echo $foo->child->attributeA;

Because every page load does not require $foo->child to be populated,
is there a way to only establish the child object if it is referenced?
Where is a good place to read about dealing with child objects?

Fopen - Append Works, Write Fails (but File Is Truncated)
I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...

Test it at:
http://home.no.net/moldevbk/fopen-test/?mode=w (write - fails)
http://home.no.net/moldevbk/fopen-test/?mode=a (append - ok)
http://home.no.net/moldevbk/fopen-test/p.php - PHP info
http://home.no.net/moldevbk/fopen-test/fopen-test.phps - source code of test script.

I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...

Parent Refreshed By Child Window
I wonder if I could refresh parent window in PHP when I close child. I know
that I can refresh but I need to keep entered data which I have in parent
window.

Display Child Records Only When Checkbox Is On
I have a list of nested arrays, that displays the parent, and then has the child records indented underneath. I want to be able to make a collapsible list, which I know how to do with regular data, but I'm having troubles getting the child records to display.

I can get regular text to show up when I click but not the child records. What I am currently doing is calling a javascript onClick that changes the span textContent property.

What would be the best way to handle the child records? Putting them in a function and calling it from the javascript by way of AJAX or something? Code:

Creating A Parent->child Tree
Does anyone know any good tutorials on creating a parent->child tree?

Ive looked through google but cant seem to find any?

An SQL Query To Insert One Child For Multiple Parents
Let's say we have two tables:

Table 1) Category [fields= categoryid,categoryname]
Table 2) Sub-Category[fields= subcategoryid,categoryid,subcategoryname]

Let's say:

There are 5 entries in Category Table and that are

1,Books
2)Games
3)Toys
4)Computers
5)Cars

now, if i want a subcategory of category "Cars", simply i add a subcategory in it with categoryid=5

thats no problem.

i want a MYSQL query that could allow me to add a subactegory for all those 5 categories in one Query.

so that query enters 5 new rows in table "subcategory"

where subcategoryid,subcategoryname remains same but categoryid is 1,2,3,4,5 respectively.

Parsing XML Using XPath: Getting Parent/child Values
I am using PHP and XPath to parse an XML value. I found a tutorial that showed me how to get node values for each node, but I need to get them by parent/child node relationships. I'll show you what I have below, so I can explain better: Code:

Resource Temporarily Unavailable: Couldn't Spawn Child Process
Everyday I check my error log I find lots of these errors:

[DATE & HOUR] [error] [client IP X.X.X.X] (35)Resource temporarily unavailable: couldn't spawn child process: /usr/local/httpd/php4-fat/php, referer: www.#*$!.com

[DATE & HOUR] [error] [client IP X.X.X.X] (35)Resource temporarily unavailable: couldn't create child process: 35: php, referer: http://www.#*$!.com

[DATE & HOUR] [error] [client IP X.X.X.X] (35)Resource temporarily unavailable: couldn't spawn child process: /usr/local/httpd/php4-fat/php, referer: http://www.#*$!.com

[DATE & HOUR] [error] [client IP X.X.X.X] (35)Resource temporarily unavailable: couldn't create child process: 35: php, referer: http://www.#*$!.com

Sometimes my includes dont work or I get 500 Internal server errors.

I was told that some PHP processes could be hanging around in the process table, preventing the spawnning of new processes, but I really doubt it since I have low traffic and my php applications arent that complex.

Does anybody know how to get rid of those errors?

Instantiate Child Object From Inside Parent Constuctor?
Is it possible to instantiate a child class within the constructor of its
parent?

eg

Class DBI extends DB {
function DBI() {
// explicit parent constructor call
$this->DB();
$class = get_class($this);
if ($class != '' && $class != 'dbi') { // only do this
for child classes
$obj = new $class; // BORK!!

<snip>

I thought the syntax would be

$obj = new DBI::$class;

but that throws the lovely Hebrew error:

parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM

Solaris/Apache, Child Pid 3383 Exit Signal Segmentation
I cant get php to work on soalaris 8

when I start apache:

[Mon Mar 8 11:39:59 2004] [notice] Apache/1.3.27 (Unix) PHP/4.3.2
configured -- resuming normal operations

but when I got to my test.php page:

which is <?php phpinfo(); ?>

Then I get a page cannot be displayed page.

then in the apache error logs:

Mon Mar 8 11:40:32 2004] [notice] child pid 3383 exit signal Segmentation
Fault (11)
[Mon Mar 8 11:40:32 2004] [notice] child pid 3382 exit signal Segmentation
Fault (11)
[Mon Mar 8 11:41:31 2004] [notice] child pid 3384 exit signal Segmentation
Fault (11)

What do I need to do?

I installed the SFWmphp package from soalris 9 which I installed on solaris 8.

How Can I Kill A Running Child Process When Client Closes Connection
running PHP5 under Apache 2.2 (prefork) as module, I call a Python script that does a sometimes lengthy MySQL query, using parameters supplied by the browser client. When the query takes too long, the user may want to press the STOP button and issue a different query. But the previous child process will run to completion in any case, wasting server resources at the very least.

In the current setting there seems to be no way to forward the user action to kill the child process. The system() call is blocking, and the only chance to see the closed connection in the PHP script is after it has returned.
Is there a work-around? I'm advised not to use the pcntl_fork() etc. in embedded PHP. Are there other possibilities?

Please don't say I should have done everything directly in PHP, without a system() call. I'm much better in Python, that's the reason why, and also I think the call to execute_query (or whatever it is called) directly from within PHP will block as well.

Any suggestions, best proven real-life solutions, are welcome. I thought this must be an everyday problem, or?

Append "string" To Uniqe ID?
Hi, I'm using a this to generate a unique ID:

$id = (substr(uniqid (""), 2, 7));

example output >> c846dd1

I'd like to append "abc" to beginning of the id.

eg. abcc84dd1

Append Text At End Of Existing Text On Same Line
I'm working on a part of my web site that uploads images, then writes the name of the image to a text file. The upload part works fine. The part that writes the name of the image to the text file works fine.

What I'm trying to do is, after all the files have been uploaded and all of the image names have been written to the WriteTo.txt file, append a written description of the picture at the end of the picture name. In other words, after a user uploads their pictures to the server I want to direct them to a page where they can label each of the pictures using a form. PHP Code:

Child Class Member's Iteration By Parent Class
I have a class that has a few private members. Is there a way to create a function in its parent class that can access its (child's) private members.

With the following code I am able to get only the public and protected members.

class parentIter {

function iterateProps ( ) {
foreach ( $this as $propName => $propValue ) {
echo "<br>$propName => $propValue" ;
}
}
}

class childIter extends parentIter {
protected $var1 = 'protected var' ;
private $var2 = 'private var' ;
public $var3 = 'public var' ;

function iterateProps ( ) {
parent::iterateProps () ;
}
}
$obj = new childIter () ;
$obj->iterateProps ( ) ;

Modify A Function Of A Parent Class From The Child Class ?
How do i modify a function of a parent class from the child class ?

How To Append A Flv File Contents To Another Flv File.
Could u pls helpe me how to append a flv movie file to another flv movie file.

How To Dynamically Name Variables?
Lets say I have variables named: name1, name2, name3, and name4. How can I call them without having to name them everytime. Something like

for ($i=1; $i<=20; $i++){
if $"name".$i {
do this }

I've tried everycombination I can think of, but am totally confused. I had no trouble naming the variables dynamically in a form, but I can't get php to call them dynamically.

PHP To Dynamically Generate XML
I am interesting in using PHP to dynamically create an XML document and
then use XSLT to transform to XHTML. I have come across two methods for
doing this. I made two equivalent examples so you can see what I mean.

http://members.shaw.ca/petermichaux...SLT_method.html

I am interested in critisim of how I implemented each method. However
my main problem is deciding between methods. Which method is better for
bigger programs where the bits of the XML data are assembled by various
php functions that I write?

For example, one php function queries a database table for a list of CD
titles. A second php function loops through this CD title list and gets
the track listing for each CD from another table in the database. Then
the composite XML data (ie. CD title and tracks as nodes) can be
tranformed to XHTML.

PHP 4: Does Method_exist Return True If Parent Class Method Even If Child Class Forgot To Call Parent::
My code was dying on the line below where I use method_exists:

if (class_exists($nameOfClassToBeUsed)) {
$object = new $nameOfClassToBeUsed();
$this->arrayOfAllTheObjectsSoFarLoaded[$nameOfClassToBeUsed] = &
$object;
if (method_exists($object, "setCallingCode"))
$object->setCallingCode($nameOfFunctionOrClassCalling);
return $object;
} else {
$this->error("$nameOfClassToBeUsed not found. The code that wants
this class is $nameOfFunctionOrClassCalling ");
}

The method is in the parent class yet I'd forgotten to call parent:: in
the constructor of the child class. It seems to me that method_exists
was testing true, though the method was not truly available, and then
the code died. Adding parent:: to the constructor of the child solved
the problem. Is this a bug in PHP?

Dynamically Naming Variables
i have this script for that uses 7 pulldowns for the time of an event each day of the week that gets inserted in to a db. Instead of writing the script 7 times for taking the data from the pulldowns, creating a time based on the hour, minute and AM/PM -can i create something that dynamically creates varibles. Basically takes something like $hour1, $minute1 and automatically creates $hour2, $minute2 and so on. This is kinda difficult to explain, heres a snippit of code which i want to duplicate.

Dynamically Incrementing Arrays
I tried searching for this, but couldn't find exactly what I wanted.

Dynamically Creating A Crontab
Is it possibe to dynamically create a crontab. Say i have a form to enter minute, hour, day, etc... and wanted to create a cronjob that ran to those values. Has anyone done this?

Dynamically Resizing An Image
I want to create a thumbnail image. But I don't want to physically resize each
image before uploading it (actually, my client doesn't really have the capability).

Can I dictate a height (i.e. 108 px) and have a PHP script that will
proportionately size down the image using that height? So, if the original is 360 px wide by 540 px high, the image will automatically size to 108 px high by 72 px wide.

How would I do this?

Dynamically Generate Mp3 Clip
I have page in which user will upload song and i need to automatically
generate a 30 second clip of the uploaded mp3 file and save it

can anyone suggest how to do this on linux server which software to use

is it possible with ffmepg or ffmpeg-php to cut a 30 second clip or 60 second clip etc.

if you have any example then please show me how to do that.

Find Domain Name Dynamically
I have 2 registered domains, which point to the same web root folder.
I would like to display a different logo image depending on which domain the user requested. Is it possible to find the domain name with PHP?

How To Change Data Dynamically ...
I'm developing a system where user has a previlage to select
his/her COUNTRY then STATE then CITY respectively. i've put all the
Country names, State names and City name in a Drop-Down combos which
is filled dynamically from the MySQL database. Now my problem is that
i want it in such a way that if one select USA as COUNTRY then all the
STATE(s) of USA should be displayed on the STATE combo not any other.
and then when user selects the STATE in the next combo the CITY combo
should be populated with cities related to that STATE only and not
with any other.

Dynamically Generate Mp3 Clip
I have page in which user will upload song and i need to automatically generate a 30 second clip of the uploaded mp3 file and save it. can anyone suggest how to do this on linux server which software to use? is it possible with ffmepg or ffmpeg-php to cut a 30 second clip or 60 second clip etc

Updating BIND Dynamically
I am about to start an indepth project for the company I work for. We want to use a PHP front end and be able to make updates to DNS dynamically. I was wondering if I can get some opinions on where to start.

Dynamically Populate PDF Form
I found a free script/class online a few months ago which enabled me to populate pre-built PDF forms with data using PHP; without using any toolkits etc (it worked perfectly). It was simply a PHP script. I lost the script when my PC died recently DOH!

Does anybody know where I can find such a script again? I have searched google all night, but all I find is commercial products (not cheap!) or toolkits for generating PDFs', not filling pre-built PDF forms. Here is what I am trying to do:

I have built a site for a client which incorporates e-learning. Students take lessons and if at the end of the course their grades are sufficient, they download a PDF certificate. The certificate is in PDF format with Form Fields for the required data. The certificate needs to display the students name, grade and course name. I need a PHP script which can import server-side data into a PDF form which the user can then print or save (flat). The last (and lost) script did this so I know it is possible.

PHP To Dynamically Make New Pages? DOH!
I am building a CMS system for a client to edit add and remove content from his new site, not a problem however he now wants the facility to create new pages and be able to edit the new pages, how do you create a new page dynamically using php and mysql?

As in he needs to make a new page called untitled2.php for example, with the title at the top of the page, a description about untitled 2 and then save the newly created page so it appears in the menu and actually exists in the remote server files, then be able to edit this using the CMS system? ERM...

Any standard commands as in create_page()?

How would I make the new page have variables included so that it could echo mysql content onto the newly created page?

Dynamically Transparent Gif's
Basically what i would like to do is dynamically set the transparency of a selection of images (GIF'S) depending on variables set in a My SQL Database. What i need to do is tint some jpg,s by setting the transparency of a solid blue gif which is set over the top of it in a table.

Managing Subdomain Dynamically
i don't know if php can do it, here is the picture, what i want is a cheaper way of doing this stuff, newdomain.mydomain.com, cuz when i use the feature of the ISP, it will cost me $1/subdomain per month. any ideas?

Dynamically Load A Class
I want to dynamically load a class using a variable, e.g.

$module = new Mod_{$tmp_Name} ();

Where $tmp_Name is the name of the class.

Is there anyway to achieve this kind of thing?

Dynamically Embedding SWF File In PDF From PHP
is there by any means can i embed a swf file and export the same to a
pdf from my script.

Creating .m3u Files Dynamically
Im looking at creating a playlist program for my server.  i have alist of files within my database, and i wanted to be able to place these values into a playlist file.  the problem is that i dont know how to get the database to create the playlist form its records.  ie, if i uploaded a new file to my server and into the database, then i woudl want the script to automatically grab that file ( SQL  i know), anbd the nplace it in the m3u file ( i dont know).

Coudl someone recommend a simple method to complete this?  or point me in teh righ t doirection for a tutorial?


Copyright © 2005-08 www.BigResource.com, All rights reserved