CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Page Scrapper and file get contents

Print topic Send  topic

Author Message
westeire

Posts: 20
Posted: 10/24/2007, 5:12 AM

I have a page scrapper script that I use to retrive sports fixtures from a site that I have permission to us
currently I hardcode the url in to the script and this works fine.
the Number of pages is growing so I would now like to store the page address in a data base.

Pages are

fixtures.php : This page calls the retrive.php script and displays the fixtures that have been retrived.
retrive.php : This script retrives the page content and reformats it to suit my needs

on the fixtures page I have a label called fixtures with the following before show event Custom Code

// Custom Code
// -------------------------
$output = implode("",file("http://localhost/league/retrive.php"));
$fixtures->SetValue($output);
// -------------------------
// End Custom Code

PROBLEM
I am passing a link parameter "record_id" to the fixtures page but this link parameter is not reaching the retrive script
my where clause needs the link parameter $record_id to make the selection ,
I know the script works because If I use WHERE record_id = 3"; it works fine

Here is the code that makes the selection

if(isset($_GET['$record_id'])){$record_id = $_GET['$record_id'];}

$sql = "SELECT page_url FROM my_table WHERE record_id = '$record_id'";
$result = mysql_query($sql);
if (!$result) {
echo "Cant run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No records found,";
exit;
}
while ($row = mysql_fetch_assoc($result)) {
$page_url = $row["page_url"];
code continues...............

Any help would be appreciated thank you.



_________________
Give a hungry man a fish and feed him for a day,
Teach him to fish and feed him for life.
View profile  Send private message
mamboBROWN


Posts: 1713
Posted: 10/24/2007, 5:17 PM

westeire
Did you confirm that $_GET is actually getting a value?? You could also try using the CCGetParam function as well. Maybe these links will help you: http://docs.codecharge.com/studio31/html/Components/Fun...tParam.html?toc
http://docs.codecharge.com/studio31/html/ProgrammingTec...Attributes.html
View profile  Send private message
wkempees


Posts: 1679
Posted: 10/25/2007, 2:00 AM

$sql = "SELECT page_url FROM my_table WHERE record_id = " . $record_id;


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
westeire

Posts: 20
Posted: 11/03/2007, 8:13 AM

Thanks for the help you sent me on the right direction Mambo
and after a little study in the help files i came up with the following code works perfectly.
Mick.
//fixtures_BeforeShow @25-8678990D
function fixtures_BeforeShow(& $sender)
{
$fixtures_BeforeShow = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $fixtures; //Compatibility
//End fixtures_BeforeShow
//Custom Code @26-2A29BDB7
// -------------------------
// Read division from URL
$division = CCGetFromGet("division", 0);
if ($division > 0) {
// Open connection
$db = new clsDB_my_connection();
$SQL = "SELECT page_address, division_id FROM fixtures WHERE division_id=".$division;
$db->query($SQL);
$Result = $db->next_record();
if ($Result) {
$page_address = $db->f("page_address");
$division = $db->f("division_id");
}
$db->close();
$source_file = @file_get_contents("$page_address") or die ("Sorry I cant find that page <a href=\"fixtures.php\">Return To Fixtures</a>");
$arr_remove = array("\r", "\n", "\t", "\s");
$stripped_file = str_replace($arr_remove, '', $source_file);
//starting position
$strpos_start_section = strpos($stripped_file, '<table border="0" cellpadding="2" cellspacing="0" width="100%">');
//ending position
$strpos_end_section = strpos($stripped_file, '</table>',
$strpos_start_section) + 8;
$len_section = $strpos_end_section - $strpos_start_section;
$section = substr($stripped_file, $strpos_start_section, $len_section);
$section = str_replace("<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\">","<table class=\"fixture_grid\" cellpadding=\"0\" cellspacing=\"0\" width=\"500\" align=\"center\">", $section);
$section = str_replace("<td></td>","<td> </td>",$section);


// Show fixtures here
$fixtures->SetValue($section);
}
//if that dont work try this
else { $fixtures->SetValue("To start You Need to make A selection from the dropdown list,"); }
// -------------------------
//End Custom Code
//Close fixtures_BeforeShow @25-32E4C0C0
return $fixtures_BeforeShow;
}
//End Close fixtures_BeforeShow



_________________
Give a hungry man a fish and feed him for a day,
Teach him to fish and feed him for life.
View profile  Send private message
mamboBROWN


Posts: 1713
Posted: 11/04/2007, 8:17 AM

westeire
Glad that I could be of help.
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.