View Single Post
Old 03-19-2005, 10:36 AM   #5 (permalink)
JimAdkins
Registered User
 
Join Date: Mar 2005
Posts: 8
JimAdkins is on a distinguished road
Cool. Just tried that, and got the same result. Let me post the attendance.php file. This file basically shows info from a db that can be changed to show whether that person was in atendance or not. It also has a link that goes back to the index.php page at the top of the page to help with site navigation. All I'm doing is logging in, choosing a month, it goes to the attendance page, I view the data, then click on the link that goes back to the index.php page. after I click that link, it says to log in again.

Also, I'm still very new to programming in PHP. So this may seem to be not programmed right.

PHP Code:
<?php

// connect to database
include("connect.php");

// include auth and nav
include("auth.php");


$username="***";
$password="***";
$database="***";

$month=$_GET['month'];

if (
$month == '')
{
    echo 
"<html><title>Error</title>
    <font face=Arial size=2>>&nbsp&nbsp<a href='/church/index.php'>Home</a></font><br>
    You must choose a month. Please click home and choose again.</html>"
;
    return 
EOF;
}


mysql_connect('localhost'$username$password) or die ('I cannot connect to the database because: ' mysql_error());
mysql_select_db($database) or die( "Unable to select database");
$query="SELECT Name, $month, ID FROM attendance ORDER BY 'Name'";
$result=mysql_query($query);

$num=mysql_numrows($result);


echo 
"<html><head><title>Attendance Results</title></head>
<font face=Arial size=2>>&nbsp&nbsp<a href='/church/index.php'>Home</a></font><br>
<center><b><font face=Arial size=5>Attendance for $month</font></b><br><br>
<table border='1' cellspacing='2' cellpadding='2'>
<thead><tr><th><font face=Arial size=3><u>Name</u></font></th><th>
<font face=Arial size=3><u>Attended</u></font></th>
<th><font face=Arial size=3><u>Name</u></font></th><th>
<font face=Arial size=3><u>Attended</u></font></th>
<th><font face=Arial size=3><u>Name</u></font></th><th>
<font face=Arial size=3><u>Attended</u></font></th></thead>"
;

mysql_close();

$i=0;
while (
$i $num) {

    
$name=mysql_result($result,$i,"Name");
    
$monthht=mysql_result($result,$i,$month);
    
$id=mysql_result($result,$i,"ID");

    
$checked1="";
    
$checked0="";

    if(
$monthht==0)
        {
        
$checked0="checked";
        }
    else
        {
        
$checked1="checked";
        }
        if (
$i == OR $i == OR $i == OR $i == 12 OR $i == 15 OR $i == 18 OR $i == 21 OR $i == 24 OR $i == 27 OR $i == 30 OR $i == 33 OR $i == 36 OR $i == 39 OR $i == 42 OR $i == 45 OR $i == 48 OR $i == 51 OR $i == 54 OR $i == 57 OR $i == 60 OR $i == 63 OR $i == 66 OR $i == 69 OR $i == 72 OR $i == 75 OR $i == 78 OR $i == 81 OR $i == 84 OR $i == 87 OR $i == 90 OR $i == 93 OR $i == 96 OR $i == 99)
        {
            echo 
"<tr>";
        }
    echo 
"<td width=100 align=center><font face=Arial size=2>$name</td></font><td width=100 align=center>
    <form action='update.php?PHPSESSID=.session_id()' type=get>
    <input type=hidden name='month' value=$month>
    <input type=hidden name='id' value=$id>
    <input type=hidden name='act' value='updateatt'>
    <input type=radio name='results' onClick='this.form.submit()' value=1 $checked1><font face=Arial size=2>Yes&nbsp&nbsp</font>
    <input type=radio name='results' onClick='this.form.submit()' value=0 $checked0><font face=Arial size=2>No&nbsp&nbsp</font>
    </td></form>"
;

    
$i++;
}
echo 
"</table></center></html>"

?>
JimAdkins is offline   Reply With Quote