Jump to content

zelllibin

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

zelllibin's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I need help to fix this index error and index offset error... <html> <head> </head> <body> <?php // The include file for PEAR::MDB2 require_once 'MDB2.php'; // Initializing the Global variables $empname=array("Ng Boon Kiat","Tan Kok Kang","Chua Cheng Ann","Cai Yong","Rex Tumewah","Tan Chuon Hee", "Wong Su-Yin","Aw Swee Keng","Lim Yen","Rudy Karyadi","Denny Prasetya","Tan Wee-Aik (Jac)","Roy Ong", "Lorical Goh","Wong Khai Thye","Tan Han Siong","Azreen bin Osman","Mohamed Ibrahim","Kelvin Wong", "Wilson Goh","Lee Yat Wah","Foang Wan Heng","Ter Khwee Heng","Diego Alonso","Shabbar Jambughodawala", "Noh Bin Salleh","Joshua Lee Joo Eng","Leon Ho","Shiley Chua","Susan Seow"); // Get the Selected year if (isset($_POST['SelectYear'])) $SEL_YEAR=$_POST['SelectYear']; else $SEL_YEAR=date("Y"); $CURR_YEAR=date("Y"); // Get the Current Month in numeric form if (isset($_POST['SelectMonth'])) $CURR_MONTH=$_POST['SelectMonth']; else $CURR_MONTH=date("m"); // Convert the Current Month into words $jd2=cal_to_jd(CAL_GREGORIAN,(int)$CURR_MONTH, 1,(int)$SEL_YEAR); $CURR_MONTH_WORDS=jdmonthname($jd2,1); $CURR_MONTH_WORDS=strtoupper($CURR_MONTH_WORDS); echo "<b><font face='Garamond' color='#0080FF'>LEAVE CALENDAR FOR $CURR_MONTH_WORDS, $SEL_YEAR</b>"; echo "</br>"; echo "</br>"; //Get the Current Date in numberic form $CURR_DATE=date("d"); $DAYS_IN_CURR_MONTH=cal_days_in_month(CAL_GREGORIAN,$CURR_MONTH,$SEL_YEAR); /* National Holidays for 2008 1 Jan New Year's Day. 7-8 Feb Chinese New Year. 21 Mar Good Friday. 1 May Labour Day. 19 May Vesak Day (Birth of the Buddha). 9 Aug National Day. 1 Oct Hari Raya Puasa (End of Ramadan). 28 Oct Deepavali. 8 Dec Hari Raya Haji (Feast of the Sacrifice). 25 Dec Christmas Day */ // Declaring National Holidays // The declaration is done in such a way that first you declare the date and then the month of holiday $NATIONAL_HOLIDAYS=array("1","1", "7","2", "8","2", "21","3", "1","5", "19","5", "9","8", "1","10", "28","10", "8","12", "25","12"); /* AID ACTIVITYTYPE 1 Leave(planned/projected) 2 Leave(approved/confirmed) 3 Overseas Training/Meeting 4 Overseas Assignment 5 Local Training 6 Saturday 7 Sunday 8 Public Holidays 9 National Service */ $AID_ABBREV=array("","LPP","LAC","OTM","OSA","LTR","SAT","SUN","NHO","NSE"); /*for($i=0;$i<sizeof($AID_ABBREV);$i++) { echo $AID_ABBREV[$i]; echo "</br>"; } */ /* Make the Calendar according to each day corresponding to a column.Each row corrresponds to an employee */ for($i=0;$i<=sizeof($empname);$i++) { for($j=0;$j<($DAYS_IN_CURR_MONTH+1);$j++) { if($i==0 && $j==0) $cal[$i][$j]="NAME"; if($i==0 && $j!=0) $cal[$i][$j]=$j; if($i!=0 && $j==0) $cal[$i][$j]=$empname[$i-1]; if($i!=0 && $j!=0) { // Finding out the Day of Week $jd=cal_to_jd(CAL_GREGORIAN,$CURR_MONTH,$j,$SEL_YEAR); $DAY_OF_WEEK=jddayofweek($jd,1); // Mapping Saturdays and Sundays onto the calendar if($DAY_OF_WEEK=="Sunday") $cal[$i][$j]="SUN"; elseif($DAY_OF_WEEK=="Saturday") $cal[$i][$j]="SAT"; // Mapping the National Holidays into the Calendar // The Mapping is done only for the Current year if($SEL_YEAR==$CURR_YEAR) { for($k=0;$k<sizeof($NATIONAL_HOLIDAYS);$k+=2) { $x=$k+1; if($NATIONAL_HOLIDAYS[$x]==$CURR_MONTH) { if($NATIONAL_HOLIDAYS[$k]==$j) $cal[$i][$j]="NHO"; } } } } } } if($SEL_YEAR>$CURR_YEAR) $CURR_MONTH=$CURR_MONTH+12; //echo "CURRENT MONTH IS $CURR_MONTH</br>"; //$match="NO"; // Initializing $EMPACTIVITY to 0 for($i=0;$i<sizeof($empname);$i++) { for($k=0;$k<sizeof($AID_ABBREV);$k++) $EMPACTIVITY[$i][$k]=0; } // Connect to the database and fetch the leave record for each user // And update it for the current month // Preparing the Data Source Name $dsn_calendar = 'mysql://root:password@localhost/TRACKER'; // Connecting to the Database 3GDBData $mdb_calendar =& MDB2::factory($dsn_calendar); if (PEAR::isError($mdb_calendar)) { die($mdb_calendar->getMessage()); } //else // echo "Successfully Connected to TRACKER</br>"; for($i=1;$i<=sizeof($empname);$i++) { $res =& $mdb_calendar->query("SELECT * FROM LEAVETRACKER WHERE SID='$i' ORDER BY STARTDATE,ENDDATE"); for ($k=0;($row = $res->fetchRow());$k++) { // Extract the information from each row // Extracting SID $SID_CALENDAR=$row[1]; // Extracting STARTDATE $STARTDATE_CALENDAR=$row[2]; // Extracting ENDDATE $ENDDATE_CALENDAR=$row[3]; // Extracting Activity ID - AID $AID_CALENDAR=$row[4]; // Extract the DAY, Month and Year from STARTDATE //The function split returns an array of strings and the strings are separated on the basis of [/.-] list($STARTMONTH_CALENDAR, $STARTDAY_CALENDAR, $STARTYEAR_CALENDAR) = split('[/.-]', $STARTDATE_CALENDAR); //echo "Month: $STARTMONTH_CALENDAR; Day: $STARTDAY_CALENDAR; Year: $STARTYEAR_CALENDAR</br>\n"; // Extract the DAY, Month and Year from ENDDATE //The function split returns an array of strings and the strings are separated on the basis of [/.-] list($ENDMONTH_CALENDAR, $ENDDAY_CALENDAR, $ENDYEAR_CALENDAR) = split('[/.-]', $ENDDATE_CALENDAR); //echo "Month: $ENDMONTH_CALENDAR; Day: $ENDDAY_CALENDAR; Year: $ENDYEAR_CALENDAR</br>\n"; if($ENDYEAR_CALENDAR>$CURR_YEAR) $ENDMONTH_CALENDAR=$ENDMONTH_CALENDAR+12; //echo "END MONTH CALENDAR is $ENDMONTH_CALENDAR</br>"; // Required to update cal for the correct year by looking into the months of the corresponding year if($SEL_YEAR==$STARTYEAR_CALENDAR) { if($STARTYEAR_CALENDAR==$ENDYEAR_CALENDAR) { //echo "PING</br>"; if($CURR_MONTH>12) $CURR_MONTH=$CURR_MONTH%12; if($ENDMONTH_CALENDAR>12) $ENDMONTH_CALENDAR=$ENDMONTH_CALENDAR%12; } //echo "CURR_MONTH is $CURR_MONTH</br>"; //echo "START_MONTH is $STARTMONTH_CALENDAR</br>"; //echo "END_MONTH is $ENDMONTH_CALENDAR</br>"; if($CURR_MONTH>$STARTMONTH_CALENDAR && $CURR_MONTH<$ENDMONTH_CALENDAR) { for($j=1;$j<($DAYS_IN_CURR_MONTH+1);$j++) { if($cal[$SID_CALENDAR][$j]!="SAT" && $cal[$SID_CALENDAR][$j]!="SUN" && $cal[$SID_CALENDAR][$j]!="NHO") $cal[$SID_CALENDAR][$j]=$AID_ABBREV[$AID_CALENDAR]; } } if($CURR_MONTH==$STARTMONTH_CALENDAR && $CURR_MONTH!=$ENDMONTH_CALENDAR) { for($j=$STARTDAY_CALENDAR;$j<($DAYS_IN_CURR_MONTH+1);$j++) { if($cal[$SID_CALENDAR][$j]!="SAT" && $cal[$SID_CALENDAR][$j]!="SUN" && $cal[$SID_CALENDAR][$j]!="NHO") $cal[$SID_CALENDAR][$j]=$AID_ABBREV[$AID_CALENDAR]; } } if($CURR_MONTH==$ENDMONTH_CALENDAR && $CURR_MONTH!=$STARTMONTH_CALENDAR) { for($j=1;$j<=$ENDDAY_CALENDAR;$j++) { if($cal[$SID_CALENDAR][$j]!="SAT" && $cal[$SID_CALENDAR][$j]!="SUN" && $cal[$SID_CALENDAR][$j]!="NHO") $cal[$SID_CALENDAR][$j]=$AID_ABBREV[$AID_CALENDAR]; } } if($CURR_MONTH==$ENDMONTH_CALENDAR && $CURR_MONTH==$STARTMONTH_CALENDAR) { for($j=$STARTDAY_CALENDAR;$j<=$ENDDAY_CALENDAR;$j++) { if($cal[$SID_CALENDAR][$j]!="SAT" && $cal[$SID_CALENDAR][$j]!="SUN" && $cal[$SID_CALENDAR][$j]!="NHO") $cal[$SID_CALENDAR][$j]=$AID_ABBREV[$AID_CALENDAR]; } } } /*******/ elseif($SEL_YEAR>$STARTYEAR_CALENDAR) { //echo "PING</br>"; //if($CURR_MONTH>12) // $CURR_MONTH=$CURR_MONTH%12; //echo "$CURR_MONTH</br>"; //if($ENDMONTH_CALENDAR>12) //$ENDMONTH_CALENDAR=$ENDMONTH_CALENDAR%12; //echo "CURR_MONTH is $CURR_MONTH</br>"; //echo "START_MONTH is $STARTMONTH_CALENDAR</br>"; //echo "END_MONTH is $ENDMONTH_CALENDAR</br>"; if($SEL_YEAR==$ENDYEAR_CALENDAR) { if($CURR_MONTH>$STARTMONTH_CALENDAR && $CURR_MONTH<$ENDMONTH_CALENDAR) { for($j=1;$j<($DAYS_IN_CURR_MONTH+1);$j++) { if($cal[$SID_CALENDAR][$j]!="SAT" && $cal[$SID_CALENDAR][$j]!="SUN" && $cal[$SID_CALENDAR][$j]!="NHO") $cal[$SID_CALENDAR][$j]=$AID_ABBREV[$AID_CALENDAR]; } } if($CURR_MONTH==$STARTMONTH_CALENDAR && $CURR_MONTH!=$ENDMONTH_CALENDAR) { for($j=$STARTDAY_CALENDAR;$j<($DAYS_IN_CURR_MONTH+1);$j++) { if($cal[$SID_CALENDAR][$j]!="SAT" && $cal[$SID_CALENDAR][$j]!="SUN" && $cal[$SID_CALENDAR][$j]!="NHO") $cal[$SID_CALENDAR][$j]=$AID_ABBREV[$AID_CALENDAR]; } } if($CURR_MONTH==$ENDMONTH_CALENDAR && $CURR_MONTH!=$STARTMONTH_CALENDAR) { for($j=1;$j<=$ENDDAY_CALENDAR;$j++) { if($cal[$SID_CALENDAR][$j]!="SAT" && $cal[$SID_CALENDAR][$j]!="SUN" && $cal[$SID_CALENDAR][$j]!="NHO") $cal[$SID_CALENDAR][$j]=$AID_ABBREV[$AID_CALENDAR]; } } if($CURR_MONTH==$ENDMONTH_CALENDAR && $CURR_MONTH==$STARTMONTH_CALENDAR) { for($j=$STARTDAY_CALENDAR;$j<=$ENDDAY_CALENDAR;$j++) { if($cal[$SID_CALENDAR][$j]!="SAT" && $cal[$SID_CALENDAR][$j]!="SUN" && $cal[$SID_CALENDAR][$j]!="NHO") $cal[$SID_CALENDAR][$j]=$AID_ABBREV[$AID_CALENDAR]; } } } } } } /* for ($i=1;($row = $res->fetchRow());$i++) { // Extract the information for each employee // Extracting SID $SID_CALENDAR=$row[1]; // Extracting STARTDATE $STARTDATE_CALENDAR=$row[2]; // Extracting ENDDATE $ENDDATE_CALENDAR=$row[3]; // Extracting Activity ID - AID $AID_CALENDAR=$row[4]; // Extract the DAY, Month and Year from STARTDATE //The function split returns an array of strings and the strings are separated on the basis of [/.-] list($STARTMONTH_CALENDAR, $STARTDAY_CALENDAR, $STARTYEAR_CALENDAR) = split('[/.-]', $STARTDATE_CALENDAR); echo "Month: $STARTMONTH_CALENDAR; Day: $STARTDAY_CALENDAR; Year: $STARTYEAR_CALENDAR</br>\n"; // Extract the DAY, Month and Year from ENDDATE //The function split returns an array of strings and the strings are separated on the basis of [/.-] list($ENDMONTH_CALENDAR, $ENDDAY_CALENDAR, $ENDYEAR_CALENDAR) = split('[/.-]', $ENDDATE_CALENDAR); echo "Month: $ENDMONTH_CALENDAR; Day: $ENDDAY_CALENDAR; Year: $ENDYEAR_CALENDAR</br>\n"; if($STARTYEAR_CALENDAR<$ENDYEAR_CALENDAR) $ENDMONTH_CALENDAR=$ENDMONTH_CALENDAR+12; $ACTIVITY="TEMP"; for($j=1;$j<($DAYS_IN_CURR_MONTH+1);$j++) { // Check if the CURR_MONTH is between the STARTMONTH_CALENDAR and ENDMONTH_CALENDAR if($STARTMONTH_CALENDAR!=$ENDMONTH_CALENDAR) { if($CURR_MONTH>$STARTMONTH_CALENDAR && $CURR_MONTH<$ENDMONTH_CALENDAR) { echo "PING1"; //echo "test"; //echo "</br>"; if($SEL_YEAR==$ENDYEAR_CALENDAR || $SEL_YEAR==$STARTYEAR_CALENDAR) { if($cal[$SID_CALENDAR][$j]!="SAT" && $cal[$SID_CALENDAR][$j]!="SUN" && $cal[$SID_CALENDAR][$j]!="NHO") $cal[$SID_CALENDAR][$j]=$AID_ABBREV[$AID_CALENDAR]; } } if($CURR_MONTH==$STARTMONTH_CALENDAR) { echo "PING2"; for($k=$STARTDAY_CALENDAR;$k<($DAYS_IN_CURR_MONTH+1);$k++) { if($SEL_YEAR==$ENDYEAR_CALENDAR || $SEL_YEAR==$STARTYEAR_CALENDAR) { if($cal[$SID_CALENDAR][$k]!="SAT" && $cal[$SID_CALENDAR][$k]!="SUN" && $cal[$SID_CALENDAR][$k]!="NHO" && $cal[$SID_CALENDAR][$k]!=$ACTIVITY) $cal[$SID_CALENDAR][$k]=$AID_ABBREV[$AID_CALENDAR]; } } $ACTIVITY=$AID_ABBREV[$AID_CALENDAR]; break; // Exiting from the for loop for $j } if($CURR_MONTH==$ENDMONTH_CALENDAR) { for($f=1;$f<=$ENDDAY_CALENDAR;$f++) { if($SEL_YEAR==$ENDYEAR_CALENDAR || $SEL_YEAR==$STARTYEAR_CALENDAR) { if($cal[$SID_CALENDAR][$f]!="SAT" && $cal[$SID_CALENDAR][$f]!="SUN" && $cal[$SID_CALENDAR][$f]!="NHO") $cal[$SID_CALENDAR][$f]=$AID_ABBREV[$AID_CALENDAR]; } } break; // Exiting from the for loop for $j } } if($STARTMONTH_CALENDAR==$ENDMONTH_CALENDAR) { for($k=$STARTDAY_CALENDAR;$k<=$ENDDAY_CALENDAR;$k++) { if($SEL_YEAR==$ENDYEAR_CALENDAR || $SEL_YEAR==$STARTYEAR_CALENDAR) { if($cal[$SID_CALENDAR][$k]!="SAT" && $cal[$SID_CALENDAR][$k]!="SUN" && $cal[$SID_CALENDAR][$k]!="NHO") $cal[$SID_CALENDAR][$k]=$AID_ABBREV[$AID_CALENDAR]; } } break; // Exiting from the for loop for $j } } } */ $mdb_calendar->disconnect(); /* Building the HTML Display */ echo "<table border=5 bordercolor='#6495ed' frame='box' width='100%'>"; $COLOR="#FFFFFF"; for($i=0;$i<=sizeof($empname);$i++) { echo "<tr>"; for($j=0;$j<($DAYS_IN_CURR_MONTH+1);$j++) { if($i==0) echo "<td bgcolor='$COLOR' height='10' width='500'><b>".$cal[$i][$j]."</b></td>"; else { if($cal[$i][$j]=="NHO") $COLOR="#FF8C00"; elseif($cal[$i][$j]=="SAT" ||$cal[$i][$j]=="SUN") $COLOR="#00FF00"; else $COLOR="#FFFFFF"; echo "<td bgcolor='$COLOR' width='3%'>".$cal[$i][$j]."</td>"; } } echo "</tr>"; } echo "</table>"; /*echo "<table border=1>"; echo "<tr>"; echo "<td>"."1 "."</td>"; echo "<td>". "2 " . "</td>"; echo "<td>"."3 " . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>". "SAT" . "</td>"; echo "<td>". "SUN" . "</td>"; echo "<td>". "SAT" . "</td>"; echo "</tr>"; echo "</table>";*/ ?> </body> </html>
  2. ok i added the table... but how do i get a count ??? and echo
  3. HI i am using the code here.. however how do i add a column for to log number of visitors visited that page... CREATE TABLE `visitors_table` ( `ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `visitor_ip` VARCHAR( 32 ) NULL , `visitor_browser` VARCHAR( 255 ) NULL , `visitor_hour` SMALLINT( 2 ) NOT NULL DEFAULT '00', `visitor_minute` SMALLINT( 2 ) NOT NULL DEFAULT '00', `visitor_date` TIMESTAMP( 32 ) NOT NULL DEFAULT CURRENT_TIMESTAMP , `visitor_day` SMALLINT( 2 ) NOT NULL , `visitor_month` SMALLINT( 2 ) NOT NULL , `visitor_year` SMALLINT( 4 ) NOT NULL , `visitor_refferer` VARCHAR( 255 ) NULL , `visitor_page` VARCHAR( 255 ) NULL ) TYPE = MYISAM ; <?php $hostname_visitors = "localhost"; $database_visitors = "growa"; $username_visitors = "root"; $password_visitors = "password"; $visitors = mysql_connect($hostname_visitors, $username_visitors, $password_visitors) or trigger_error(mysql_error(),E_USER_ERROR); function getBrowserType () { if (!empty($_SERVER['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; } else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; } else if (!isset($HTTP_USER_AGENT)) { $HTTP_USER_AGENT = ''; } if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[2]; $browser_agent = 'opera'; } else if (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'ie'; } else if (ereg('OmniWeb/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'omniweb'; } else if (ereg('Netscape([0-9]{1})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'netscape'; } else if (ereg('Mozilla/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'mozilla'; } else if (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'konqueror'; } else { $browser_version = 0; $browser_agent = 'other'; } return $browser_agent; } function selfURL() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; } function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); } function paginate($start,$limit,$total,$filePath,$otherPara ms) { global $lang; $allPages = ceil($total/$limit); $currentPage = floor($start/$limit) + 1; $pagination = ""; if ($allPages>10) { $maxPages = ($allPages>9) ? 9 : $allPages; if ($allPages>9) { if ($currentPage>=1&&$currentPage<=$allPages) { $pagination .= ($currentPage>4) ? " ... " : " "; $minPages = ($currentPage>4) ? $currentPage : 5; $maxPages = ($currentPage<$allPages-4) ? $currentPage : $allPages - 4; for($i=$minPages-4; $i<$maxPages+5; $i++) { $pagination .= ($i == $currentPage) ? "<a href=\"#\" class=\"current\">".$i."</a> " : "<a href=\"".$filePath."? start=".(($i-1)*$limit).$otherParams."\">".$i."</a> "; } $pagination .= ($currentPage<$allPages-4) ? " ... " : " "; } else { $pagination .= " ... "; } } } else { for($i=1; $i<$allPages+1; $i++) { $pagination .= ($i==$currentPage) ? "<a href=\"#\" class=\"current\">".$i."</a> " : "<a href=\"".$filePath."?start=".(($i-1)*$limit).$otherParams."\">".$i."</a> "; } } if ($currentPage>1) $pagination = "<a href=\"".$filePath."? start=0".$otherParams."\">FIRST</a> <a href=\"".$filePath."? start=".(($currentPage-2)*$limit).$otherParams."\"><</a> ".$pagination; if ($currentPage<$allPages) $pagination .= "<a href=\"".$filePath."? start=".($currentPage*$limit).$otherParams."\">&gt ;</a> <a href=\"".$filePath."? start=".(($allPages-1)*$limit).$otherParams."\">LAST</a>"; echo '<div class="pages">' . $pagination . '</div>'; } ?> <?php require_once('visitors_connections.php');//the file with connection code and functions //get the required data $visitor_ip = GetHostByName($_SERVER['REMOTE_ADDR']); $visitor_browser = getBrowserType(); $visitor_hour = date("h"); $visitor_minute = date("i"); $visitor_day = date("d"); $visitor_month = date("m"); $visitor_year = date("Y"); $visitor_refferer = GetHostByName($_SERVER['HTTP_REFERER']); $visitor_page = selfURL(); //write the required data to database mysql_select_db($database_visitors, $visitors); $sql = "INSERT INTO visitors_table (visitor_ip, visitor_browser, visitor_hour, visitor_minute, visitor_day, visitor_month, visitor_year, visitor_refferer, visitor_page) VALUES ('$visitor_ip', '$visitor_browser', '$visitor_hour', '$visitor_minute', '$visitor_day', '$visitor_month', '$visitor_year', '$visitor_refferer', '$visitor_page')"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);?> <?php require_once('visitors_connections.php');//the file with connection code and functions if ($_GET['start'] == "") $start = 0; else $start = $_GET['start']; $limit = 20; $additionalQuery = "SQL_CALC_FOUND_ROWS "; mysql_select_db($database_visitors, $visitors); $query_visitors = "(SELECT ".$additionalQuery." * FROM visitors_table WHERE"; if ($_POST['day']!="") { $query_visitors .= " visitor_day = '".$_POST['day']."'"; } else { $query_visitors .= " visitor_day = ".date("d").""; if ($_POST['month']!="") { $query_visitors .= " AND visitor_month = '".$_POST['month']."'"; } else { $query_visitors .= " AND visitor_month = ".date("m").""; } if ($_POST['year']!="") { $query_visitors .= " AND visitor_year = '".$_POST['year']."'"; } else { $query_visitors .= " AND visitor_year = ".date("Y").""; }} $query_visitors .= " LIMIT $start,$limit)"; $insert_visitors = mysql_query($query_visitors, $visitors) or die(mysql_error()); $row_visitors = mysql_fetch_assoc($insert_visitors); $totalRows_visitors = mysql_num_rows($insert_visitors); $nbItems = mysql_result(mysql_query("Select FOUND_ROWS() AS nbr"),0,"nbr"); if ($nbItems>($start+$limit)) $final = $start+$limit; else $final = $nbItems; echo '<link href="style.css" rel="stylesheet" type="text/css" />'; echo '<table style="width:100%; border:1px dashed #CCC" cellpadding="3"> <form id="form1" name="form1" method="post" action="display_visits.php"> <tr> <td>day <select name="day" id="day"> <option value="" selected="selected"></option> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select></td> <td>Month <select name="month" id="month"> <option value="" selected="selected"></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select></td> <td>Year <select name="year" id="year"> <option value="" selected="selected"></option> <option value="2007">2007</option> </select></td> <td><input type="submit" name="Submit" value="Submit" /></td> <td></td> </tr>'; echo '<tr> <td style="width:15%;border-bottom:1px solid #CCC">IP</td> <td style="width:15%;border-bottom:1px solid #CCC">Browser</td> <td style="width:15%;border-bottom:1px solid #CCC">Time</td> <td style="width:30%;border-bottom:1px solid #CCC">Refferer</td> <td style="width:25%;border-bottom:1px solid #CCC">Page</td> </tr>'; do { echo '<tr onmouseout="this.style.backgroundColor=\'\'" onmouseover="this.style.backgroundColor=\'#EAFFEA\ '"> <td>'.$row_visitors['visitor_ip'].'</td> <td>'.$row_visitors['visitor_browser'].'</td> <td>'.$row_visitors['visitor_hour'].':'.$row_visitors['visitor_minute'].'</td> <td>'.$row_visitors['visitor_refferer'].'</td> <td>'.$row_visitors['visitor_page'].'</td> </tr>'; } while ($row_visitors = mysql_fetch_assoc($insert_visitors)); paginate($start,$limit,$nbItems,"display_visits.ph p",""); ?>
  4. i mean how do i connect from php to flash
  5. New to php and flash.. help ples.. i need to know how to do i create a news content using php and will get contents in flash (.swf)
  6. i have a code here.. which count number of visitors .. i was wondering how to i code it so that it could track click of links from my webpage. <?php // Getting the information $ipaddress = $_SERVER['REMOTE_ADDR']; $page = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}"; $page .= iif(!empty($_SERVER['QUERY_STRING']), "?{$_SERVER['QUERY_STRING']}", ""); $referrer = $_SERVER['HTTP_REFERER']; $datetime = mktime(); $useragent = $_SERVER['HTTP_USER_AGENT']; $remotehost = @getHostByAddr($ipaddress); //create a log line $logline =$ipaddress.'|'.$referrer.$datetime.'|'.$useragent.'|'.$remotehost.'|'.$page . "/n"; //logs folder $logfile = 'logfile.php'; // Open the log file in "Append" mode if (!$handle = fopen($logfile, 'a+')) { die("Failed to open log file"); } // write logline to logfile if (fwrite($handle $logfile) === false { die ("The File Cannot Be Logged"); } fclose($handle) ?>
  7. i did on php.ini file. and it did not enter the data to my database and the script return blank when i entered any data//
  8. ok i removed the $ . when i click submit. it turn into blank page... it seems not work... please help...
  9. line 31===== $result = mysql_query($query) OR die($mysql_error());
  10. HI. i have a script below. it seems that there is some error. k anyone help me???? Fatal error: Function name must be a string in C:\wamp\www\php_project\final\member\addpage.php on line 31 <?php // If our form has NOT been submitted.... if (!isset($_POST['submitted'])) { ?> <h3>Add Your Site</h3> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <p><b>Name :</b> <input type="text" name="name" size="25" maxlength="40" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /></p> <p><b>Site URL :</b> <input type="text" name="url" size="25" maxlength="60" value="<?php if (isset($_POST['url'])) echo $_POST['url']; ?>" /></p> <p><b>Description :</b><br /> . <textarea name="description" rows="5" cols="40"><?php if(isset($_POST['description'])) echo $_POST['description']; ?></textarea></p> <p><div align="center"><input type="submit" name="submit" value="Add Site" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form> <?php } else { // If the form HAS been submitted, continue. // Connect to your database require_once('../mysql_connect.php'); if (empty($_POST['name'])) { echo '<font color="red">Please enter in a name for your site.</font><br />'; $n = FALSE; } else { $name = $_POST['name']; $query = "SELECT id, name FROM websites WHERE name = '$name'"; $result = mysql_query($query) OR die($mysql_error()); $num = mysql_num_rows($result); } if (empty($_POST['url'])) { echo '<font color="red">Please enter in a URL for your site.</font><br />'; $u = FALSE; } else { $u = mysql_real_escape_string($_POST['url']); } if (empty($_POST['description'])) { echo '<font color="red">Please enter in a description for your site.</font><br />'; $d = FALSE; } else { $d = mysql_real_escape_string($_POST['description']); } if ($n && $u && $d) { $query = "INSERT INTO websites (name, url, description, password) VALUES ('$n', '$u', '$d', SHA('$p'))"; $result = mysql_query($query) OR die(mysql_error()); if ($result) { echo '<h3>Site Added!</h3> <p>Your site has been added into your database, you may now take the code below and add it to your site so people can start voting!</p>'; } } $query = "SELECT id, name FROM websites WHERE name = '$n'"; $result = mysql_query($query) OR die(mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); } ?>
  11. this code don't seems working for me..
  12. HI.. please help me.. i am new on php... <?php session_start(); include "include/mysql_connect.php"; include "include/redirect.php"; $username = $_POST['_username']; $fullname = $_POST ['_fullname']; $email = $_POST['_emailaddress']; $password = $_POST['_password']; if (get_magic_quotes_gpc() ) { $username = stripslahes($username); $fullname = stripslahes($fullname); $email = stripslahes($email); } $error_msg=array(); if($username=="") { $error_msg[]="please enter your username"; } if ($fullname=="") { $error_msg[]="please enter your full name"; } if ($email=="") { $error_msg[]"please enter your email address"; } if ($password=="") { $error_msg[]="please enter your password"; } $query_username = "SELECT `id` FROM members WHERE `username`='$username' "; $exists = query_to_array($query_username); //print_r($exists); if ($exists != ''){ $_SESSION['err_msg'] = "Please try another username"; do_redirect('register.php'); }else{ $fullname = $_POST['_fullname']; $email = $_POST['_emailaddress']; $password = $_POST['_password']; $query_new_user = "INSERT INTO members (`username`, `password`, `email`, `fullname`) VALUES ('$username','$password','$email','$fullname')"; query($query_new_user); $profile = query_to_array("SELECT `id`, `fullname`, `email` FROM members WHERE `username`='$username'"); $_SESSION["u_id"]= $profile["id"]; $_SESSION["u_fullname"]= $profile["fullname"]; $_SESSION["u_email"]= $profile["email"]; $_SESSION["username"]= $username; do_redirect('index.php'); } ?>
  13. Hi. New here and new to php .. any one please help.. i need to know how top listing script work. and sample?/ or tutorial??? please help.. million thanks...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.