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


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Add Element On The Page


I'm creating a web page to allow the user to change their web page by filling the form. In my form, I use JavaScript to change the properties on their page at the iframe in the same page on my form page. I know Javascript is the client programming, that can change the content of the file in server. I also use PHP to handle to change the content of file (web page) in server. It is not difficult to change the properties on the page at the iframe, however, if i want to allow the user to add element, let says adding a paragraph below the paragraph is existed on the page. How can I add more elements(image, link, heading...etc.) on the page or any function can do so?? How can do it in screen (change the visual page) maybe by JavaScript and how can change the content by using PHP?




View Complete Forum Thread with Replies

Related Forum Messages:
Add A PHP Element To An HTML Page?
I have a .htm page on which I want to add a PHP script that will display links depending on if the user is in session or not. I'm not sure if this can be done on a strictly .htm page, but hey you only live once right?  Here's the script I'm attempting to execute:

   <? if ($_SESSION['auth'] == "yes"){ ?>
       <a href="/index.php?page=sign_in">Sign In[/url]
             <? }else{ ?>
       <a href="index.php?page=logout">Logout[/url]
   <? } ?>

The problem is that I don't know all the back-end php coding for the 3rd party s/w I'm using, but since the design calls for a "main .htm page" that displays all the "include" pages, having 2 links displaying on the same page seems silly (1 link for login and anohter for logout).

View Replies !
Put Transparent Layer That Disable Page Element At The Time Of Processing Ajax
I have made web page in php with the help of ajax and javascript. I want to do whenever page processing for ajax for that time I want to put some transperent layer that will disable the back pages element.. I have seen one site but I dont remember.

View Replies !
Php Array Inserted (element By Element) Into Mysql DB
I want each element of the array to be inserted into the database, but only the last
element of the array is inserted... all the elements will echo... any ideas? I'm a PHP newbie... you can probably tell by the code:

View Replies !
Wnat To Embed Full HTML Page In Email, But Migrating Style From Css Files To Element Style Attributes
My web pages of course use css files, but Webmail services require
style to be in element style attributes.

How do I convert a standard HTML page to HTML suitable for delivery to
webmail services?

Perhaps another way to ask the question is:

How to I walk the DOM and for every element, for every style, set the
element's style attribute to the values that are looked up in the css
file in normal rendering.

Anyone know of any tools, or examples to do this?

View Replies !
Getting The First Element
tell me the easy way to get the first element out of an associative array when you don't know what the key is? I have this array:

myarray = array("key1" => "val1", "key2" => "val2", and so on)

How can I get "key1" => "val1" returned to me when I don't know the value of key1 is?

View Replies !
Does An Array Contain An Element?
I'm using PHP 4.4.4. Is there a shorter way to check if an array has
an element besides doing a for loop and iterating through each element?

View Replies !
Is The Element Of An Array The Last One ?
What is the best way to solve the next problem: PHP Code:

View Replies !
Getting Element Only Once In Array
I've got an array like so: 1,1,5 But I want to try and make it so if it has the ID appearing more than once then it won't be in the array multiple times. i.e. I want the above to say 1,5.

View Replies !
How To Get Array Element?
get_the_category() returns an array that looks like this:

ResourceArray ( [0] =stdClass Object ( [cat_ID] =3 [cat_name] =>
Certifications [category_nicename] =ms-certifications
[category_description] =Certification Resource [category_parent] =0
[category_count] =5 [fullpath] =/ms-certifications ) )

I want to get the value in "category_description" and have tried:

$category = get_the_category();
$cat_d = $category->category_description;
print_r($cat_d);

But that doesn't print anything. What is the correct way to get the
value I'm after?

View Replies !
Remove Element
I have an array I have included below, it is created by whatever is posted from the previous page. I would like it to remove all of the blank elements if possible. Code:

View Replies !
Array Element
I am having trouble getting a weather sticker php script to work properly. I have been working with the guys that wrote it, but so far they haven't come up with a solution. They/we have narrowed it down to the section of the script that compares a text string (which has been converted into UPPER CASE) from a file generated by the weather station, with an array. It is supposed to match an index in the array, that points to which graphic file to generate. This works about 30% of the time.

(When the text string is VERY SIMPLE - like CLOUDY or CLEAR or RAIN) But not when the text string is more complex, like HEAVY RAIN, MIST OVERCAST, LIGHT RAIN or PARTLY CLOUDY.

Here is the line that defines one of the elements in the array:

