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.





Retrieve The Copy Within An Html Element


I would like to know if it's possible to retrieve the copy within an html element using php.

Specifically i'd like to have a script that read the contents of a <p></p> tag with the id 'title' and saved it as a variable. there can be no .php within the html itself.

Is this possible or is there a better way of going about it?




View Complete Forum Thread with Replies

Related Forum Messages:
Retrieve The Index Number Of The Element Of An Array
After some looking around - and maybe entering just the wrong keywords in
Google :) - a short question: is it possible to retrieve the index number
of the element of an array, let say that there is an array $myArray =
("John", "Tom", "Dick","Harry","Peter")
I am looking for a function that tells me that Harry is the fourth element.
(I have tried in google things like "retrieve index array php" but without
result)


View Replies !
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 !
Inserting A Variable Into An Html Element
I am trying to pull information from a mysql database to display an image or create a link and have not been able to get either to work. Code:

View Replies !
Converting The Posted String To The Value Of Html Element
I've been very confused in dealing with posted strings. For example, if I fill in a text element with "(double quote), submit it and display it in a text and a textarea, I get "(backslash followed by double quote) in the textarea element but (backslash only) in the text element.

Code:
<input name="somename" value="<?php if(isset($HTTP_POST_VARS['submitName'])) echo $HTTP_POST_VARS['somename']; ?>" />

I made a function which correct the misbehavings:

View Replies !
Retrieve Data Into Html Form
I want to retrieve fields from mysql table into html form to update those fields.

View Replies !
How To Save And Retrieve HTML In Its Original Form
When i am saving the below shown html to a text file using php write function, the text file is not the same as the html source. Character "&nbsp" changes to "Â" and "&gt" converts to ">".How can i save the below shown html as it is to the text file.
Code:

View Replies !
Post , Add, Copy To Html File
I'm posting data trough a form and adding it to an html file with the following :

<?php
echo "copiage de fichier debut";
// your new data + newline
$new_line = stripslashes($_POST['codesource'])."";
// the filepath
$file = 'upload/aaatest.html'
// the old data as array
$old_lines = file($file);
// add new line to beginning of array
array_unshift($old_lines,$new_line);
// make string out of array
$new_content = join('',$old_lines);
$fp = fopen($file,'w');
// write string to file
$write = fwrite($fp, $new_content);
fclose($fp);
echo "copiage de fichier Fin";
echo "Redirection.....";
?>


this code add "codesource" to "upload/aaatest.html"

It add it to the bigginig of the file, How can I choose the line "codesource" is added within the file , ex : count 100 lines and start adding text after 100 lines ????


I also need this code to add a log part, It would add to the source code of the html file, in comment, the time&date, the ip, the name, email.

I know how to show the time or ip of a user on screen but i don't want it to be seen, only in the sourcecode of the html, as logs?

View Replies !
Copy A File To Folder In Apache Directory From Html Form
Does anyone have a PHP script that will take a file uploaded by a user via a HTML form, i.e.:

<input type="file" name="filename" id="filename" class="textbox">

Take the file and copy it into the Apache directory on the server?

i.e. on my local machine Apache2.2/htdocs/mini/images/*FILEINHERE*

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 !
How Can Strip The Text Bullet And Then Make That Copy An Unordered List In The HTML?
I have some text coming into a web page from a MySql DB that contains bullets in the copy. The copy cannot be changed as it is also used in a Quark Xpress document we have connected to the DB. So, my question is how can strip the text bullet and then make that copy an Unordered list in the HTML?

This is what I have but and does the indents like a list but no bullets (I guess they are being stripped by the str_replace as well?

echo str_replace(Chr(13), "<p>", ("<ul>".str_replace('•', '', $bulletcontent1)."</ul>"));

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 !
Warning: Copy(fileupload/cc.gif) [function.copy]: Failed To Create Stream: Permission Denied In /
I have a script called "FILE-UPLOAD.PHP" on this page GO HERE TO TEST UPLOAD FILE FUNCTION

When I upload a image file i get the following error:
Warning: copy(fileupload/cc.gif) [function.copy]: failed to create stream: Permission denied in /home/karmacr/public_html/fileupload-class.php on line 266

Any ideas on how to resolve? I have both the Script and upload file in my Public_html directory.

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

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