P.S. I stripped out all the unimportant stuff like the <meta> info, etc.
Code: Select all
<?php
$mysql_host = "localhost";
$mysql_user = "root";
$mysql_pass = "";
$mysql_db = "tiki";
$confirm_message = "";
$user = 'jbutler';
// mysql connect
$link = mysql_connect($mysql_host, $mysql_user, '');
if (!$link) die('Could not connect: ' . mysql_error());
$db_selected = mysql_select_db($mysql_db, $link);
if (!$db_selected) die ('Can\'t use tiki : ' . mysql_error());
$clock_history_query = "
SELECT
els_punch_times.user,
els_punch_times.in_time,
els_punch_times.out_time,
els_punch_times.time_stamp,
els_punch_times.status
FROM els_punch_times
WHERE els_punch_times.user = '$user'";
//returns the result set
$clock_history_ret = mysql_query($clock_history_query);
if (!$clock_history_ret) {
die('Invalid query: ' . mysql_error());
}
//parses the array and assigns a result to a new variable
while ($history_array = mysql_fetch_assoc($clock_history_ret)) {
$results[$i++] = $history_array;
}
?>
<title>Web Based Clock In</title>
<script type="text/javascript">
var bar = document.createTextNode(" ");
var foo = document.createTextNode("<?php
foreach($results as $history) {
echo "$history[user], $history[in_time], $history[out_time], $history[time_stamp], $history[status]\n;
} ?>")
</script>
</head>
<body>
<br />
<i onclick="document.body.replaceChild(foo,bar);">Show History</i>
<br />
<script type="text/javascript">
document.body.appendChild(bar);
</script>
</body>
</html>