Codice PHP:
<?php require_once('Connections/lupin.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Recordset1 = 1;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_lupin, $lupin);
$query_Recordset1 = "SELECT * FROM lupin ORDER BY ID ASC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $lupin) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table>
<tr>
<td>ID
</td>
<td>Codice
</td>
<td>Descrizione
</td>
<td>Nome
</td>
<td>Udv
</td>
<td>Pagina
</td>
<td>Disp
</td>
<td>Bullet
</td>
</tr>
<?php
echo $row_Recordset1['ID'];
while ($row_Recordset1['ID'] <=99999999)
{
//dichiarazione del file
$source = file_get_contents("SITO CHE DEVO CERCARE?ProductId=$row_Recordset1['ID']");
//------------------------------------------------------------------
//controllo l'esistenza della pagina
$start_text = '<div class="box-heading"><h3>';
$end_text = "</h3>";
$start_pos = strpos($source, $start_text) + strlen($start_text);
$end_pos = strpos($source, $end_text,$stast_pos) - $start_pos;
//"INSERT INTO nome_tabella (campo_stringa) VALUES ('$stringa')"
$controllo = substr(substr($source, $start_pos, $end_pos),0);
if($controllo <> "Spiacenti")
{//------------------------------------------------------------------
//Dichiaro le variabili del Codice
$start_text = "Codice Prodotto";
$end_text = "</span";
//prendo il codice
$start_pos = strpos($source,$start_text) + strlen($start_text) + 38;
$end_pos = strpos($source,$end_text,$start_pos) - $start_pos;
$Codice = substr($source,$start_pos,$end_pos);
//------------------------------------------------------------------
//Dichiaro le variabili della descrizione
$start_text = 'product-pack-desc';
$end_text = '</span>';
//prendo il codice
$start_pos = strpos($source, $start_text) + strlen($start_text) + 43;
$end_pos = strpos($source,$end_text,$start_pos) - $start_pos;
$Descrizione = substr($source, $start_pos, $end_pos);
//------------------------------------------------------------------
//Dichiaro le variabili del nome
$start_text = 'product-desc';
$end_text = '</h3>';
//prendo il codice
$start_pos = strpos($source, $start_text) + strlen($start_text) + 2;
$end_pos = strpos($source,$end_text,$start_pos) - $start_pos;
$Nome = substr($source, $start_pos, $end_pos);
//------------------------------------------------------------------
//Dichiaro le variabili delle unità di vendita
$start_text = 'product-pack-size';
$end_text = '</span>';
//prendo il codice
$start_pos = strpos($source, $start_text) + strlen($start_text) + 89;
$end_pos = strpos($source,$end_text,$start_pos) - $start_pos;
$udv = substr($source, $start_pos, $end_pos);
//------------------------------------------------------------------
//Dichiaro le variabili della pagina
$start_text = 'product-page';
$end_text = '</span>';
//prendo il codice
$start_pos = strpos($source, $start_text) + strlen($start_text) + 78;
$end_pos = strpos($source,$end_text,$start_pos) - $start_pos;
$pagina = substr($source, $start_pos, $end_pos);
//------------------------------------------------------------------
//Dichiaro le variabili della pagina
$start_text = 'stock-value';
$end_text = '</span>';
//prendo il codice
$start_pos = strpos($source, $start_text) + strlen($start_text) + 14;
$end_pos = strpos($source,$end_text,$start_pos) - $start_pos;
$disp = substr($source, $start_pos, $end_pos);
//------------------------------------------------------------------
//Dichiaro le variabili dei bullet
$start_text = '<div class="bulleted-text-area clear">';
$end_text = '[/list]';
//prendo il codice
$start_pos = strpos($source, $start_text) + strlen($start_text) + 34;
$end_pos = strpos($source,$end_text,$start_pos) - $start_pos;
$bullet = substr($source, $start_pos, $end_pos);
if ($row_Recordset1['ID'] % 2 == 0)
{
echo '<tr style="background-color:#CCC">';
}
else
{
echo "<tr>";
}
echo "<td>";echo $row_Recordset1['ID'];
echo "</td>";
echo "<td>";echo $Codice;
echo "</td>";
echo "<td>";echo $Descrizione;
echo "</td>";
echo "<td>";echo $Nome;
echo "</td>";
echo "<td>";echo $udv;
echo "</td>";
echo "<td>";echo $pagina;
echo "</td>";
echo "<td>";echo $disp;
echo "</td>";
echo "<td>";echo $bullet;
echo "</td>";
echo "</tr>";
$query = "INSERT INTO Recordser1 (ID, Nome, Codice, udv, pagina, disp, bullet, descrizione) VALUES ('".$ID."', '".$Nome."', '".$Codice."', '".$udv."', '".$pagina."', '".$disp."', '".$bullet."', '".$descrizione."')";
mysql_query($query) or die ('errore di aggiornamento database');
else
}
?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>