Jump to content

venom792001

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

venom792001's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the help Mchl but i just can't figure it out might be a little to advanced for my brain lol
  2. Ok here is all the code im using calendar.php <?php /* * Quick Calendar Using PHP and AJAX * Copyright (C) 2005-2007 * Version 1.1; * Last modified: 23 Jan 2007 * Author: Bernard Peh * Email: bpeh@sitecritic.net * Website://web-developer.sitecritic.net/ * File Name: quick_calendar.php * * LICENSE: * This is my contribution back to the open source community. You may modify the codes according * to your needs but please keep this section intact. * * DESCRIPTION: * Generate a simple calendar that can integrate seamlessly into any system with minimal * installation. You must be running be running PHP 4 at the minimal. * * SPECIAL THANKS TO FRIENDS FROM EVOLT.ORG * Adam Taylor, kirk837 * */ // This year $y = date('Y'); // This month $m = date('n'); // This Day $d = date('j'); $today = array('day'=>$d, 'month'=>$m, 'year'=>$y); // If user specify Day, Month and Year, reset the var if (isset($_GET['m'])) { $y = $_GET['y']; $m = $_GET['m']; } // CONFIGURE THE DB ACCESS $dbhost = ''; $dbuser = ''; $dbpass = ''; $database = ""; $dbConnect = mysql_connect($dbhost, $dbuser, $dbpass); if (!$dbConnect) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db($database, $dbConnect); if (!$db_selected) { die ('db selection error : ' . mysql_error()); } // name of table $tableName = 'calendar'; // name of css $css = 'calendar'; // Location of the calendar script file from the root $ajaxPath = './calendar.php'; // END OF CONFIGURATION. YOU CAN CHANGE THE CSS. THE OTHER CODES CAN BE KEPT AS DEFAULT IF YOU WANT. $sql = "SELECT * FROM $tableName WHERE (month='$m' AND year='$y') || (month='*' AND year='$y') || (month='$m' AND year='*') || (month='*' AND year='*')"; $rs = mysql_query($sql); $links = array(); while ($rw = mysql_fetch_assoc($rs)) { extract($rw); $links[] = array('day'=>$day, 'month'=>$month, 'year'=>$year, 'link'=>$link, 'desc'=>$desc); } ?> <?php // if called via ajax, dont display style sheet and javascript again if (!isset($_GET['ran'])) { ?> <style type="text/css"> .calendar { /** configure the width **/ width:218px; background-color: #EEEEEE; border: 1px solid #000000; font-family: Arial, Helvetica, sans-serif; font-size: 12px; margin:0px; padding:0px; text-align:center; } .calendar th { background:url('images/header2.jpg'); font-weight: bold; height: 20px; color: #ffffff; } .calendar .header { background:url('images/header.jpg'); font-weight: bold; height: 24px; color: #FFFFFF; } .calendar .footer { background:url('images/header2.jpg'); font-weight: bold; font-size:0.8em; color: #FFFFFF; width:100%; } .calendar td { width: 22px; height: 20px; text-align: center; font-size:0.9em; padding: 2px; } .calendar .today { width: 18px; height: 16px; background-color: #36393D; padding: 2px; border: 1px solid #000000; font-weight: bold; color: #ffffff; } .calendar .home { width: 18px; height: 16px; background-color: #B71313; padding: 2px; border: 1px solid #000000; font-weight: bold; color: #ffffff; } .calendar .away { width: 18px; height: 16px; background-color: #000000; padding: 2px; border: 1px solid #EEEEEE; font-weight: bold; color: #ffffff; } .calendar .link { width: 18px; height: 16px; color: #ffffff; font-weight:bold; background-color: #B71313; padding: 2px; border: 1px solid #000000; } .calendar a, .calendar a:link, .calendar a:hover { font-weight: bold; text-decoration: underline; color: #ffffff; } .calendar a.headerNav, .calendar a:link.headerNav, .calendar a:hover.headerNav { color: #ffffff; } .calendar a.footerNav, .calendar a:link.footerNav, .calendar a:hover.footerNav { width: 100%; color: #ffffff; } </style> <script language="javascript"> function createQCObject() { var req; if(window.XMLHttpRequest){ // Firefox, Safari, Opera... req = new XMLHttpRequest(); } else if(window.ActiveXObject) { // Internet Explorer 5+ req = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert('Problem creating the XMLHttpRequest object'); } return req; } // Make the XMLHttpRequest object var http = createQCObject(); function displayQCalendar(m,y) { var ran_no=(Math.round((Math.random()*9999))); http.open('get', '<?= $ajaxPath; ?>?m='+m+'&y='+y+'&ran='+ran_no); http.onreadystatechange = function() { if(http.readyState == 4 && http.status == 200) { var response = http.responseText; if(response) { document.getElementById("quickCalender").innerHTML = http.responseText; } } } http.send(null); } </script> <?php } ?> <?php class CreateQCalendarArray { var $daysInMonth; var $weeksInMonth; var $firstDay; var $week; var $month; var $year; function CreateQCalendarArray($month, $year) { $this->month = $month; $this->year = $year; $this->week = array(); $this->daysInMonth = date("t",mktime(0,0,0,$month,1,$year)); // get first day of the month $this->firstDay = date("w", mktime(0,0,0,$month,1,$year)); $tempDays = $this->firstDay + $this->daysInMonth; $this->weeksInMonth = ceil($tempDays/7); $this->fillArray(); } function fillArray() { // create a 2-d array for($j=0;$j<$this->weeksInMonth;$j++) { for($i=0;$i<7;$i++) { $counter++; $this->week[$j][$i] = $counter; // offset the days $this->week[$j][$i] -= $this->firstDay; if (($this->week[$j][$i] < 1) || ($this->week[$j][$i] > $this->daysInMonth)) { $this->week[$j][$i] = ""; } } } } } class QCalendar { var $html; var $weeksInMonth; var $week; var $month; var $year; var $today; var $links; var $css; function QCalendar($cArray, $today, &$links, $css='') { $this->month = $cArray->month; $this->year = $cArray->year; $this->weeksInMonth = $cArray->weeksInMonth; $this->week = $cArray->week; $this->today = $today; $this->links = $links; $this->css = $css; $this->createHeader(); $this->createBody(); $this->createFooter(); } function createHeader() { $header = date('M', mktime(0,0,0,$this->month,1,$this->year)).' '.$this->year; $nextMonth = $this->month+1; $prevMonth = $this->month-1; switch($this->month) { case 1: $lYear = $this->year; $pYear = $this->year-1; $nextMonth=2; $prevMonth=12; break; case 12: $lYear = $this->year+1; $pYear = $this->year; $nextMonth=1; $prevMonth=11; break; default: $lYear = $this->year; $pYear = $this->year; break; } // -- $this->html = "<table cellspacing='0' cellpadding='0' class='$this->css'> <tr> <th class='header'> <a href=\"javascript:;\" onclick=\"displayQCalendar('$this->month','".($this->year-1)."')\" class='headerNav' title='Prev Year'><<</a></th> <th class='header'> <a href=\"javascript:;\" onclick=\"displayQCalendar('$prevMonth','$pYear')\" class='headerNav' title='Prev Month'><</a></th> <th colspan='3' class='header'>$header</th> <th class='header'><a href=\"javascript:;\" onclick=\"displayQCalendar('$nextMonth','$lYear')\" class='headerNav' title='Next Month'>></a> </th> <th class='header'> <a href=\"javascript:;\" onclick=\"displayQCalendar('$this->month','".($this->year+1)."')\" class='headerNav' title='Next Year'>>></a></th> </tr>"; } function createBody(){ // start rendering table $this->html.= "<tr><th>S</th><th>M</th><th>T</th><th>W</th><th>Th</th><th>F</th><th>S</th></tr>"; for($j=0;$j<$this->weeksInMonth;$j++) { $this->html.= "<tr>"; for ($i=0;$i<7;$i++) { $cellValue = $this->week[$j][$i]; // if today if (($this->today['day'] == $cellValue) && ($this->today['month'] == $this->month) && ($this->today['year'] == $this->year)) { $cell = "<div class='today'>$cellValue</div>"; } // else normal day else { $cell = "$cellValue"; } // if days with link foreach ($this->links as $val) { if (($val['day'] == $cellValue) && (($val['month'] == $this->month) || ($val['month'] == '*')) && (($val['year'] == $this->year) || ($val['year'] == '*'))) { $cell = "<div class='link'><a rel=\"facebox\" href=\"cal_games.php\" title='{$val['desc']}'>$cellValue</a></div>"; break; } } $this->html.= "<td>$cell</td>"; } $this->html.= "</tr>"; } } function createFooter() { $this->html .= "<tr><td colspan='7' class='footer'><span class='home'> </span> Game Nights</td></tr></table>"; } function render() { echo $this->html; } } ?> <?php // render calendar now $cArray = &new CreateQCalendarArray($m, $y); $cal = &new QCalendar($cArray, $today, $links, $css); if (!isset($_GET['ran'])) { echo "<div id='quickCalender'>"; } $cal->render(); if (!isset($_GET['ran'])) { echo "</div>"; } ?> and the code im using to call the info from the db via a modal box <?php // CONFIGURE THE DB ACCESS $dbhost = ''; $dbuser = ''; $dbpass = ''; $database = ""; $dbConnect = mysql_connect($dbhost, $dbuser, $dbpass); if (!$dbConnect) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db($database, $dbConnect); if (!$db_selected) { die ('db selection error : ' . mysql_error()); } // name of table $tableName = 'calendar'; $date=date("F j, Y"); $day = // selected day $month = // selectod month $year = // selected year $sql = "SELECT * FROM $tableName WHERE `day` = $day AND `month` = $month AND `month` = $month"; $query = mysql_query($sql); while ($row = mysql_fetch_assoc($query)){ echo " <table border='0' cellpadding='12' cellspacing='4' width='95%'> <tbody> <tr> <th align='center'>Home</th> <th align='center'>Away</th> </tr> <tr> <td align='center'>$row[home_team]</th> <td align='center'>$row[away_team]</th> </tr> <tr> <td align='center'>0</th> <td align='center'>0</th> </tr> <tr> <td align='center' colspan='2'> </td> </tr> <tr> <td align='center' colspan='2'> </td> </tr> <tr> <td align='center' colspan='2'>$date, $row[time]</td> </tr> <tr> <td align='center' colspan='2'> </td> </tr> <tr> <tr> <td align='center' colspan='2'>$row[location]</td> </tr> </table> </div>"; } ?> If you now of a better way to store the date for this i would love your input if it makes it easier i appreciate all your input and patience!!
  3. Thanks for the reply, for some reason because the code for the calendar uses the mysql_fetch_array on the index page, that now any code i have elsewhere that uses mysql_fetch_assoc will shoot off an error Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /
  4. here is the structure TABLE calendar ( id INT NOT NULL AUTO_INCREMENT , day VARCHAR( 2 ) NOT NULL , month VARCHAR( 2 ) NOT NULL , year VARCHAR( 4 ) NOT NULL , link VARCHAR( 255 ) NOT NULL , desc TEXT NOT NULL , PRIMARY KEY ( id ) );
  5. thats a good idea, any idea how i would compare the date to the info in the db im really new to php/mysql Thanks!
  6. I'm using a php/mysql calendar from http://evolt.org/quick_calendar_using_ajax...nts_per_page=50 ive got it on my site and i have info in the database and have it showing when you click on the date on the calendar the problem i am having is having it only show the info for that specific date clicked, right now its showing all info from the database obviously i am doing the query wrong just not sure what.... This is the code im using to show the info from the db on selected day <?php // CONFIGURE THE DB ACCESS $dbhost = 'xxxxx'; $dbuser = 'xxxxxx'; $dbpass = 'xxxxx'; $database = "xxxxx"; $dbConnect = mysql_connect($dbhost, $dbuser, $dbpass); if (!$dbConnect) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db($database, $dbConnect); if (!$db_selected) { die ('db selection error : ' . mysql_error()); } // name of table $tableName = 'calendar'; $date=date("F j, Y"); $sql = "SELECT * FROM $tableName"; $query = mysql_query($sql); while ($row = mysql_fetch_assoc($query)){ echo " <table border='0' cellpadding='12' cellspacing='4' width='95%'> <tbody> <tr> <th align='center'>Home</th> <th align='center'>Away</th> </tr> <tr> <td align='center'>$row[home_team]</th> <td align='center'>$row[away_team]</th> </tr> <tr> <td align='center'>0</th> <td align='center'>0</th> </tr> <tr> <td align='center' colspan='2'> </td> </tr> <tr> <td align='center' colspan='2'> </td> </tr> <tr> <td align='center' colspan='2'>$date, $row[time]</td> </tr> <tr> <td align='center' colspan='2'> </td> </tr> <tr> <tr> <td align='center' colspan='2'>$row[location]</td> </tr> </table> </div>"; } ?> Any help is greatly appreciated
  7. Yeah thats the first thing i checked and its in the tsl_sites table, i know it works in mysql 4 because i installed mysql 4 on my localhost and it works fine I made sure the column "id" was in the table before posting so i wouldnt look like an idiot lol this is the query CREATE TABLE `tsl_sites` ( `id` mediumint( unsigned NOT NULL auto_increment, `user` mediumint( unsigned NOT NULL default '0', `email` mediumint( unsigned NOT NULL default '0', `guest_email` tinyint(1) NOT NULL default '1', `show_email` tinyint(1) NOT NULL default '0', `name` varchar(255) NOT NULL default '', `url` varchar(255) NOT NULL default '', `description` varchar(255) NOT NULL default '', `category` smallint(5) unsigned NOT NULL default '0', `category_validated` tinyint(1) NOT NULL default '1', `last_category` smallint(5) unsigned NOT NULL default '0', `webring` tinyint(1) NOT NULL default '0', `banner` varchar(255) default NULL, `banner_size` varchar(10) NOT NULL default '', `in_count` mediumint( unsigned NOT NULL default '0', `out_count` mediumint( unsigned NOT NULL default '0', `out_total` mediumint( unsigned NOT NULL default '0', `hit_count` mediumint( unsigned NOT NULL default '0', `archive_in` mediumint( unsigned NOT NULL default '0', `archive_out` mediumint( unsigned NOT NULL default '0', `archive_hits` mediumint( unsigned NOT NULL default '0', `vote_count` mediumint( unsigned NOT NULL default '0', `archive_votes` mediumint(9) NOT NULL default '0', `admin_validate` tinyint(1) NOT NULL default '0', `active` tinyint(1) NOT NULL default '0', `last_position` mediumint( unsigned NOT NULL default '0', PRIMARY KEY (`id`), KEY `category` (`category`), KEY `user` (`user`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; and it was successfull and id was there not sure what the correct mysql 5 query would be Thanks for replying!
  8. Im having trouble getting this query to execute im using mysql 5 and this code was created 3 years ago. $this->count_sites = $this->base->db->fetch_id('SELECT COUNT(s.id) FROM @sites AS s, @users as u, @emails as e WHERE s.user = u.id && s.email = e.id && u.blocked = 0 && s.active = 1 && s.admin_validate = 1 && e.validated = 1'.$where); // If this query were a person it would be Rik Waller $this->db_resource = $this->base->db->query(' SELECT s.*,COUNT(DISTINCT c.id) as comment_count, AVG(v.value) as rating,COUNT(DISTINCT v.id) as num_votes'.$additional_select.' FROM @sites AS s, @users AS u, @emails AS e '.$votes_join.' LEFT JOIN @comments AS c ON c.site = s.id && c.admin_validate = 1 LEFT JOIN @votes AS v ON v.active = 1 && v.site = s.id WHERE s.user = u.id && s.email = e.id && u.blocked = 0 && s.active = 1 && s.admin_validate = 1 && e.validated = 1'.$where.' GROUP BY s.id ORDER BY '.$order_by_parameter.' LIMIT ' . $this->offset . ',' . $this->search_limit ); } and it gives me this error. Unknown column 's.id' in 'on clause' Query Executed: SELECT s.*,COUNT(DISTINCT c.id) as comment_count, AVG(v.value) as rating,COUNT(DISTINCT v.id) as num_votes, 0 as already_voted FROM tsl_sites AS s, tsl_users AS u, tsl_emails AS e INNER JOIN tsl_comments AS c ON c.site = s.id && c.admin_validate = 1 INNER JOIN tsl_votes AS v ON v.active = 1 && v.site = s.id WHERE s.user = u.id && s.email = e.id && u.blocked = 0 && s.active = 1 && s.admin_validate = 1 && e.validated = 1 GROUP BY s.id ORDER BY in_count DESC, rating DESC, out_count DESC, hit_count DESC, name DESC LIMIT 0,20 Any idea on what i need to fix in the query im assuming its not valid for mysql 5 and im pretty new to php/mysql and learning more each day but im stumped. Thanks to anyone who can help.
  9. Ok im new to php and mysql been reading a little bit at a time as i go and i need a little help Im sorry if this is a huge request but if someone could help or point me in the direction of some tuts regarding what im trying to do that be great also. Ok here we go its for a local minor hockey league, Im creating a script in php/mysql where i can input a players name, number, team, goals, assists, penalty minutes, suspensions, and games played i have all that working fine and for the form i use a radio selection for the teams and then manually input a players info works perfect, what i need to do is i want to then be able to use a dropdown list which would be generated from the database of all the teams curently only 6 and then once selected it gives me the list of players either in radio format or dropdown and once i click on a player it brings up a form of that player with his current stats for me to edit. Also i cant seem to figure out how to not allow duplicate names be submitted right now i can submit as many players with the same name as possible. If anyone can help me out here it be greatly appreciated or point me towards some reading/tuts that be great also, i can post the code im currently using if anyone needs it. Kind Regards
×
×
  • 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.