to use a session variable
will only allow 1 time per session
so if close down browser and start a new browser session
that variable will be lost, and this can be run again
to make a permanent indication,
we would need to store a variable flag in cookie or in database
or make some test of that last row in database
I dont know when or how often this INSERT should be allowed
because you have not told much details of it
<?php
// start session, and see if has been run before - redirect to index.php
session_start();
if( isset($_SESSION['been_run']) && $_SESSION['been_run'] == 1 ){
header( 'location: index.php' );
exit;
}
/* Connect to database */
$db= mysql_connect("localhost", "", "");
mysql_select_db("", $db);
$lastrow = mysql_query("SELECT id
FROM current
ORDER BY id DESC LIMIT 1");
while($row= mysql_fetch_array($lastrow))
{
$JOB= "BOB";
$newlastrow= ($row["o_id"]+1);
printf($BOB);
printf($newlastrow);
}
$today = date("F j, Y, g:i a"); // Date to Print
echo "\n $today";
$date = date("Ymd"); // Date to Database
$sql= "INSERT INTO current
VALUES ('$newlastrow', NULL, '$date', '1', '1')";
mysql_query($sql);
// set 'been run' flag variable
$_SESSION['been_run'] = 1;
?>