Jump to content

Mike088

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Everything posted by Mike088

  1. Thanks mrMarcus that 'file_get_contents' does the trick well and overall makes everything alot easier too This is what I ended up with: $html = file_get_contents("http://www.website.com/page"); $html = str_replace("page1","page2",$html); $html = str_replace("help","helpme",$html); echo $html; To easy. Cheers, Mike.
  2. Anyone else have any suggestions on this?
  3. Ugh well do you know of any other ways to grab that html and display it? I guess I'm just basically duplicating the content but replacing text within the links. The html is dynamically generated and I need to swap out text within the links so that's why I can't just use it or an iframe
  4. Hey everyone, I'm a little stuck here, I've just started playing around with DOM and parsing. I'm down to the very last thing that I want to grab and then display which is just standard text on my html page, it doesn't have any attributes or title tags; it's just plain text... and I can't seem to grab it :'( Here's the html code I'm trying to parse (in bold is what I'm after) giving it the value $price: <body> $10.00<a href="http://www.site1.com/page1/data/help" title="Site1">Site1</a><br/> $20.00<a href="http://www.site2.com/page1/data/help" title="Site2">Site2</a><br/> $30.00<a href="http://www.site3.com/page1/data/help" title="Site3">Site3</a><br/> $40.00<a href="http://www.site4.com/page1/data/help" title="Site4">Site4</a><br/> </body> Here's where I'm at: // parse the html into a DOMDocument $dom = new DOMDocument(); @$dom->loadHTML($html); // grab text from the page $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate("/html/body//a"); for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); $url = $href->getAttribute('href'); $url2 = $href->getAttribute('title'); $price = "not sure what to put here..."; $newurl = str_replace("page1","page2",$url); $newurl2 = str_replace("help","helpme",$newurl); echo "<br /> From". $price ." <a href='" . $newurl2 . "'>$url2</a>"; } Any help would be much appreciated, Cheers
  5. Thanks for that drisate, so that's the outputing of the information? I'm new to mysql so how am I to actually get the submit form data into a mysql database to recall it? Is there any tutorials or is it something simple?
  6. Hey everyone, I am trying to accomplish something that I thought would be rather easy to find instructions on the web... however I can't find a thing ??? My dilemma is as follows. I have a submit form and I want to simply have some text below it stating the last 10 entries along with another area of text that is displaying the 10 most popular entries. I was told to try using a MySQL database for something similar to this but again can't find any information on how to do so If you could help out please feel free to it would be much appreciated
  7. Hey everyone, I've noticed some php coded web pages in which when you hover over a link there is nothing displayed in the browsers status area along with right clicking on the link will not show a properties selection in the menu... How is this accomplished? Any help would be much appreciated
  8. OOH I think I have it, just added another counting variable which does a recount and it looks to be working... well the $query variable is containing the correct stuff generated from the 2nd class only I'm pretty beat so I think I'll leave it there for the time being and mark this solved. If it buggers up I'll come re-open it Thanks for the help mate.
  9. positive mate I'll keep slaving away at it, would I have to do anything special with the print command in order to get it to reflect the correct output? (I'm just using print $query; at the end).
  10. I want it to run all classes if the count is below 60 and if it is above 60 I only want it to run the Answers2 class, in order to get the count it's running through all classes first tho. I want it to then output either all classes or the answers2 class at the end using my print command of the $query.
  11. Well I am using a print command later on for $query and it gives the info from all classes even if the count value is above 60
  12. Ok I guess they will all run originally to get the $results then I want: if the results returned are greater than 60 to maybe re-run it so that it only runs through the $entry = array_merge( $entry, cEntry::getAnswers2($word)); and then outputs that to the $query variable. If you get that lol :-\
  13. Hey all, basically I have a PHP class which details different things and I am wanting to have them all work BUT if the count value of another variable ($results) is greater than 60 then I want it to only run the one variable type. The generated stuff from the class is then output to another variable ($query) $word = trim($_POST["word"]); $entry = array(); $entry = array_merge( $entry, cEntry::getAnswers1($word)); $entry = array_merge( $entry, cEntry::getAnswers2($word)); $entry = array_merge( $entry, cEntry::getAnswers3($word)); $entry = array_merge( $entry, cEntry::getAnswers4($word)); $results = count ($entry); if ($results > 60) $entry = array_merge( $entry, cEntry::getAnswers2($word)); $query = implode (',', $entry); I am having trouble getting it to do so, help would be appreciated thanks
  14. Hey everyone I'm trying to encode a variable into UTF8 char set, I don't want the whole thing UTF8 just this variables data. How would I go about doing that? My variable as follows: $link = ("<a href=\"http://$url\blahblah">Link Here</a>"); I tried and failed with this: string utf8_encode (string $link); So all up I want to encode the variable then print/echo it. Help appreciated
  15. Hey all, I am having trouble with printing a hyperlink which includes insertion of variables to complete the link. This is what I got... which is most likely wrong lol: <?php print ("<a href=\"http://mysite.com/place/"$page"/blahblah"$text">Click Me</a>"); ?> I'm getting "Parse error: syntax error, unexpected T_PRINT" Help appreciated
  16. Hey all I am trying to use an if statement thing to assign data to a variable. Using the if statement I want to grab data from another variable which is getting its data from a html select form. Basically I want to pull two different things from the select form that are related to the one thing if you get that lol. So my code is like this (simplified): <select name="website"> <option value="100-01">Url1</option> <option value="100-02">Url2</option> <?php $url = $_POST['website']; $result = "" if ($url==100-01) $result = headache; else if ($url==100-02) $result = biggerheadache; ?> I am getting an error: Parse error: syntax error, unexpected T_IF I am not to sure if I am writing the if statement correctly or if this is actually the easiest way to go about doing what I want to do, any help much appreciated
  17. Hey all, got myself in a little pickle (keep in mind I am relatively new to PHP lol). So I have a HTML selection box with some values now I want to then use what the user selected within a variable later on. So here I have the selection box code: <select name="website"> <option value="100-01">Url1</option> <option value="100-02">Url2</option> And now I want what is selected into a variable called $url so umm: $url = ''; To do this I think I need something like: if option with value 100-01 is selected then $url = url1 else if option with value 100-02 is selected then $url = url2 I read something about using $this-> but I'm not sure... so how would I go about making the above work lol? Cheers, Mike
  18. Thanks, new it would be something simple like that (probably just need some more coffee). To be honest I don't know why I didn't think about the fundamental fact that php executes from top to bottom lol EDIT: Uhh this is SOLVED but somethings up with the 'Topic Solved' button giving me a database error.
  19. Basically I am making a search query using the ebay API... uhh I don't think you will need to have any knowledge of the API to help here as all I need to do is fix something up regarding the variables I have set. So when I first load the page I am getting an error about an undefined variable ($query). What I have worked out is basically that is because the variable = 'the word submitted into the form' and obviously when it first loads there is no word submitted... how do I go about making it not try and load that variable until the search is executed through the form input? Here is my code: <?php if(isset($_POST['submit'])) { $query = trim($_POST["word"]); } error_reporting(E_ALL); // turn on all errors, warnings and notices for easier debugging $SafeQuery = urlencode($query); $endpoint = 'http://open.api.ebay.com/shopping'; // URL to call $responseEncoding = 'XML'; // Format of the response // Construct the FindItems call $apicall = "MY APP ID AND SUCH YOU DONT NEED TO SEE"; // Load the call and capture the document returned by the Shopping API $resp = simplexml_load_file($apicall); // Check to see if the response was loaded, else print an error if ($resp) { $results = ''; // If the response was loaded, parse it and build links foreach($resp->Item as $item) { $link = $item->ViewItemURLForNaturalSearch; $title = $item->Title; // For each result node, build a link and append it to $results $results .= "<a href=\"$link\">$title</a><br/>"; } } // If there was no response, print an error else { $results = "Oops! Must not have gotten the response!"; } ?> <html> <head> <title>eBay Search Results For <?php print $query ?></title> </head> <body> <form action="Working.php" method="post"> Enter Your Word: <input type="text" name="word" /> <input type="submit" value="Submit" name="submit"/> </form> <h1>eBay Search Results</h1> <?php echo $results;?> </body> </html> I am pretty much a noob lol so I give you permission to laugh at me with my attempt to do this kind of stuff Any help much appreciated.
  20. Thank you all very much for the help (/answers lol)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.