Location: PHPKode > projects > MyTodos > show-events.php
<?
###################################################
#Copyright (C) 2002 Lihua Gao (hide@address.com) 
#
#$Id: show-events.php,v 1.1 2002/12/05 10:03:33 gaolihua Exp $
#
#This file is part of myTodos.
#
#myTodos is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#myTodos is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with myTodos; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#####################################################
?>
<?
session_start();
require_once("config.php");
include("header.php");
?>

<table cellspacing="0" class="table3">
	<tr  class="rowtitle">
		<td><h5>Events of <?=$_SESSION['firstname']." ".$_SESSION['lastname']?> </h5></td>
	</tr>
   <!-- empty line -->
	<tr><td>&nbsp;</td></tr>
	<tr>
    	<td>

         <FORM  action="delete-todos-action.php" method="POST" name="edit_todo_action" enctype="multipart/form-data" title="TITLE">


         <? 

         // select column display options
         $sql = "SELECT * FROM todos_display WHERE tdd_usr_id='".$_SESSION['userid']."'";
         $result = mysql_query($sql);
         $tdd_row = mysql_fetch_array($result, MYSQL_ASSOC);
         $cnt_fields = mysql_num_fields($result);
         $show_columns="";
         $i=0;
         while ($i < $cnt_fields) {
            $name = mysql_field_name($result, $i);
            if ($tdd_row[$name]=='y')
            $show_columns.=substr($name, 4, strlen($name)-4).",";
	         $i++;
         }
         $show_columns=substr($show_columns, 0, strlen($show_columns)-1)." ";

         //echo "show_columns:".$show_columns."\n";

         // select data
         $sql = "SELECT ".$show_columns." FROM todos, users where tds_usr_id=usr_id AND usr_email='".$_SESSION['login']."'";

         //echo "sql:".$sql."\n";

         $result = mysql_query($sql);
         $cnt_fields = mysql_num_fields($result);
         $cnt_rows = mysql_num_rows($result);


         if ($result) {

            echo "<P> <a href='display-option.php'>Display options</a>";

            echo "<TABLE border=0 cellPadding=2 cellSpacing=2>";

            // column names
            echo "<TR>";
            $i=0;
            while ($i < $cnt_fields) {
               $name = mysql_field_name($result, $i);
               echo "<TD bgColor=#00c0c0> $name </TD>";
	         $i++;
            }
            echo "<TD bgColor=#00c0c0> delete </TD>";
            echo "</TR>";

            // loop of events (values)
            $idlist="";
            while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
               echo "<TR>";

	            $i=0;
               while ($i < $cnt_fields) {
                  if ($i == 0) {
                     echo "<TD bgColor=#f6f6f6> <a href='edit-todo.php?tds_id=$row[$i]'>$row[$i]</a> </TD>";
                     $idlist.=$row[$i].",";
                  }
	               else {
                     echo "<TD bgColor=#f6f6f6> $row[$i] </TD>";
                  }
   	            $i++;
               }
               echo "<TD bgColor=#f6f6f6> <INPUT TYPE='CHECKBOX' name='$row[0]'> </TD>";
               echo "</TR>";
            }
            // TODO set this variable in Session object!
            $idlist=substr($idlist, 0, strlen($idlist)-1);

            echo "</TABLE>";
         } else {
            echo "<P>".mysql_error();
         }

         //echo "<P><a href='delete-todos-action.php?idlist=$idlist'>Delete selected events</a>";
         ?>

   		<input type="hidden" name="idlist" value="<?=$idlist?>">
         <table>
         <!-- empty line -->
	      <tr><td>&nbsp;</td></tr>
         <tr><td align="right">
         <INPUT TYPE="SUBMIT" name="submit" value="delete events">
         </td></tr>
         </table>
         </FORM>


      </td>
	</tr>
</table>


<?
include("footer.php");
?>
Return current item: MyTodos