Hi,
I've got a question about adding a custom table event on loading a list page.
When the page loads, a certain delete and insert query should be run before it shows you the page. The code is as follows:
<?php
//Connect met database
$dbcnx = @mysql_connect('localhost', 'blabla', 'blabla');
if (!$dbcnx) {
exit('<p>Kan niet connecten met de server.</p>');
}
//Connect met grappen database
if (!@mysql_select_db('prototype')) {
exit('<p>Kan prototype database niet vinden</p>');
}
?>
<?php
//remove contents
$sqldelete = @mysql_query("DELETE FROM totaalbeschikbaar");
//Select query
$sql = @mysql_query("SELECT init, year(datum) as jaar, week(datum) as week, sum(Contract+Overwerk-Nietbeschikbaar) AS totaal FROM Personeelsvoorraad GROUP BY init, jaar, week");
while ($result = mysql_fetch_array($sql)){
$init = htmlspecialchars($result['init']);
$jaar = htmlspecialchars($result['jaar']);
$week = htmlspecialchars($result['week']);
$totaal = htmlspecialchars($result['totaal']);
$sql2 = "INSERT IGNORE INTO Totaalbeschikbaar SET
Init = '$init',
Jaar = '$jaar',
Week = '$week',
Totaal = '$totaal'";
@mysql_query($sql2);
}
I'm wondering if this is possible with the 'adding custom code' option, if yes, should I take special things in notice?.
Btw: It is possible to perform this script by placing alle the code in a file called 'total.php' and place it in the include directory. After that you have to edit '_list.php' file and add the following code in it:
'include("include/total.php"); ' just before 'CheckFileTime();' With my question I just want to know if you can also use the 'add custom code' option here.