Jump to content

spacepoet

Members
  • Posts

    320
  • Joined

  • Last visited

Everything posted by spacepoet

  1. Hello: I am making a dynamic food menu system for a project so a client can manage his food and drink menus. I gave him the ability to add, edit, and delete menus. However, for the "Delete Menu" option, I would like to first check and see if a Category (menuCatID) or a Menu Item (menuItemID) is associated to the Main Menu (menuID) and - if so - to *NOT* allow that Menu to be deleted. I would like to send them back to the a_Menus.php page and display a message like "You must delete all Categories and Menu Items associated with this Menu before the Menu can be deleted." This is the code: a_Menus.php <a href="a_MenusDelete.php?menuID=".$menuData['menuID'].">Delete Menu</a> a_MenusDelete.php <?php include('../include/myConn.php'); include('../include/myCodeLib.php'); include('include/myCheckLogin.php'); $menuID = $_REQUEST['menuID']; mysql_query("DELETE FROM theMenus WHERE menuID = $menuID"); header("Location: a_Menus.php"); ?> <html> <head> <title></title> </head> <body> </body> </html> How would I be able to accomplish this? Thanks.
  2. Hi. Thanks for the tip. I found that online so just going with what was in the tutorial. Is there a more "robust" example you can point me to? I want to keep it as simple as possible but want to make it solid as well. New to me so not always sure what to look for ...
  3. Hi: How do I set a password-protected page to time out after 20 minutes or so? I thought it was doing it on the below page, but it is not working. A tutorial I found online. Login.php <form name="form1" method="post" action="myLogin.php"> <input name="myUserName" type="text" size="40" id="myUserName"> <br /><br /> <input name="myPassword" type="password" size="40" id="myPassword"> </div> <input type="submit" name="Submit" value="Login"> </form> myLogin.php <?php ob_start(); // Connect to server and select database. //mysql_connect("$host", "$username", "$password")or die("cannot connect"); //mysql_select_db("$db_name")or die("cannot select DB"); // Define $myUserName and $myPassword $myUserName=$_POST['myUserName']; $myPassword=$_POST['myPassword']; // To protect MySQL injection (more detail about MySQL injection) $myUserName = stripslashes($myUserName); $myPassword = stripslashes($myPassword); $myUserName = mysql_real_escape_string($myUserName); $myPassword = mysql_real_escape_string($myPassword); $sql="SELECT * FROM myAdmins WHERE myUserName='$myUserName' and myPassword='$myPassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myUserName and $myPassword, table row must be 1 row if($count==1){ // Register $myUserName, $myPassword and redirect to file "a_Home.php" session_register("myUserName"); session_register("myPassword"); header("location:a_Home.php"); } else { echo " <html> ... </html> "; } ob_end_flush(); ?> myCheckLogin.php (added to each page to see if the person logged-in via Login.php): <? session_start(); if(!session_is_registered(myUserName)){ header("location:Login.php"); } ?> Any help would be great. Thanks.
  4. Hi: Thanks very much! This worked perfectly! Looks and works just fine now. Your help is appreciated!
  5. Howdy: Thanks - tried it - but it's still the same, poor result. Any other ideas? How about scaling it as well? Any ideas on that?
  6. Hello: I have a photo uploader in my admin area. First time I tried this so it's new to me. The upload form sends it to the page below, and does the resizing and saving. It seems to automatically resize the photos to make thumbnails, which is really nice. However, I am trying to do 2 things and can't figure it out. 1 - I would like to resize the main photo and not the thumbnail (or just use the thumbnail as the main photo, whichever seems easier). I would like it to be 690px wide but let it scale in proportion to what the height should be (not set a height as I think that's what it is doing now). This is the area where it gets resized: { $thumbnail_width = 690; $thumbnail_height = (int)(100 * $size[1] / $size[0]); } else { $thumbnail_width = (int)(690 * $size[0] / $size[1]); $thumbnail_height = 100; } Also, the thumbnails are coming out very dark and de-colored. How can I set it so it retains all the color and clarity, but just resizes them? Point I'm trying to do is just resize upon upload, as most of my clients do not and will not resize photos before uploading them, and that means each photo from a digital camera will be about 1.3 MBs, which starts to make a photo gallery page very heavy and clunky. This is the full code, if it will help: <?php // initialization $result_final = ""; $counter = 0; // List of our known photo types $known_photo_types = array( 'image/pjpeg' => 'jpg', 'image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/bmp' => 'bmp', 'image/x-png' => 'png' ); // GD Function List $gd_function_suffix = array( 'image/pjpeg' => 'JPEG', 'image/jpeg' => 'JPEG', 'image/gif' => 'GIF', 'image/bmp' => 'WBMP', 'image/x-png' => 'PNG' ); // Fetch the photo array sent by preupload.php $photos_uploaded = $_FILES['photo_filename']; // Fetch the photo caption array $photo_caption = $_POST['photo_caption']; while( $counter <= count($photos_uploaded) ) { if($photos_uploaded['size'][$counter] > 0) { if(!array_key_exists($photos_uploaded['type'][$counter], $known_photo_types)) { $result_final .= "File ".($counter+1)." is not a photo<br />"; } else { mysql_query( "INSERT INTO gallery_photos(`photo_filename`, `photo_caption`, `photo_category`) VALUES('0', '".addslashes($photo_caption[$counter])."', '".addslashes($_POST['category'])."')" ); $new_id = mysql_insert_id(); $filetype = $photos_uploaded['type'][$counter]; $extention = $known_photo_types[$filetype]; $filename = $new_id.".".$extention; mysql_query( "UPDATE gallery_photos SET photo_filename='".addslashes($filename)."' WHERE photo_id='".addslashes($new_id)."'" ); // Store the orignal file copy($photos_uploaded['tmp_name'][$counter], $images_dir."/".$filename); // Let's get the Thumbnail size $size = GetImageSize( $images_dir."/".$filename ); if($size[0] > $size[1]) //{ //$thumbnail_width = 100; //$thumbnail_height = (int)(100 * $size[1] / $size[0]); //} //else //{ //$thumbnail_width = (int)(100 * $size[0] / $size[1]); //$thumbnail_height = 100; //} { $thumbnail_width = 690; $thumbnail_height = (int)(500 * $size[1] / $size[0]); } else { $thumbnail_width = (int)(690 * $size[0] / $size[1]); $thumbnail_height = 500; } // Build Thumbnail with GD 1.x.x, you can use the other described methods too $function_suffix = $gd_function_suffix[$filetype]; $function_to_read = "ImageCreateFrom".$function_suffix; $function_to_write = "Image".$function_suffix; // Read the source file $source_handle = $function_to_read ( $images_dir."/".$filename ); if($source_handle) { // Let's create an blank image for the thumbnail $destination_handle = ImageCreate ( $thumbnail_width, $thumbnail_height ); // Now we resize it ImageCopyResized( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1] ); } // Let's save the thumbnail $function_to_write( $destination_handle, $images_dir."/tb_".$filename ); ImageDestroy($destination_handle ); // $result_final .= "<img src='".$images_dir. "/tb_".$filename."' style='margin-right: 20px;' />"; } } $counter++; } // Print Result echo <<<__HTML_END $result_final __HTML_END; ?> Anyone know how to fix this? Thanks.
  7. Hi: How do I transfer an ID to a 3rd page. Meaning: Events.php ... <a href="eventDetails.php?calID=<?=$row['calID'];?>"><?=$row['calName'];?></a> ... Goes to eventDetails.php, and transfer/displays the calID properly: <?php include('include/myConn.php'); include('include/myNav.php'); $calID = $_REQUEST['calID']; $query=mysql_query("select * from calTbl where calID = $calID") or die("Could not get data from db: ".mysql_error()); while($result=mysql_fetch_array($query)) { $calName=$result['calName']; $calDesc=$result['calDesc']; $calDate=$result['calDate']; $calID=$result['calID']; } ?> ... <a href="?calID=<?php echo $calID; ?>" onclick="openSesame();" class="myBold">Print</a> ... However, when I click the "Print" link (I see it is properly writing the calID on the link - like eventDetailsPrint.php?calID=7. The "eventDetailsPrint.php" is written from a JavaScript file as a new window function), it is coming up blank. <?php include('include/myConn.php'); //$calID = $_REQUEST['calID']; //$calID = $_SERVER['calID']; //$calID = echo $_GET['calID']; echo $_POST["calID"]; $query=mysql_query("select * from calTbl where calID = calID") or die("Could not get data from db: ".mysql_error()); while($result=mysql_fetch_array($query)) { $calName=$result['calName']; $calDesc=$result['calDesc']; $calDate=$result['calDate']; $calID=$result['calID']; } ?> ... <?php echo $calID; ?> ... What is the trick to pass an ID from page to page to page? Thanks.
  8. Got it! Entertainment.php?month=".date('n')."&year=".date('Y')."\" Thanks for the pointers - helped me to work through it.
  9. Hi: What I need to have happen is when the link is clicked: Entertainment.php It goes to that page with the final URL looking like: Entertainment.php?month=4&year=2011 Where the URL will always write the current month and year. Does this make sense? Thanks!
  10. Hi: How can I build a querystring (or whatever I need to do to solve my issue) to pull in the month and year? Meaning: I have this link: Entertainment.php which goes to a dynamic calendar, which works fine except it does not show the events because I think it replies on getting the current month and year. When I click on a "Next Month" and the click back to the current month, the URL is: Entertainment.php?month=4&year=2011 and the events then display properly in the calendar. How do I properly build a URL for this? The calendar code looks like this: <?php ob_start(); $today = date("M Y"); ?> ... <head> <script> function show_evt(m,y,day){ location.href = "<?=$_SERVER['PHP_SELF'];?>?month=" + m + "&year=" + y + "&day=" + day; } function goLastMonth(month, year) { if(month == 1) { --year; month = 13; } document.location.href = '<?=basename($_SERVER['PHP_SELF']);?>?month='+(month-1)+'&year='+year; } function goNextMonth(month, year) { if(month == 12) { ++year; month = 0; } document.location.href = '<?=basename($_SERVER['PHP_SELF']);?>?month='+(month+1)+'&year='+year; } </script> </head> ... <p> <?php $date =time (); $day = (isset($_GET['day'])) ? $_GET['day'] : date('d', $date); $month = (isset($_GET['month'])) ? $_GET['month'] : date('m', $date); $year = (isset($_GET['year'])) ? $_GET['year'] : date('Y', $date); $first_day = mktime(0,0,0,$month, 1, $year); $title = date('F', $first_day); $day_of_week = date('D', $first_day); switch($day_of_week){ case "Sun": $blank = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; } $days_in_month = cal_days_in_month(0, $month, $year); ?> <table class="tableClass"> <tr class="field-bg-color"> <th class="eventLeftArrow"><a href="javascript: void(0);" onClick="goLastMonth(<?php echo $month . ", " . $year; ?>)"><<<</a></th> <th colspan="5" class="eventHeader"><?=$title. " " . $year;?></th> <th class="eventRightArrow"><a href="javascript: void(0);" onClick="goNextMonth(<?php echo $month . ", " . $year; ?>)">>>></a></th> </tr> <tr class="calDates"> <td>S</td> <td>M</td> <td>T</td> <td>W</td> <td>T</td> <td>F</td> <td class="lastOne">S</td> </tr> <?php $day_count = 1; ?> <tr> <?php while ( $blank > 0 ) { ?> <td> </td> <?php $blank = $blank-1; $day_count++; } $day_num = 1; while ( $day_num <= $days_in_month ) { $sql = "select count(calName) as evt_count from calTbl where calDate ='" . $month . '/' . $day_num . '/' . $year . "'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ if($row['evt_count'] >= 1){ ?> <td align="center" style="cursor:hand;cursor:pointer;background-color:#FF6A6A;text-align:center;" onclick="show_evt('<?=$month;?>','<?=$year;?>','<?=$day_num;?>');"> <div class="brown-bg-color cal-head-text white-text bold-text"><?=$day_num;?></div> <?php $sql = "select * from calTbl where calDate ='" . $month . '/' . $day_num . '/' . $year . "'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ ?> <a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$month;?>&year=<?=$year;?>&day=<?=$day_num;?>"><?=$row['calName'];?></a></br> <? } }else{ ?> <td> <div class="brown-bg-color cal-head-text"><?=$day_num;?></div> <?php } } ?> </td> <?php $day_num++; $day_count++; if ($day_count > 7){ ?> </tr><tr> <?php $day_count = 1; } } while ( $day_count >1 && $day_count <=7 ) { ?> <td> </td> <?php $day_count++; } ?> </tr></table> <?php if(isset($_GET['day'])){ $sql = "select * from calTbl where calDate ='" . $month . '/' . $_GET['day'] . '/' . $year . "'"; $result = mysql_query($sql); echo '<table class="data-table-class">'; echo '<th>Event Name</th><th>Event Desc</th>'; while($row = mysql_fetch_array($result)){ echo '<tr><td>'. $row['calName'] . '</td><td>' . $row['calDesc'] . '</td></tr>'; } echo '</table>'; } ?> <div class="myClear"></div> <?php ob_flush(); ?> </p> Can anyone help me out? This is the last part and I am good to go! Thanks!
  11. Hi: Yes, I know there are other scripts, but the ones I have been finding have too much "stuff" - I liked this one because it was (at least I thought until this point ..lol..) simple .. I will have to look at the code along with your points. This is where I'm stuck with it; haven't tried to do anything like this before. Thanks for the time.
  12. calStamp is "stamping" the time the entry is made into the database, which is why I can't use it for what I need. I added calDate as a timedate field in the DB, but it's getting inserted as "00-00-00 0000" ... I am gathering that this wasn't set-up properly to do what I need it to do. Maybe I need to look for another calendar ... I just want a simple "wall" calendar to add events in the admin, and display them on the front end...
  13. Hi: Yes, agreeded - date and time should be a timedate (like the calStamp field is) So ... should I just change that in the database and it will work?? As far as where the current date is coming from, I amnot certain. This is the full code I am using: <p> <div id="legend"> Today is: <? $today = date("F j, Y, g:i a"); echo " $today " ?> </div> <?php //$todaysDate = date("n/j/Y"); //echo $todaysDate; // Get values from query string $day = (isset($_GET["day"])) ? $_GET['day'] : ""; $month = (isset($_GET["month"])) ? $_GET['month'] : ""; $year = (isset($_GET["year"])) ? $_GET['year'] : ""; //comparaters for today's date //$todaysDate = date("n/j/Y"); //$sel = (isset($_GET["sel"])) ? $_GET['sel'] : ""; //$what = (isset($_GET["what"])) ? $_GET['what'] : ""; //$day = (!isset($day)) ? $day = date("j") : $day = ""; //comparaters for today's date //$todaysDate = date("n/j/Y"); //$sel = (isset($_GET["sel"])) ? $_GET['sel'] : ""; //$what = (isset($_GET["what"])) ? $_GET['what'] : ""; //$day = (!isset($day)) ? $day = date("j") : $day = ""; if(empty($day)){ $day = date("j"); } if(empty($month)){ $month = date("n"); } if(empty($year)){ $year = date("Y"); } //set up vars for calendar etc $currentTimeStamp = strtotime("$year-$month-$day"); $monthName = date("F", $currentTimeStamp); $numDays = date("t", $currentTimeStamp); $counter = 0; //$numEventsThisMonth = 0; //$hasEvent = false; //$todaysEvents = ""; //run a selec statement to hi-light the days function hiLightEvt($eMonth,$eDay,$eYear){ //$tDayName = date("l"); $todaysDate = date("n/j/Y"); $dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; if($todaysDate == $dateToCompare){ //$aClass = '<span>' . $tDayName . '</span>'; $aClass='class="today"'; }else{ //$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; //echo $todaysDate; //return; $sql="select count(calDate) as eCount from calTbl where calDate = '" . $eMonth . '/' . $eDay . '/' . $eYear . "'"; //echo $sql; //return; $result = mysql_query($sql); while($row= mysql_fetch_array($result)){ if($row['eCount'] >=1){ $aClass = 'class="event"'; }elseif($row['eCount'] ==0){ $aClass ='class="normal"'; } } } return $aClass; } ?> <table width="900" cellpadding="0" cellspacing="0"> <tr> <td width="50" colspan="1"> <input type="button" value=" < " onClick="goLastMonth(<?php echo $month . ", " . $year; ?>);"> </td> <td width="250" colspan="5"> <span class="eventHeader"><?php echo $monthName . " " . $year; ?></span><br> </td> <td width="50" colspan="1" align="right"> <input type="button" value=" > " onClick="goNextMonth(<?php echo $month . ", " . $year; ?>);"> </td> </tr> <tr> <th>S</th> <th>M</th> <th>T</th> <th>W</th> <th>T</th> <th>F</th> <th class="lastOne">S</th> </tr> <tr> <?php for($i = 1; $i < $numDays+1; $i++, $counter++){ $dateToCompare = $month . '/' . $i . '/' . $year; $timeStamp = strtotime("$year-$month-$i"); //echo $timeStamp . '<br/>'; if($i == 1){ // Workout when the first day of the month is $firstDay = date("w", $timeStamp); for($j = 0; $j < $firstDay; $j++, $counter++){ echo "<td> </td>"; } } if($counter % 7 == 0){ ?> </tr><tr> <?php } ?> <td width="50" <?=hiLightEvt($month,$i,$year);?>> <?php if(isset($_GET['full'])){ $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo $row['calName']; }else{ $sql="select calID, calDate, calName, calDesc from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ echo $row['calName']; ?> <a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$row['calDate'];?></a> <?php } } ?> </td> <?php } ?> </table> <?php if(isset($_GET['v'])){ $sql="select calID, calDate, calName, calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'"; $result = mysql_query($sql); $numRows = mysql_num_rows($result); ?> <?php if($numRows == 0 ){ echo '<h3>No Events</h3>'; }else{ while($row = mysql_fetch_array($result)){ ?> <div class="output"> <?=$row['calDate'];?> <h5><?=$row['calName'];?></h5> <?=$row['calDesc'];?> </div> <?php } } } ?> </p> Sorry about all these posts - I found this online and it works great, excecpt the original version doesn't display the events in the calendar. You have to click the date, and events for that date display under that calendar, which seems kinda of odd. The point of a calendar is to display the events in the calendar so people see them right when they hit that page. Thanks for taking the time to help me.
  14. OK, this is my DB: -- -- Table structure for table `calTbl` -- CREATE TABLE `calTbl` ( `calID` int(11) NOT NULL auto_increment, `calName` varchar(65) NOT NULL, `calDesc` varchar(255) NOT NULL, `calDate` varchar(11) NOT NULL, `calStamp` datetime NOT NULL, PRIMARY KEY (`calID`) ) ENGINE=MyISAM AUTO_INCREMENT=90 DEFAULT CHARSET=latin1 AUTO_INCREMENT=90 ; -- -- Dumping data for table `calTbl` -- INSERT INTO `calTbl` VALUES (88, 'Open Mic', '<p>Come out and Jam with us!</p>', '4/22/2011', '2011-04-18 13:59:44'); The calDate would display as: 4/20/2011 (I am not using the calStamp field) So, what am I missing?
  15. Well ... I did all of this, but still no errors or data .. puzzled .. <td width="50" <?=hiLightEvt($month,$i,$year);?>> <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); if(isset($_GET['full'])){ $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo $row['calName']; }else{ //$sql="select calID, calDate, calName, calDesc from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'"; $sql="select calID, calDate, calName, calDesc from calTbl where calDate = '" . $month . "/" . $day . "/" . $year . "'"; //$result = mysql_query($sql); $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['calName']; ?> <a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$row['calDate'];?></a> <?php } } ?> <? $today = date("F j, Y, g:i a"); echo " $today " ?> </td> It does write the date into every field using the <? $today = date("F j, Y, g:i a"); echo " $today " ?> code .. but doesn't fix my issue ... Can this be re-written so an event date is assigned properly to the date on the calendar? That's all I want to do. This was easy in ASP, but PHP has me stumped ...
  16. Hi: I tried your code as well, but I'm not getting any errors .. That's why I confused ..
  17. Hi: I had that in there: ini_set ("display_errors", "1"); error_reporting(E_ALL); but it didn't do anything ... so I removed it ... The VIEW SOURCE is just showing empty TD cells, so that is why I am stumped .. .. ??
  18. Hi: Thanks for the tips but they are no working .. it's still just a blank calendar .. This is the full code: <p> <div id="legend"> Today is: <? $today = date("F j, Y, g:i a"); echo " $today " ?> </div> <?php //$todaysDate = date("n/j/Y"); //echo $todaysDate; // Get values from query string $day = (isset($_GET["day"])) ? $_GET['day'] : ""; $month = (isset($_GET["month"])) ? $_GET['month'] : ""; $year = (isset($_GET["year"])) ? $_GET['year'] : ""; //comparaters for today's date //$todaysDate = date("n/j/Y"); //$sel = (isset($_GET["sel"])) ? $_GET['sel'] : ""; //$what = (isset($_GET["what"])) ? $_GET['what'] : ""; //$day = (!isset($day)) ? $day = date("j") : $day = ""; //comparaters for today's date //$todaysDate = date("n/j/Y"); //$sel = (isset($_GET["sel"])) ? $_GET['sel'] : ""; //$what = (isset($_GET["what"])) ? $_GET['what'] : ""; //$day = (!isset($day)) ? $day = date("j") : $day = ""; if(empty($day)){ $day = date("j"); } if(empty($month)){ $month = date("n"); } if(empty($year)){ $year = date("Y"); } //set up vars for calendar etc $currentTimeStamp = strtotime("$year-$month-$day"); $monthName = date("F", $currentTimeStamp); $numDays = date("t", $currentTimeStamp); $counter = 0; //$numEventsThisMonth = 0; //$hasEvent = false; //$todaysEvents = ""; //run a selec statement to hi-light the days function hiLightEvt($eMonth,$eDay,$eYear){ //$tDayName = date("l"); $todaysDate = date("n/j/Y"); $dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; if($todaysDate == $dateToCompare){ //$aClass = '<span>' . $tDayName . '</span>'; $aClass='class="today"'; }else{ //$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; //echo $todaysDate; //return; $sql="select count(calDate) as eCount from calTbl where calDate = '" . $eMonth . '/' . $eDay . '/' . $eYear . "'"; //echo $sql; //return; $result = mysql_query($sql); while($row= mysql_fetch_array($result)){ if($row['eCount'] >=1){ $aClass = 'class="event"'; }elseif($row['eCount'] ==0){ $aClass ='class="normal"'; } } } return $aClass; } ?> <table width="900" cellpadding="0" cellspacing="0"> <tr> <td width="50" colspan="1"> <input type="button" value=" < " onClick="goLastMonth(<?php echo $month . ", " . $year; ?>);"> </td> <td width="250" colspan="5"> <span class="eventHeader"><?php echo $monthName . " " . $year; ?></span><br> </td> <td width="50" colspan="1" align="right"> <input type="button" value=" > " onClick="goNextMonth(<?php echo $month . ", " . $year; ?>);"> </td> </tr> <tr> <th>S</th> <th>M</th> <th>T</th> <th>W</th> <th>T</th> <th>F</th> <th class="lastOne">S</th> </tr> <tr> <?php for($i = 1; $i < $numDays+1; $i++, $counter++){ $dateToCompare = $month . '/' . $i . '/' . $year; $timeStamp = strtotime("$year-$month-$i"); //echo $timeStamp . '<br/>'; if($i == 1){ // Workout when the first day of the month is $firstDay = date("w", $timeStamp); for($j = 0; $j < $firstDay; $j++, $counter++){ echo "<td> </td>"; } } if($counter % 7 == 0){ ?> </tr><tr> <?php } ?> <td width="50" <?=hiLightEvt($month,$i,$year);?>> <?php if(isset($_GET['full'])){ $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo $row['calName']; }else{ $sql="select calID, calDate, calName, calDesc from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ echo $row['calName']; ?> <a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$row['calDate'];?></a> <?php } } ?> </td> <?php } ?> </table> <?php if(isset($_GET['v'])){ $sql="select calID, calDate, calName, calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'"; $result = mysql_query($sql); $numRows = mysql_num_rows($result); ?> <?php if($numRows == 0 ){ echo '<h3>No Events</h3>'; }else{ while($row = mysql_fetch_array($result)){ ?> <div class="output"> <?=$row['calDate'];?> <h5><?=$row['calName'];?></h5> <?=$row['calDesc'];?> </div> <?php } } } ?> </p> Do you see a way to revise this?? I am REALLY stumped on this one ...
  19. Hi: Can someone tell me why the code below is not displaying any data. It's suppose to write the calendar dates and event info, but nothing is showing up. No errors, either .. ?? <td width="50" <?=hiLightEvt($month,$i,$year);?>> <?php if(isset($_GET['full'])){ $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo $row['calName']; }else{ $sql="select calID, calDate, calName, calDesc from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ echo $row['calName']; ?> <a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$row['calDate'];?></a> <?php } } ?> </td> Help, please ....
  20. Hi: I think I am close to getting the data to display as I would like it, but I'm a bit stuck and don't know where to go with it. Perhaps someone here can help me out. This is the chuck of code that will display the date (and where I want to display the data assigned to that date): <td width="50" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$i;?></a> <?php if(isset($_GET['v'])){ $sql="select calDate, calName,calDesc from calTbl where calDate = \"'month=' $month '&day=' $i '&year=' $year\"; $result = mysql_query($sql); $numRows = mysql_num_rows($result); ?> <?php if($numRows == 0 ){ echo '<h3>No Events</h3>'; }else{ while($row = $_GET($result)){ ?> <div class="output"> <h5><?=$row['calName'];?></h5> <?=$row['calDesc'];?> </div> </td> The "<?=$i;?>" in the first line writes the date (1, 2, 3, etc.) into the correct area of the calendar. Seeing that that works fine, I am trying to figure out how to display the "calName" and "calDesc" to the proper date assigned to them in the admin area (this is assigned by "calDate"). Anyone know how to do this? Thanks.
  21. Hi: I am working with a PHP Event Calendar. I am having trouble displaying the data the way I want to. If a person clicks on a number/date in the calendar (17, for example) the data will display fine below the calendar.\ However, I want to display only the Event Title ("calName") in the date box as a link, and allow the user to click the title to go to a new page to see the full Event info. I can not get any of the data to display and hope someone can tell me what I'm doing wrong. This is the code: <script> function goLastMonth(month, year){ // If the month is January, decrement the year if(month == 1){ --year; month = 13; } document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month-1)+'&year='+year; } //next function function goNextMonth(month, year){ // If the month is December, increment the year if(month == 12){ ++year; month = 0; } document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month+1)+'&year='+year; } function remChars(txtControl, txtCount, intMaxLength) { if(txtControl.value.length > intMaxLength) txtControl.value = txtControl.value.substring(0, (intMaxLength-1)); else txtCount.value = intMaxLength - txtControl.value.length; } function checkFilled() { var filled = 0 var x = document.form1.calName.value; //x = x.replace(/^\s+/,""); // strip leading spaces if (x.length > 0) {filled ++} var y = document.form1.calDesc.value; //y = y.replace(/^s+/,""); // strip leading spaces if (y.length > 0) {filled ++} if (filled == 2) { document.getElementById("Submit").disabled = false; } else {document.getElementById("Submit").disabled = true} // in case a field is filled then erased } </script> ............... <p> <div id="legend"> <img src="images/Cal-Icon.jpg" style="padding: 0 15px 15px 0;" /> Today is: <? $today = date("F j, Y, g:i a"); echo " $today " ?> </div> <?php //$todaysDate = date("n/j/Y"); //echo $todaysDate; // Get values from query string $day = (isset($_GET["day"])) ? $_GET['day'] : ""; $month = (isset($_GET["month"])) ? $_GET['month'] : ""; $year = (isset($_GET["year"])) ? $_GET['year'] : ""; //comparaters for today's date //$todaysDate = date("n/j/Y"); //$sel = (isset($_GET["sel"])) ? $_GET['sel'] : ""; //$what = (isset($_GET["what"])) ? $_GET['what'] : ""; //$day = (!isset($day)) ? $day = date("j") : $day = ""; //comparaters for today's date //$todaysDate = date("n/j/Y"); //$sel = (isset($_GET["sel"])) ? $_GET['sel'] : ""; //$what = (isset($_GET["what"])) ? $_GET['what'] : ""; //$day = (!isset($day)) ? $day = date("j") : $day = ""; if(empty($day)){ $day = date("j"); } if(empty($month)){ $month = date("n"); } if(empty($year)){ $year = date("Y"); } //set up vars for calendar etc $currentTimeStamp = strtotime("$year-$month-$day"); $monthName = date("F", $currentTimeStamp); $numDays = date("t", $currentTimeStamp); $counter = 0; //$numEventsThisMonth = 0; //$hasEvent = false; //$todaysEvents = ""; //run a selec statement to hi-light the days function hiLightEvt($eMonth,$eDay,$eYear){ //$tDayName = date("l"); $todaysDate = date("n/j/Y"); $dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; if($todaysDate == $dateToCompare){ //$aClass = '<span>' . $tDayName . '</span>'; $aClass='class="today"'; }else{ //$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; //echo $todaysDate; //return; $sql="select count(calDate) as eCount from calTbl where calDate = '" . $eMonth . '/' . $eDay . '/' . $eYear . "'"; //echo $sql; //return; $result = mysql_query($sql); while($row= mysql_fetch_array($result)){ if($row['eCount'] >=1){ $aClass = 'class="event"'; }elseif($row['eCount'] ==0){ $aClass ='class="normal"'; } } } return $aClass; } ?> <table width="900" cellpadding="0" cellspacing="0"> <tr> <td width="50" colspan="1"> <input type="button" value=" < " onClick="goLastMonth(<?php echo $month . ", " . $year; ?>);"> </td> <td width="250" colspan="5"> <span class="title"><?php echo $monthName . " " . $year; ?></span><br> </td> <td width="50" colspan="1" align="right"> <input type="button" value=" > " onClick="goNextMonth(<?php echo $month . ", " . $year; ?>);"> </td> </tr> <tr> <th>S</th> <th>M</th> <th>T</th> <th>W</th> <th>T</th> <th>F</th> <th class="lastOne">S</th> </tr> <tr> <?php for($i = 1; $i < $numDays+1; $i++, $counter++){ $dateToCompare = $month . '/' . $i . '/' . $year; $timeStamp = strtotime("$year-$month-$i"); //echo $timeStamp . '<br/>'; if($i == 1){ // Workout when the first day of the month is $firstDay = date("w", $timeStamp); for($j = 0; $j < $firstDay; $j++, $counter++){ echo "<td> </td>"; } } if($counter % 7 == 0){ ?> </tr><tr> <?php } ?> <!--right here--><td width="128" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$i;?></a> // TRYING TO DISPLAY CALENDAR EVENTS HERE <?php $sql="select calName,calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'"; //echo $sql; //return; $result = mysql_query($sql); $numRows = mysql_num_rows($result); ?> <? while($row = mysql_fetch_array($result)){ ?> <div class="output"> <h5><?=$row['calName'];?></h5> <?=$row['calDesc'];?><br/> Listed On: <?=$row['calStamp'];?> </div> </td> </table> // END OF TRYING TO DISPLAY CALENDAR EVENTS HERE <?php } } ?> </p> Can anyone tell me what is wrong? Thanks!
  22. Well, I got the code from a tutorial ... There is an option to revise the code and upload multiple photos, so I assume that's why it's an array ..
  23. Hi there: No, I am only trying to check if the file field is empty (for submitting a photo to the photo gallery). If it is empty, then the JS Alert should activate, which it now does. Thanks.
  24. I do know the other site has a QueryString, so maybe that's why it worked? <?php $photo_id = $_REQUEST['photo_id']; mysql_query("DELETE FROM gallery_photos WHERE photo_id = $photo_id"); header("Location: a_Page.php?myID=1"); ?> So, it will not work the way I have it? Thanks for the help.
  25. Hi, I tried it like this: <p> <?php if ($_SERVER['HTTP_REFERER'] == 'a_Photo_Delete.php') { echo "<span class=\"textError\">Photo successfully deleted!</span>"; } ?> </p> but it still doesn't work. I'm stumped because I took the code from another site, and it works fine on that one. Odd .. any other ideas? 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.