Jump to content

Calling ALL Freaks "PHP Freaks that is :-)


Modernvox

Recommended Posts

$CL = "Craigslist";

 

I have my code all complete with one exception.

After I select a State from the drop down box the script scrapes the appropriate data from CL and displays it on the page. That's Great, right? Right!  But it also transforms all my buttons and images into a link which is the same link from the last results returned from the original request?

 

If you go to http://dezi9er.net16.net/search.php and just press submit the first attempt will return the results the way it is suppose to, But Now it turns everything into a link? click on the bouncer image or any of the buttons and it will take you to a CL listing.

 

This is crazy!  What is going on here?

Link to comment
https://forums.phpfreaks.com/topic/187796-calling-all-freaks-php-freaks-that-is/
Share on other sites

But it also transforms all my buttons and images into a link which is the same link from the last results returned from the original request?

 

Umm, If you're scraping links they'd become links after displaying them? What is your code? You're doing nothing but displaying a website to us without any relevant code.

its making all the navigation etc link to the last search result... are you closing the anchor tag correctly (</a>)?

or is this last link overriding a variable which is storing the links for the navigation etc..?

you'll have to post your code.

My Bad

 <?php
$st = isset($_POST['submit']) ? $_POST['state'] : '';

$urls = array();

if ($st == "AL") 
{

$urls = array("http://auburn.craigslist.org", "http://bham.craigslist.org");
}
else if ($st == "AK") 
{
$urls= array("http://anchorage.craigslist.org");
}
foreach ($urls as $url) {
    $html = file_get_contents("$url/muc/");

    preg_match_all('/<a href="([^"]+)">([^<]+)<\/a><font size="-1">([^"]+)<\/font>/s', $html,$posts,PREG_SET_ORDER);
    //echo "<pre>";print_r($posts);
$i = 1; //set start point;
$limit = 60; //set limit;
foreach ($posts as $post) {
   //print $post[0]; //HTML
   $post[2] = str_ireplace($url,"",$post[2]); //remove domain
   echo "<a href=\"$url{$post[1]}\">{$post[2]}<font size=\"3\">{$post[3]}<br />";
   print "<BR />\n";


   if ($i == $limit)
   {
      break;
   }
  $i++; 
}

}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.