Quote $vws_icon["PARTLY|MOSTLY+CLOUDY|SUNNY+THUNDERSTORM"] = "./icons/" . "$daynight" . "_tstorm.$image_format";

I did not incluse the whole script, nor the whole array because of its length.

My Question (Finally...) is --- in the line above within the square braces, he has enclosed a string in double quotes, but the string is delimited by | characters and + characters. Can someone explain to me in English what this means? I have tried reading through two big reference books on php arrays, and they only made me even less certain. (For example: "the line means - If the string is PARTLY or MOSTLY CLOUDY or SUNNY and THUNDERSTORM, then set $vws_icon to whtever the $daynight._tstorm.$image_format evaluates to.)

I know, my example translation makes NO SENSE in English. Maybe it makes no sense in php either? I think what he's trying to ask is "If the string contains 'THUNDERSTORM' and any of these other words, then generate the correct icon file for thunderstorm".

View Replies !
Create An Element
Hello, I am doing the following:

   $child = $xml->createElement('comment',$_POST['comment']);
   $entry->appendChild($child);

What I am trying to do is create <comment><![CDATA[$_POST['comment']]]></comment>

In other words, I need to have the $_POST data wrapped in cdata tags contained in comment tags. I have looked till bleary eyed and find I can do the cdata tags or the comment tags but I'm trying for both. Before I came to my senses I used to do it in asp by:

  Set oDetailsNode = oEntryNode.appendChild(oDOM.createElement("comment"))

  oDetailsNode.appendChild oDOM.createCDATASection(sComment)

where sComment was the equivalent of $_POST['comment']

View Replies !
Getting One XML Element Into A PHP Variable
I want to get the information (in *s) from the following feed into a PHP variable: Code:

View Replies !
Access Each Element
I have code as follows generated by php from reading records from a database:

<select name="menu[]" onchange="change(1)">
<option>...</option>
...
</select>
...
<select name="menu[]" onchange="change(2)">
<option>...</option>
...
</select>
and on and on...

it works fine, except that javascript::change(i) (i tells change() which "select" calls the function) does not know how to access the menu control because they have the same name. any ideas to solve the problem?

View Replies !
Occurrences Of XML Element
I am working on parsing a sports XML feed. for the most part I am done, I have pulled all of the pertinent info from the first occurrences of the element in the file. What I need to do now is write a loop (or several embedded loops) that executes = to the number of times there are recurring elements.

For example: if I have 10 occurrences of the <team-stat> element

$n = numberofoccurrences;
for (var i=0;i<$n;i++)
{
foreach
}

What I am having a problem with is finding the number of occurrences for a particular element.

View Replies !
Using The Last Element In An Array
This is the code I have: PHP Code:

$sql = mysql_query("SELECT * FROM dt_directories WHERE category = '$category' ORDER BY name") or die(mysql_error());
  
$last_sql = mysql_query("SELECT * FROM dt_directories WHERE category = '$category' ORDER BY name DESC LIMIT 1") or die(mysql_error());

while ( $last = mysql_fetch_object($last_sql) ) {
     $last_element = "$last->name";
}

while ( $dirs = mysql_fetch_array($sql) ) {
     $allowed_dirs = $allowed_dirs."name = '$dirs[name]' OR ";
    }

What this does is output the following into the variable $allowed_dirs:

E.G - name = 'Best of the Web' OR name = 'Dmoz' OR name = 'Yahoo!' OR

Another part of the code outputs the last element in the array to the variable $last_element, in the example above, $last_element would be "Yahoo!". What I want to do is use $last_element to remove the last "OR" in the example above. Any ideas?

View Replies !
Sum One Array Element
I have an array that contains two elements partNo and Quantity. I want to sum the quantity element for all values in the array. From what I can tell array_sum() sums all elements and converts non-numeric fields to their number equivalent or something. whatever it does I don't get a good total. I'm sure there is an easy solution but I'm hitting a wall.

View Replies !
Get Key Of The First Element Of An Array
Is there an easy way to get the key of the first element of an associative array?

View Replies !
Add Element To The DOM Tree
The code displays hello as soon as the user clicks on the button but the text dissappears as soon as the click button is released. Why is it not static ? Is it because of the onClick event? Code:

View Replies !
How Do I Use The First And Last Element Of An Array
I want to use the first and last element of an array, don't care what happens to the rest. I tried using.

$count=count($name);
$fname = $name[0];
$lname= $name['$count'];

but it only gives me the first one.

any ideas?

View Replies !
Add Element Onto Array
I have an array that has been already created from a script. Here is the code for that array:

$returnArray[]= array("id" => $smilieRow['id'],
"url" => $smilie->url,
"bbcode" => $smilie->bbcode);

I have another array too that is created pretty similarly to that. What I want to do is add another element to the array called "$num". Now I would just loop through it again with a foreach, but is there an easier way?

View Replies !
Get Value Element From Array:
removing one key=>value element from array: I have an array of this sort:

array(
[#document]=> <?xml version ="1.0"?>
[finemae]=>2344ddd
[subscriptionstatus]=>unread
[trackingnumber]=>45566
}

I wanted to get rid of the first Key=>value element which is #document=> <?....?>

element:

insert into table (#document,filename,subscriptionstatus,trackingnumber) value ('"<?...?>','..',...);

View Replies !
Deleting An Element
I have a script where I want to delete an element of an array, not just set it equal to "". For example if i have:

$array = array("test1","test2","test3","test4");

I want to remove "Test3" so I'm left with

$array = array("test1","test2","test4");

I searched php.net and only found functions that bump from the begining or the end, I need to delete stuff in the middle sometimes too.

View Replies !
How Do You Take An Element *out* Of An Array?
is there a way to leave a certain field out?

for instance, I'm using http_build_query() to build a new query and I have page_num=2&color_id=5&start=5 and all I want to do is keep color_id=5&start=5 .. I don't want/need the page_num info How can I take that out of the array?

View Replies !
Element From An Array
I have an array that contains numbers. Each element in the array is guaranteed to be unique.Let's say I have another variable which I know for certain is in the array, but I don't know the position.


View Replies !
Find Element Id
I use ajax to display number of hits being made on a page, in the first time of loading, the number is retrieved from the DB, in the rest time, I want to get it from another page directly that knows a new hit is being made. I don't know how to let that page to change the innerHTML in a different page. Normally we do: document.getElementById("someID"); but it is for the current page, what would be the code that specify which page's text field ID to go.

View Replies !
Delete Array Element
How can i delete an element from one array. Let us suppose that i've an array of 10 elements $a[0], $a[1], $a[2]...etc
And when i delete $a[2] i wanna the elements to be re-ordered like this
$a[0] will be the same $a[0]
$a[1] will be the same $a[1]
but $a[2] will be the $a[3] element i had before deleting $a[2]

It would be called in Delphi, HOW TO DELETE AN ELEMENT FROM A COLLECTION? Is this possible? Have i to use another type of data?
Hope you've understood the idea.

View Replies !
Use Session_is_registered() With An Element Of An Array
If I want to use session_is_registered() with an element of an array, how do I code it?

View Replies !
Deleting An Element In An Array??
Here is the problem:

I've got an array with the following elements

$array = ("ice","ice","polka","skate","polka");

thats 2 polka, 2 ice and 1 skate

Now i want someway of removing just one of the polka's from it..

so that i'd be left with:
$array = ("ice","ice","skate","polka");

what i did was a basic search with for loop and break

Code: for($x=0;$x<sizeof($array);$x++)
{
if($array[$x] == "polka")
{
echo("match ".$x);
break;
}
} alls well n good till now.. now i've got the index value(2 in this case) of the element which needs to be deleted.. but what should be done now?? is there any function which'll let me delete a particular element in an array?

Is there any other way to go around this?

View Replies !
Editing An Element Within An Array
I have a two-dimensional array that looks like this:
array(
array(0, 123),
array(0, 234),
array(0, 345),
array(0, 456)
)
I want to REMOVE any element that contains 234, and I want to
INCREMENT the first value for any element that contains 345, to make
it look like this:
array(
array(0, 123),...

View Replies !
How To Substract An Element From An Array
I'm looking for a function which substracts an element from an array. For example,

$array = array ("green", "red", "blue", "grey" );

array_substract($array, "red" );

now it's like I had :

$array = array ("green", "blue", "grey" );

notice that the order should be preserved!

View Replies !
Foreach Element In $_POST?
Is there a way to go through each element in the $_POST supervariable?

I'm making a page with dynamic forms, so I don't know for sure how many
$_POST variables there will be (the number of textboxes, radio buttons,
etc changes).

How can I either count them or do a foreach loop to do this?

View Replies !
Missing Array Element
I am trying to store the id's for 3 hotel rooms into an array called
$rooms, using a simple mysql select statement. Here is the code:

<?php require_once('Connections/Vita_Italiano.php'); ?>
<?php mysql_select_db($database_Vita_Italiano, $Vita_Italiano);
$query_rsAllRooms = "SELECT * FROM room";

$rsAllRooms = mysql_query($query_rsAllRooms, $Vita_Italiano) or
die(mysql_error());

$row_rsAllRooms = mysql_fetch_assoc($rsAllRooms);
$totalRows_rsAllRooms = mysql_num_rows($rsAllRooms);

// create array of all rooms
while ($row_rsAllRooms = mysql_fetch_assoc($rsAllRooms))
{
$rooms[]= $row_rsAllRooms['Room_Number'];
}

?>

When I use <?php print_r($rooms);?> to display the contents of the
variable, the array only contains 2 room numbers, instead of 3. These
are stored in $rooms[0] and $rooms[1].

Does anyone have any ideas what is going on here?

View Replies !
Random Element(s) Select?
I'm trying to create a page that displays an image, but also has a specific text string and link associated with that image. There are 5 images, and I want a way to select randomly one of these images with its appropriate info.

I've seen a lot of scripts already that select an image from a text file, or a database, or a directory of images, but I want to do it with arrays. I suppose I would have to use associative arrays. PHP Code:

View Replies !
Breaks In Form Element
I have been having a whole lot of trouble trying to get this to work. I am using the code below for my Content Management system. The field 'content' is the field that needs to have the auto <br /> turned off. I am using the code below to insert pages into the database. The pages have HTML included within them and are formatted using Dreamweaver, so they look nice and neat.

After the script is done running, the page entered had extra <br />s added to it. Could someone please help me get rid of them, been looking all over the place and have tried a lot, no luck though PHP Code:

View Replies !
How To Change Css Id In Span Element?
How to change a link's color based on a php variable?

I have a number of links on a page:

<p><a href="page1.php">Page 1</a></p>
<p><a href="page2.php">Page 2</a></p>
<p><a href="page3.php">Page 3</a></p>
<p><a href="page4.php">Page 4</a></p>

I want the link to be red if $nav has a value that corresponds to the page
number: If $nav = 1, then the page1.php link should be red; if $nav = 2,
then the page2.php link should be red, and so on.

This is how I'd normally code the html to make a red link:

<p><span id="red"><a href="page1.php">Page 1</a></span></p>

But how do I check the value of $nav and insert the appropriate span id for
each link? Can I somehow make the span id a variable? How to I jump in and
out of php within a tag?

If $nav does not correspond with the link's page number, then the link
should remain the default color - which is blue:

<p><span id="blue"><a href="page1.php">Page 1</a></span></p>

View Replies !
Missing Element In Array?!
I have the following query I run to pull some data from the db. The
sql (when run on the db) returns 2 elements. However, if I var dump my
variable ($aidlook) then the first element in the array does not show
up.

$getaid = mysql_query("SELECT a_uid FROM `answers` WHERE `qid` =
$qid", $db);
$aidlook = mysql_fetch_array($getaid,MYSQL_NUM);

Doing a var dump returns: array(1) { [0]= string(1) "4" }

I should be getting 2 elements (4 and 5).

I am totally baffled. code as follows:

*********************
if (!is_array($aidlook)) $aidlook = array($aidlook); // Check for the
existence of the array in case of null returns

if (!in_array($userid,$aidlook)) // Look for our element which in
this case is "5"
{
if ($qstatus === 1) // Do a status check
{
}

answer_box($qid,$answ); // additional function being run

} else
{
echo "Your Text Here";

}
}

View Replies !
Deleting An Element Of An Array?
How can I delete an Element of an array? Consider the following Example: PHP Code:

View Replies !
Eliminate An Element Of An Array
I want to eliminate the last element of an array, couse when I print it, it doesn´t have any value. I tried to use array_pop but it doesn´t work.

View Replies !
Deleting An Element From An Array
is there some handy and short method to delete an element from an array and than shifting the rest of elements one place ahead
e.g

array(1,2,3,4,5,6)
becomes
array(1,2,4,5,6)

View Replies !
Remove Element From Array
How do I remove an element from an array? Here is my current code:

$sql = mysql_query("SELECT suitenos FROM gssettings WHERE id=1");
$row = mysql_fetch_assoc($sql);
$suites = split(",",$row['suitenos']);
$number_of_suites = count($suites);
for($i=0;$i<$number_of_suites;$i++)
{
if($suiteno == $suites[$i])
{
$selected = "SELECTED";
} else {
$selected = "";
}

echo<<<endhtml
<option value="$suites[$i]" $selected>$suites[$i]</option>
endhtml;
}

Now I have another table in my database called "gsdays" that holds values of suite numbers that are already booked. What I want to do is remove any suite numbers that are already booked from my $suites array. To get the booked suites, I would do the following query.

$query = mysql_query("SELECT suite FROM gsdays WHERE date='2007-03-24'");
$row = mysql_fetch_assoc($query);

$booked_suites = $row['suite'];

so basically what I want to do is remove $booked_suites from $suites. I tried using array_splice but I don't know what I'm doing.

View Replies !
Random Element From An Array
seems simple enough, but not as much as rand($ARRAY); how would i select a random element from an array?

ie $User_Prize = rand($Users);

View Replies !
Sort 2D Array (by Value Of Second Element)
I was looking forward to sorting an array by the value of the second element. e.g.: Sort by number of hits:

<?php
$webs = array (
   array("url" => "example.com", "name" => "example 1", "hits" => "5"),
   array("url" => "example.org", "name" => "example 2", "hits" => "20"),
   array("url" => "example.net", "name" => "example 3", "hits" => "10")
);
?>

View Replies !
Get The First Element (section) To Be The Outside Loop
I have been trying everything, including Tom Muck's nested repeat region, but I can't get the first element (section) to be the outside loop with the second element (bullet) looping inside. Code:

View Replies !
Adding Value Of A Form Element
im using this code to fill in 3 values for each 'ticket' in any page there could be multiple form elements (depends on how many have been selected) How do i got about adding a total to the bottom, a running total if possible? Code:

View Replies !
Foreach Seems To Only Get Last Array Element
I'm probably doing something stupid that I just can't see (it is 3:30am here).

Here is the result of print_r($children):

Code:
Array
(
[0] => Array
(
[id] => 1380
[fname] => Mary
[lname] => Contrary
[status] => 1
[type] => 2
[email] => Mary.Contrary@nowhere.xxx
)

[1] => Array
(
[id] => 1378
[fname] => Jane
[lname] => Doe
[status] => 0
[type] => 2
[email] => Jane.Doe@nowhere.xxx
)

[2] => Array
(
[id] => 1379
[fname] => John
[lname] => Smith
[status] => 1
[type] => 1


View Replies !
How To Identify A &lt;SELECT&gt; Element
If you want user to choose one or more choices from select list, you use a code like:

<form action="service.php" method="POST">
<select name="Items[]" size=3 multiple>
<option value="1">alpha
<option value="2">beta
<option value="3">gamma
<option value="4">delta
<option value="5">epsilon
</select>
<input type="submit" value="OK" />
</form>


Don't know, how to identify Items[] in further php code. Statement
extract($_POST) says 1, so $_POST array is defined, however none of these statements are working:

service.php:

echo $_POST['Items[]'];
echo $_POST['Items[0]'];
echo $_POST['Items[1]'];
echo $_POST['Items'];
echo $_POST['Items[&#390;']'];
echo $_POST[Items[]];
echo $_POST[Items];

View Replies !
Hide Array Element
I am just wondering how I can hide a directory from showing? I've been playing around with files and it doesn't show the "." and ".." for parent folders but I can't seem to make it hide the "admin" folder (which is in the folder "Folder"). I have tried using unset but without success. Code:

View Replies !
Using An Array Element And Substr
Hi, just new to the list, but couldn't find anything about this on google so I hope it's never been asked before.

I'm trying to write a function that takes a rather large (ASCII) string and splits it into distict sections. The input string is beyond my control since it will be read from a magnetic card (like a creditcard).

The string looks like this: ....

View Replies !
Making Third Element In Array =0
PHP Code:

Array ( [2005-08-21] => 20 [2005-08-22] => 20 [2005-08-23] => 20 [2005-08-24] => 20 [2005-08-25] => 20)

The above is my array, the day of each date is sun(21), mon(22), tue(23), weds(24), thurs(25). i use the code below which reports back the day of the week of each day. PHP Code:

$day = date('w', $dates);
output
0
1
2
3
4

what i want to do is somehow to make the third element in the array = 0 if the first two elements that falls on a day between 0 and 4 (sun and thurs) i.e if the days are 0,1,2,3 then 2 should = 0 or if the days are 3,4,5,6,0 then 0 should = 0.

View Replies !
Array Last Element Index
which array function gives the index of last element out?

View Replies !
How Do I Sort An Array By It's Second Element.
I've searched the forums and can't seem to find a solution to this. How do I sort an array by it's second element. For example, how do I sort this array with this general setup:

$player[0]['pts'] = 2;

so that the player with the most points (pts) is at the start of the array?

View Replies !

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