PHP - Content To Html *help Please*
Hi there,
I'm new a this, please help me: I've a page in php, that's showing the content of a table, but i want to put a link on it, to save that content in html file to my local hard disk. Can anyone help me please? Thanks a lot. Similar TutorialsHi, How do I open all HTML file contained in a folder, then search for the title of the page, and save the title in the database? Also, is it possible to do this using functions? Cheers. Hey guys, OK, so actually I have two questions that are kind of related. The first one is how I can allow users to use <i>, <b>, <strong> tags when submitting information in a form. I would like to allow certain tags so they can emphasize things in their text, but I still want to strip the rest for security reasons. I tried using strip_tags() with some exceptions as a second parameter, but as far as I understand, that just allows them to be displayed as text, not for the browser to make text bold for instance. Below is what I have now. function stripdata($data) { return trim(htmlentities(stripslashes($data), ENT_QUOTES)); } echo stripdata($someDataFromMySQL); I also want to ask if the solution above is 100% safe so that users can not submit malicious code that can execute when users' visit a page of mine that displays that code. Thank you in advance. Hello World, I need some tips on how to make a button that does something like the code below. .......echo '<tr><td align="left"><a href="add_cart.php?pid=' . $row1['item_id'] . '">Add to Cart</a></td>........ I've been messing with html form and button type with no success. This code does the job but I prefer a button. Thanks Hello everybody. Have a good day. I'm Lam, I have problem hope you help me. 1. This is content html Quote <img src="http://example.com/logo.png" /> anti http://google.com<br /> and http://bing.com I want convert to Code: [Select] <img src="http://example.com/logo.png" /> anti <a href="http://google.com">http://google.com</a><br /> and <a href="http://bing.com">http://bing.com</a> and this code php Code: [Select] preg_replace("/(http:\/\/[a-zA-Z-0-9._?\/\s]+)/", "<a href=\"$1\">$1</a>", $content); but result Code: [Select] <img src="[color=red]<a href="http://example.com/logo.png">http://example.com/logo.png</a>[/color]" /> anti <a href="http://google.com">http://google.com</a><br /> and <a href="http://bing.com">http://bing.com</a> I can help me I speak English not well hope u ignoring thanks. Hi
I try to echo out random lines of a html file and want after submit password to whole content of the same html file. I have two Problems.
1st Problem When I echo out the random lines of the html file I don't get just the text but the code of the html file as well. I don't want that. I just want the text. How to do that?
for($x = 1;$x<=40;$x++) { $lines = file("$filename.html"); echo $lines[rand(0, count($lines)-1)]."<br>"; }I tried instead of "file("$filename.html");" "readfile("$filename.html");" But then I get the random lines plus the whole content. Is there anything else I can use instead of file so that I get the random lines of text without the html code?P.S file_get_contents doesn't work either have tried that one. 2nd Problem: As you could see in my first problem I have a file called $filename.html. After I submit the value of a password I want the whole content. But it is like the program did forget what $filename.html is. How can I make the program remember what $filename.html is? Or with other words how to get the whole content of the html file? My code: if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ $my_file = file_get_contents("$filename.html"); echo $my_file; } else{ echo "You entered wrong password"; } }If the password isn't correct I get: You entered wrong password. If the password is correct I get nothing. I probably need to create a path to the file "$filename.html", but I don't know exactly how to do that. Hi, I will start off trying to explain what I am trying to make the best I can. What I want to create is a script that gets the gold value from this website: http://www.lbma.org.uk/pages/index.cfm?page_id=46&title=current_statistics and then save it to a variable which I will use to calculate values of different gold karats. Here is the content in bold I need on the website I linked: Quote LONDON GOLD FIXING USD GBP EUR AM 1588.00 1005.127 1251.083 PM 1589.50 1004.741 1249.803 So what help do I need? Well, I don't expect you to figure out the calculating part for me but some help how to get that content pointed out above and save it to a variable is what I would appreciate getting some help with. I don't know much PHP, only some and I have been trying to figure this out for a day now without any success. I suppose php get contents and/or curl should be used here but I don't know how really. I would very much appreciate the help I can get on this. Thank you! This is the Code i am using. This is show error: Fatal error: Call to a member function item() on a non-object in /home/domain/public_html/forum/file/Test.php on line 35 Code: [Select] <?php $xml=("http://www.vn-zoom.com/external.php?type=RSS2&forumids=77"); $xmlDoc = new DOMDocument(); $xmlDoc->load($xml); //get elements from "<channel>" $channel=$xmlDoc->getElementsByTagName('channel')->item(0); $channel_title = $channel->getElementsByTagName('title') ->item(0)->childNodes->item(0)->nodeValue; $channel_link = $channel->getElementsByTagName('link') ->item(0)->childNodes->item(0)->nodeValue; $channel_desc = $channel->getElementsByTagName('description') ->item(0)->childNodes->item(0)->nodeValue; //output elements from "<channel>" echo("<p><a href='" . $channel_link . "'>" . $channel_title . "</a>"); echo("<br />"); echo($channel_desc . "</p>"); //get and output "<item>" elements $x=$xmlDoc->getElementsByTagName('item'); $i=1; // $i = 1 to n (I use For here). { $item_title=$x->item($i)->getElementsByTagName('title') ->item(0)->childNodes->item(0)->nodeValue; $item_link=$x->item($i)->getElementsByTagName('link') ->item(0)->childNodes->item(0)->nodeValue; $item_desc=$x->item($i)->getElementsByTagName('description') ->item(0)->childNodes->item(0)->nodeValue; // If i remove this, it will work....//////////// $item_content=$x->item($i)->getElementsByTagName('content') ->item(0)->childNodes->item(0)->nodeValue; ///////////////////////////////////////////////////// echo ("<p><a href='" . $item_link . "'>" . $item_title . "</a>"); echo ("<br />"); echo ($item_desc . "</p>"); echo ("<br />"); echo ($item_content . "</p>"); } ?> Please help me Fix this Code to Get content of Tag Name <content:encoded> Thanks I have a form that users input user name, password, and email... all writes to csv fine. My problem is I need to concatenate a a string with a variable and some html code will preserving the html when written to the csv.. I need the csv to be this username,password,email,user,category,text with http://sub.domain..com/splash/,something,something here's what i have Code: [Select] <?php if($_POST['formSubmit'] == "Submit") $varUserName = $_POST['username']; $varPW = $_POST['PW']; $varEmail = $_POST['email']; { $fs = fopen("testcsv.csv","a"); fputcsv($fs, array($varUserName,$varPW,$varEmail,"user","title",",category","some text '<a href="http://$varUserName.url.com/splash/>site.com</a>',)); fclose($fs); exit; } ?> and of course I'm getting Parse error: syntax error, unexpected T_STRING, expecting ')' on line 9 Hey guys, I'm a total newbie here, and just about as a new to php. My issue: I have a very large .html file that contain multiple articles (I actually have a few of these, but we'll start with one for practicality). The article titles are all wrapped in <h2> tags, there are 10 articles in one file. The articles are very simple, just a title wrapped with <h2> and then a few paragraphs wrapped in <p> tags. What I want to know how to do: I want to know if there's a way to open that file, and have each article saved as it's own .html or .txt document (the title & following paragraphs of each article). Ultimately taking my 1 large file, and creating the subsequent 10 smaller files from the articles inside of it. I am having trouble explaining this in text so I'll try to illustrate: I have "Articles.html" - which contains (article1,article2,article3.. ..article10) I want to split "Articles.html" and create "Article1.html", "Article2.html", "Article3.html", etc. Is that possible? Or am I looking at something far more complex than I can imagine at this point - perhaps something I'd be better off doing by hand? Ultimately I intend to stick all these articles into a database, but that's the 2nd part of what I want to do (and I think will be the easier of the tasks). Let me know if you need any additional information in the event my description above is unclear... I simply am having issues figuring out how to separate out the text into individual articles. require_once 'phpSimpleHtmlDomClass.php'; $html = '<div> <div class="man">Name: madac</div> <div class="man">Age: 18 <div class="man">Class: 12</div> </div>' $name=$html->find('div[class="man"]', 0)->innertext; $age=$html->find('div[class="man"]', 1)->innertext; $cls=$html->find('div[class="man"]', 2)->innertext; wanna get a text from each div class="man" but it didn't work because there is a missing closing div tag on 2nd line of html code. please help me to fix this. thanks in advance. Hi guys I need to be able to extract (into an array) the content between two tags "<!--" and "-->" in a string ($string). I have $string = "<!--HELLO WORLD-->"; $tags = "/<!--(.*?)--!>/"; preg_match($tags, $string, $matches); return $matches[1]; but it does not seem to work, (no error code, nothing). Any help much appreciated, Hi, I am building function to convert the db table to an XML file. But I want to retrieve the root node value from the FIRST row in that db table before I build a for loop to traverse that db table. Let's say I have this table NodeInfo: node_Id source target ====== ===== ===== 1 email to 2 to toFirstName pseudocode for what I want: 1) store root (the source field of table NodeInfo 2)for each entry in table NodeInfo, do: build XML END FOR-EACH Any help much appreciated! Hi: I have this code that - when added to a page - works fine: Code: [Select] <div class=\"<?php echo (time() <= strtotime('4/17/2011 2:00:00 AM')) ? 'myUpcoming' : 'myPassed'; ?>\"> <span class=\"myGameDate\">April 16:</span> <span class="myGameDateRed">Home</span> vs Baltimore </div> It's a schedule that will display one CSS style before the date, and another CSS style after the date. Works fine on the homepage. I am trying to add it to an include navigation file, so I can add it to all the pages like this: myNav.php Code: [Select] function spSchedule() { $spSchedule = " <div class=\". echo time() ." <= strtotime("4/17/2011 2:00:00 AM") ? \"myUpcoming\" : \"myPassed\"; .\"> <span class=\"myGameDate\">April 16:</span> <span class=\"myGameDateRed\">Home</span> vs Baltimore </div> "; return $spSchedule; } myPage.php: Code: [Select] <?php include('include/myNav.php'); ?> ... <?php echo spSchedule(); ?> What it is doing is writing "myUpcoming" to the page, and that's it. What am I missing on this, please? I want to display 50 results, theirfore I'm using a while loop to do so, the issue is, if $row consists of results lower then 50 (it will display them) and not display 50..so I'm trying to figure out a way so even if $row doesn't cosist of 50 i'll display what it has aswell as continue the $i (and for the rest display NO CONTENT). I've come up with the following on the spot (not sure if it even would work) - but was wanting a better solution. $i = 0; $results = mysql_num_rows($result); while ($row = mysql_fetch_assoc($result)) { $i++; echo $i .' CONTENT '.$row['name'].'<br />'; } if ($result < 50) { for($i <= 50 - $result; $i++) { echo $i .' NO CONTENT<br />'; } } There's many options available for downloading a URL - but I'm stuck. I've looked through all the ones I know, but none seem to pay attention to partial content. I'm trying to retrieve a URL that gives the following header: HTTP/1.1 206 Partial Content Content-Range: bytes 0-100000/631723 As you can see it dishes out the file in 100,000 byte chunks. Trouble is, when I use any method in PHP, ie file_get_contents, fopen, or even cURL, none of these continue on after retrieving the 100,000 bytes. End result, I have a 100,000 byte file. What I need is to get the PHP script to grab all the data, in the example above, all 631,723 bytes. How can I do this? Hi all, Maybe someone can help me with this, I am looking to copy specific content from one website to another automatically. So when ever one website updates the certain content the other site is automatically updated with it to. I have tried using file_get_contents but this wasnt working. Does anyone have any ideas? Im looking to copy https://annablais.scentsy.us/Home starting at line 270, the end is determined by how many Parties there are. Thanks all Hello,
I have html files with this format Code: [Select] ..... <!--ImageSection--><div class="image"><!--ImageSection--><div align="top"><b>Image Link</b> <br />http://www.something.com <br />http://www.another_url <br /></div><!--ImageEnd--></div><!--ImageEnd--></div> ..... I tried to get the content of a <div> with this code: Code: [Select] preg_match_all('/<div class=\"image\">\<!--ImageSection-->\<div align=\"top\">([^`]*?)<\/div>/', $html, $imglinks); foreach ($imglinks as $imglink){ echo $imagelink; } but it returns empty, where did I wrong? Is there a way that I can tweak the following code so that the root nodes have different names? At the moment the xml file is creating a root node for each booking called booking so when I take the xml into flash it is calling it badly formed xml due to the repitition of <booking></booking> //sql_query $table_id = 'booking'; $query = "SELECT * FROM $table_id WHERE (booking.bookingDate = curDate()) AND roomID = 1 ORDER BY startTime"; $room1 = mysql_query($query); //create a new DOM document $doc = new DOMDocument('1.0'); //create root element $root = $doc->createElement('root'); $root = $doc->appendChild($root); //process one row at at time while($row = mysql_fetch_assoc($room1)){ //add node for each row $occ = $doc->createElement($table_id); $occ = $doc->appendChild($occ); //add achild for each field foreach ($row as $fieldname => $fieldvalue){ $child = $doc->createElement($fieldname); $child = $occ->appendChild($child); $value = $doc->createTextNode($fieldvalue); $value = $child->appendChild($value); } } $xml_string = $doc->saveXML(); echo $xml_string; mysql_free_result($room1); ?> I've used get_file_contents() before but it seems like it took a long time to load... what is the best or most efficient way to get certain content from a webpage? Like all the posts on a single forum page for example, without loading any images or styles, just the "source" |