[RÉSOLU] Affichage des données Google Webmaster à partir de l'API avec tableau triable

« Page précédente
0
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="tablesorter-master/jquery.tablesorter.min.js"></script>
<script>
$(document).ready(function()
{
$("#myTable").tablesorter();
}
);
</script>

<style>
table.tablesorter {
font-family:arial;
background-color: #CDCDCD;
margin:10px 0pt 15px;
font-size: 8pt;
width: 100%;
text-align: left;
}
table.tablesorter thead tr th, table.tablesorter tfoot tr th {
background-color: #e6EEEE;
border: 1px solid #FFF;
font-size: 8pt;
padding: 4px;
}
table.tablesorter thead tr .header {
background-image: url(bg.gif);
background-repeat: no-repeat;
background-position: center right;
cursor: pointer;
}
table.tablesorter tbody td {
color: #3D3D3D;
padding: 4px;
background-color: #FFF;
vertical-align: top;
}
table.tablesorter tbody tr.odd td {
background-color:#F0F0F6;
}
table.tablesorter thead tr .headerSortUp {
background-image: url(asc.gif);
}
table.tablesorter thead tr .headerSortDown {
background-image: url(desc.gif);
}
table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp {
background-color: #8dbdd8;
}
table.tablesorter tbody tr:hover td{ background-color:#eeeeee !important; }
</style>

<a href="?site=1">site1.com</a>
<a href="?site=2">site2.com</a>
<?php
include 'gwtdata.v2.php';
try {
$email = "[email protected]";
$password = "MOT_DE_PASSE";
# If hardcoded, don't forget trailing slash!

if( $_GET['site'] <= 1 )
$website = "http://www.site1.com/";
if( $_GET['site'] == 2 )
$website = "http://www.site2.com/";

$gdata = new GWTdata();
if($gdata->LogIn($email, $password) === true)
{
$gdata->DownloadCSV($website);

//var_dump($gdata->_downloaded[1]);

$f = fopen($gdata->_downloaded[1], "r");

echo '<table id="myTable" class="tablesorter">';
$line = fgetcsv($f);
echo "<thead><tr>";
foreach ($line as $cell) {
echo "<th>" . htmlspecialchars($cell) . "</th>";
}
echo "</tr></thead><tbody>";

while (($line = fgetcsv($f)) !== false) {
echo "<tr>";
foreach ($line as $cell) {
echo "<td ".( $cell < 0 ? 'style="background:#FFCCCC;"' : '' ).">" . htmlspecialchars($cell) . "</td>";
}
echo "</tr>";
}
echo '</tbody></table>';

fclose($f);

}
} catch (Exception $e) {
die($e->getMessage());
}
?>
RÉSOLU
Posté par William
Posée le 2 juin 2015 9 h 16 min
57 vues
    « Page précédente