Drakla,
in the script by script example you gave how and where would I put the statement you gave in an earlier post......
Also here is the code, for you to see......
include "header.php";
//include "authenticate.php";
$page_title = "Survey Admin: Weekly Random Drawing";
include "start_page.php";
// get SQL syntax to determine the date of the beginning of the week in
// which the date value in $weekdate falls, from the weekstart() function
// (defined in header.php). a week is considered to start on Sunday.
$qweekdt = weekstart($weekdate);
list($thisweek) = mysql_fetch_array(safe_query("select $qweekdt"));
print subtitle("Draw a winner for the week of $thisweek");
// get a list of qualifying entries for the given week.
$query = "select name, email, user_id from users
where week(create_dt) = week('$thisweek')
and year(create_dt) = year('$thisweek')
and name is not null and name != ''
and email is not null and email != '' and email like '%@%.%'
and age > 0
and country is not null and country != ''
";
$result = safe_query($query);
$tot = mysql_num_rows($result);
if ($tot == 0)
{
print subtitle("There were no entries for the week of $thisweek.");
}
else
{
if ($tot == 1)
{
// if there's only one entry, they win.
$winner = 0;
}
else
{
// seed random number generator.
// (do this only once in a script.)
mt_srand((double)microtime()*1000000);
// pick a winner from the result set by picking a random
// row number from the result set, starting at the first
// row (0).
$winner = mt_rand(0,$tot-1);
}
// move to the winner's row and grab the information.
mysql_data_seek($result, $winner);
list($name, $email, $user_id) = mysql_fetch_array($result);
// we'll be including the week date in the query string, so
// encode it
$urlthisweek = rawurlencode($thisweek);
print paragraph(
"<b>$name</b> $email "
, "<b><font color=red>WINNER!</font></b> "
,anchor_tag("admin_winners.php?weekdate=$urlthisweek"
."&what=notify&user_id=$user_id"
, "Notify Winner"
)
);
}
print <<<EOQ
<p>
<b>Past Weeks:</b>
<br>
EOQ;
// get SQL syntax to determine the starting date for entries based on
// the value of the create_dt field from the weekstart() function.
$pastwkqry = weekstart("create_dt");
// print out a list of previous weeks when entries have been made
$query = "select distinct $pastwkqry as pastweek from users order by pastweek";
$result = safe_query($query);
while (list($pastweek) = mysql_fetch_array($result))
{
$urlweek = rawurlencode($pastweek);
print anchor_tag("admin_get_winner.php?weekdate=$urlweek",$pastweek)
."<br>\n"
;
}
print "</p>\n";
include "admin_end_page.php";
?>
thanks for any help as ever!!