PHP - Php Grabing Stuff From A Html Page!
Okay the page is structed like this.
lets says i have a http://site.com/sdsddsa And it shows the following Quote <div class="data"> <div class="title"> <a class="title" href="http://www.site.com/product/dp/ITEMID/ref=sr_1_1?s=automotive&ie=UTF8&qid=1291906958&sr=1-1">ITEM ID</a> </div> <div class="newPrice"> <a href="http://www.site.com/product/dp/ITEMID/ref=sr_1_1?s=automotive&ie=UTF8&qid=1291906958&sr=1-1" > Buy new</a>:<span class="price"> $12.95</span> </div><br class="unfloat"> <div class="usedNewPrice"> <span class="subPrice"> <a href="http://www.site.com/product/dp/ITEMID/ref=sr_1_1?s=automotive&ie=UTF8&qid=1291906958&sr=1-1">2 new</a> from <span class="price">$12.95</span></span> <br class="unfloat"> </div> <div class="fastTrack"> <span class="getItBy">Get it by <span class='deliveryDate'>Friday, Dec 10</span></span> if you order in the next <span class='timeLeft'>8 hours</span> and choose one-day shipping.</div> <div class="sss"> Eligible for <span class="sssFree">FREE</span><span class="sssLastLine"> Super Saver Shipping.</span> </div> <div class="lowStock"> Only 3 left in stock - order soon.</div> </div> </div> And it repeated again! I need the ITEMID number from the LISTING and the Price for the item ID number. Can anyone help please! Similar TutorialsI would like to automaclly get posts in a thread manually. Here's my design: -Bot goes to topic, looking for posts -He would search for a <a name="POSTIDHERE">, idenfity it and start the logging loop -Firstly he searches for a field <span id="author"> and logs the content inside it -Then he searches for a field <span id="content"> and logs the content of it -Finally flush it into database (or do it when a step is completed) -When all posts on the page are dealt, move to the next page I don't have a problem with looping ATM, the place I am confused is the second step and the logging steps. How would I do them? In JavaScript there is something called getElementsById. I cannot find the same function in PHP. Thanks! This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=348759.0 hello guys, i'm new here, looking for some help.. here is the situation: I have a string: "system_controllers_qty" and i need it to be: "system_controllers.system_controllers_qty" I can use substr because the It wont always be 'system_controllers', it can be 'system_cpus' for example so I need to somehow break and the second underscore if possible. Any ideas? Why is it when a save a youtube video on my db it gives me this <iframe width="220" height="240" src="http://www.youtube.com/embed/DCZ2l1BbWyY?wmode=opaque" frameborder="0" allowfullscreen></iframe><br> i have to save it twice so it can be view why if you want to see my edit videos page i will add it here This script is working fine on PHP 5.3.1 but i got a new host that uses 5.3.6 and now its no longer working? What can i change to make it work, and does anyone know where i can learn the different coding between the 2 updates? Code: [Select] <? include 'cpheader.php'; if (isset($_POST['submit'])) { $error = ($_POST['title'] == "") ? "You need to have a title!" : $error; $error = ($_POST['message'] == "") ? "You need to have a message!" : $error; if($error == ""){ $time = time(); $result= mysql_query("INSERT INTO `ads` VALUES('".$time."', '$user_class->id', '".$_POST['title']."', '".$_POST['message']."')"); echo Message("You have posted a news update.); } else { echo Message($error); } } ?> <tr><td class="contenthead">Post News</td></tr> <tr><td class="contentcontent"> This is the news that posts on the main page after you log in. HTML is turned on and you may use it to make your posts look a bit better than normal text, as well as add images. </td></tr> <tr><td class="contentcontent"> <form method='post'> <table width='100%'> <tr> <td width='25%'>Title:</td> <td width='25%'> <input type='text' name='title' size='40' maxlength='100'> </td> </tr> <tr> <td width='25%'>Message:</td> <td width='25%'> <textarea name='message' cols='60' rows='4' ></textarea> </td> </tr> <tr> <td width='25%'>Submit:</td> <td width='25%'> <input type='submit' name='submit' value='Post'> </td> </tr> </table> </form> </td></tr> <? include 'footer.php'; ?> This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=318433.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=354568.0 i can do stuff in html, php, flash, java and server developement
and work for more then 8 years in different segments for webprogramming.
german.
include "header.php"; if(isset($_GET['post_id'])) { $select=mysqli_query($con,"select...."); while($data=mysqli_fetch_array($select)) { echo "bla bla bla"; to_head("<title>asd</title><meta itemprop="name" content="asdfasdf">..."); } } include "footer.php";This is samthing what i want... I have header.php and footer.php and any script ex news.php where how news and read SEO stuff from database and put in HEAD of the document. I tried with jquery like $("head").append(str); and it works but then i read google don't run jquery when vist website. This is done with drupal, wordpress and php-fusion Drupal: https://api.drupal.o...add_html_head/7 php-fusion: https://www.php-fusi...thread_id=30959 so it is possible but i don't know how. Any idea? I've been trying for days to get this simple 1990's code to work. It won't work. Now, I don't even want to get it to work, because it's crappy ugly 1990's code... Is there an elegant way to accomplish this? (I just want to be able to manually override the default catalog prices as needed.) <?php //default catalog prices: $sku = "123456"; $price = "5.99"; if(isset($_POST[$sku])) { // if form submitted, and if( ${$_POST[$sku]} != $price) { //...and I manually changed price $price = ${$_POST[$sku]}; //...then change price to what I input } } echo '<form name="form1" method="post" action="Crappy1990sCodePage.php">'; echo '<input type="text" name="'.$sku.'" value="'.$price.'">'; echo '<input type="text" name="'.$sku.'" value="'.$price.'">';// (same sku may be listed twice) echo '<input type="submit" class="no_class_its_the_90s_remember">' echo '</form>'; ?> Thank you 😀 Edited July 25, 2020 by StevenOliverI got a snippet of code from here that will give me the Monday of any submitted date, so if I pass 12/08/10 it'll return 12/06/10 as the Monday, which is correct. I tried to expand it to give me the Tuesday of that week: Code: [Select] function getWeekDays($date) { $offset = ''; if( date('l', strtotime($date)) == 'Monday' ) { $offset = ''; } elseif( date('l', strtotime($date)) == 'Sunday' ) { $offset = 'Tomorrow'; } else { $offset = 'Last Monday'; } $monday = date('m/d/Y', strtotime("$date $offset")); $tuesday = date('m/d/Y', strtotime("+1 day", $monday)); return $tuesday; } I keep getting the UNIX epoch returned for $tuesday...obviously this is just confusing the crap out of me, could someone explain what it is I am doing wrong? Thanks This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=323045.0 OK, about ready to go postal, as I've been wasting inordinate amounts of time trying to resolve this issue! If I create basic HTML echo-ed content, PHP works fine. But if I try to reference any database related syntax, the whole PHP web page breaks! VERY FRUSTRATING. This works: <?php // Printing results in HTML echo "<html>\n"; echo "<head>"; echo "</head>"; echo "<body bgcolor=\"#CCCCCC\">"; echo "<CENTER><H1>Current Inventory</H1>"; but this blows up and just gives me a white page with nothing!: <?php // Printing results in HTML echo "<html>\n"; echo "<head>"; echo "</head>"; echo "<body bgcolor=\"#CCCCCC\">"; echo "<CENTER><H1>Current Inventory</H1>"; $dbhostip = "192.168.0.10"; $dbport = "5432"; $dbname = "testdata"; $dbuser = "postgres"; $dbpass = "password1"; $dbconn = pg_connect($dbhostip,$dbport,$dbname,$dbuser,$dbpass); echo $dbconn; if(!$dbconn) { echo "An error has occurred (line 17)\n"; exit; } $result = pg_query($dbconn, "SELECT * FROM inventory"); if(!$result){ echo "An error has occurred (line 24)\n"; exit; } $resultCheck = pg_num_rows($result); if ($resultCheck > 0) { while ($row = pg_fetch_assoc($result)){ echo $row['cid']; echo $row['item_title']; } } ?> Any help would be appreciated. It seems that anything with $whatever causes the issue...  Hi I would like to know how to make a link select certain stuff from the database. For example the link called cape town with the id 11 is selected then the link must search through the events table for the city_id 11 and take that information and display it in another page. I would like to know how to do that or can you let me know of place that I can look. I have tried google but I don't know how to put what I'm looking for in words Hi, I'm designing a website for an online radio station. One show a week they have a DJ who has his own top 40 show with HIS top 40 listed on his own site At the moment, the only solution I have to getting the top 40 onto my clients site is an iframe (not good I know!) However, what's worse is that this top 40 list has horrendous colours that completely break the theme of my clients site and worse still, is Excel generated HTML! The author of this list is not a client of mine, and so, I can't do anything to persuade him to change. I've attached a copy of the offending file so you can see what I'm working with, changed the extension from html to txt for the forum post. Just for clarification, the excel generated HTML file is not hosted on my server (although I could set up a cron job to get it if required) I've done some digging and found a useful bit of code However, it displays the table 4 or 5 times In addition to this, is there a way to manipulate the width of the columns with this code? Code: [Select] <?php $oldSetting = libxml_use_internal_errors( true ); libxml_clear_errors(); $html = new DOMDocument(); $html->loadHtmlFile('Chart%20Table2.htm'); $xpath = new DOMXPath( $html ); $elements = $xpath->query( "//table" ); foreach ( $elements as $item ) { $newDom = new DOMDocument; $newDom->appendChild($newDom->importNode($item,true)); $xpath = new DOMXPath( $newDom ); foreach ($item->attributes as $attribute) { for ($node = $item->firstChild; $node !== NULL; $node = $node->nextSibling) { if (($attribute->nodeName =='valign') && ($attribute->nodeValue=='top')) { print($node->nodeValue); } else { print("<br>".$node->nodeValue); } } print("<br>"); } } libxml_clear_errors(); libxml_use_internal_errors( $oldSetting ); ?> Basically, I just want the table, I'm not bothered about the first column that contains some pictures as I think that's a separate table Ideally, I'd like to apply my own formatting to the table too (padding etc) if that is possible (eg from line 897 <td class=xl28 x:num>1</td>) down to line 1433 The trouble is, there is a lot of custom widths and styles inbetween which I don't want I'd like all the tr and td's without all the associated guff from the original export from Excel Geez I wish there was an easy way to get this guy just to export as CSV but unfortunately that's not an option! Many thanks in advance! Hi, I wrote a classFile to handle files that looks like this: class classfile { //path_parths is an array, use it this way //path_parts["filename"] -> filename //path_parts["dirname"] -> directory //path_parts["extension"] //path_parts["basename"] protected $path_parts; private $fullpath; function __construct($filename){ if(file_exists($filename)){ $this->fullpath = $filename; $this->path_parts= pathinfo($this->fullpath); } else{ die("File or Folder doesn't exist"); } } function move($destination){ if (file_exists($destination)){ rename($this->fullpath, $destination . "/" . $this->getfilename()); //Update properties $this->setfullpath($destination . $this->getfilename()); $this->setpath_parts(); } else{ die("The folder specified doesn't exist"); } } function copy($destination){ copy($this->fullpath, $destination); } function getpath(){ return $this->path_parts["dirname"]; } function getfilename(){ return $this->path_parts["basename"]; } function getextension(){ return $this->path_parts["extension"]; } function getfullpath(){ return $this->fullpath; } function setfullpath($path){ $this->fullpath = $path; } function setpath_parts(){ $this->path_parts = pathinfo($this->fullpath); } function __destruct() { ; } } ?> Then I extended it with a class to handle images that looks like this: include 'c:/wamp/www/classfile.php'; class classimage extends classfile{ var $image; var $image_info; var $image_type; function __construct($filename){ parent::__construct($filename); $this->image_info = getimagesize(parent::getfullpath()); $this->image_type = $this->image_info[2]; if( $this->image_type == IMAGETYPE_JPEG ) { $this->image = imagecreatefromjpeg(parent::getfullpath()); } elseif( $this->image_type == IMAGETYPE_GIF ) { $this->image = imagecreatefromgif(parent::getfullpath()); } elseif( $this->image_type == IMAGETYPE_PNG ) { $this->image = imagecreatefrompng(parent::getfullpath()); } } function save($filename, $image_type=IMAGETYPE_JPEG, $compression=80, $permissions=777) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image,$filename,$compression); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image,$filename); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image,$filename); } if( $permissions != null) { chmod($filename,$permissions); } } function output($image_type=IMAGETYPE_JPEG) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image); } } function getWidth() { return $this->image_info[0]; } function getHeight() { return $this->image_info[1]; } function resizeToHeight($height) { $ratio = $height / $this->getHeight(); $width = $this->getWidth() * $ratio; $this->resize($width,$height); } function resizeToWidth($width) { $ratio = $width / $this->getWidth(); $height = $this->getheight() * $ratio; $this->resize($width,$height); } function scale($scale) { $width = $this->getWidth() * $scale/100; $height = $this->getheight() * $scale/100; $this->resize($width,$height); } function resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); echo "resized to:\n"; echo $width . "\n"; echo $height . "\n"; echo "imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight())\n"; imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); $this->image = $new_image; } function format(){ $width = $this->getWidth(); $height = $this->getHeight(); if ($width > $height){ return "landscape"; } if ($height > $width){ return "portrait"; } if ($height == $width){ return "square"; } } function isTooBig($maxsize){ $width = $this->getWidth(); $height = $this->getHeight(); if ($width > $maxsize || $height > $maxsize){ return true; } else{ return false; } } function __destruct() { ; } } ?> Now that I got this, I loop through images located in a folder that way: if ($handle = opendir($directory)) { while (false !== ($file = readdir($handle))) { //Instantiate the object $image = new classimage($directory . "/" . $file); //And do quite a lot of verification and particularly this: if ($image->format() == "landscape") { echo "width: " . $image->getWidth() . "\n"; echo "height: " . $image->getHeight() . "\n"; if ($image->isTooBig($maxsize_mini)) { $image->resizeToWidth($maxsize_mini); $image->save($directory . "/mini_" . $image->getfilename()); } } } And now to the problem: I echo'ed the resize function to see what's being run and I got that: picture1 imagecopyresampled(Resource id #26, Resource id #25, 0, 0, 0, 0, 608, 405.65, (), ()) picture2 imagecopyresampled(Resource id #27, Resource id #26, 0, 0, 0, 0, 250, 166.796875, (), ()) It looks like it's reusing an instantiation of the previous object and so on and so forth. In my mind, the way it should look is: picture1 imagecopyresampled(Resource id #2, Resource id #1, 0, 0, 0, 0, 608, 405.65, (), ()) picture2 imagecopyresampled(Resource id #2, Resource id #1, 0, 0, 0, 0, 250, 166.796875, (), ()) The previous object is destructed, the new one has the old id. how does that work? The reason I ask and wonder about this is because I'm having weird result for the resize such as a ridiculously small picture mini size in the actual mini size picture (250 px) except whatever is left is filled with black. The first part of this project was to pull a pdf file which was stored securely on the server into the browser for a user to look at it, but not long after the client asked if I could move the pdf down a bit and put a close button in.
Didnt think anytihng of it until I tried and it wasnt so easy, as the pdf always took over the full screen and I couldnt get it to recognise a div i placed on the page.
So have tried doing it the way below, which has sort of worked but I get a not as pdf error alert.
The user clicks a link to get the page below
<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>utgroup admin</title> <meta content="text/html; charset=utf-8" http-equiv="Content-type" /> </head> <body> <div style="position:relative; width:100%; height:30px; background-color:#FF0000; margin-bottom:40px; clear:both;"></div> <object data="spdf.php" type="application/pdf" width="100%" height="100%"> <p>It appears you don't have a PDF plugin for this browser. No biggie... you can <a href="myfile.pdf">click here to download the PDF file.</a></p> </object> </body> </html>Inside that I placed an object to try and pull the other page through which is creating the pdf, but its not quite working, any suggestions. session_start(); require_once('../auth.php'); include "../config.php"; error_reporting(E_ALL); ini_set('display_errors','On'); if(isset($_GET['pdf'])) { $stock_Id=$_GET['pdf']; $a=mysql_query("select Document from Documents where ID=$stock_Id") or die (mysql_error()); while($s=mysql_fetch_assoc($a)){ $cdocdocb=$s["Document"]; } } $file="$cdocdocb"; header('Content-type: application/pdf'); header('Content-Disposition: inline; filename="$file"'); @readfile($file); //echo "<p>$file</p>"; ?> Hi, i'm new in php. I'm building a website for my project. My prof wants us to combine php and html. .i've created the web page and it's working fine. .but when i'm about to make a link from my html page to my php page something went wrong. .although it's jumping to the php page,but this was what happened: Thanks for registering! "; } //The web form for input ability else { echo " \n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; //echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "" ; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; //echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo " \n"; } // EOF ?> Username: \n Password: \n First Name: \n Middle Name: \n Last Name: \n Nick Name: \n Gender: all my php codings showed up on the page. the page should be neat. my php file is located on my c drive on wamp folder. then my html file are located on the d: drive. . another help, if my php file is not in my wamp folder, let say its on another folder, how can i access it?. . please help me, and be patient on this one . .thanks so much I build almost all my pages in .html and then do my .php calls inside the .html code. A buddy of mine who's also a web developer told me that I'm doing it backwards, and I should be building .php pages and calling .html inside of them. I'm interested in knowing which of us is full of crap. My argument is that it's insanely hard to write .html code inside a .php page. (For me, anyway). Half the time, the page just pops up completely blank, and I have yet to figure out what Magic Word I'm using on the 50% of the time that it actually works. Opinions? Thoughts? Insults? I'm open to all comments... |