PHP - Php Calendar Is Working Now, But Will Not Do Previous/next Month Correctly
In a previous posting I was having a problem with a calendar filling in with events. That is now working. However, I cannot get the Previous/Next month selections to work correctly. Here is the coding for that portion of the calendar:
Code: [Select] /* date settings */ $month = (int) ($_POST['month'] ? $_POST['month'] : ($_GET['month'] ? $_GET['month'] : date('m'))); $year= (int) ($_POST['year'] ? $_POST['year'] : ($_GET['year'] ? $_GET['year'] : date('Y'))); /* "previous month" control */ $previous_month_link = '<a href="?month='.($month != 1 ? $month - 1 : 12).'&year='.($month != 1 ? $year : $year - 1).'" class="control"><< Previous Month</a>'; /* select month control */ $select_month_control = '<select name="month" id="month">'; for($x = 1; $x <= 12; $x++) { $select_month_control.= '<option value="'.$x.'"'.($x != $month ? '' : ' selected="selected"').'>'.date('F',mktime(0,0,0,$x,1,$year)).'</option>'; } $select_month_control.= '</select>'."\n"; /* select year control */ $year_range = 4; $select_year_control = '<select name="year" id="year">'; for($x = ($year-floor($year_range/2)); $x <= ($year+floor($year_range/2)); $x++) { $select_year_control.= '<option value="'.$x.'"'.($x != $year ? '' : ' selected="selected"').'>'.$x.'</option>'; } $select_year_control.= '</select>'."\n"; /* "next month" control */ $next_month_link = '<a href="?month='.($month != 12 ? $month + 1 : 1).'&year='.($month != 12 ? $year : $year + 1).'" class="control">Next Month >></a>'; /* bringing the controls together */ $controls = '<form method="get">'.$previous_month_link.' '.$select_month_control.$select_year_control.' <input type="submit" name="submit" value="Go" /> '.$next_month_link.' </form>'; //CODING REMOVED echo draw_calendar($month,$year,$events); Here is the SQL query if that helps: Code: [Select] SELECT Events.EventTitle, DATE_FORMAT(Performance.startDateTime, '%Y-%m-%e') AS event_date, DATE_FORMAT(Performance.startDateTime, '%h:%i %p') AS start_time, Events.EventID, Events.ShoWareEventLink, Events.group_id, Performance.category_id FROM Events LEFT JOIN Performance ON Events.EventID = Performance.EventID WHERE Events.group_id=1 AND Performance.category_id!=5 AND Performance.category_id!=7 AND Performance.category_id!=8 AND DATE_FORMAT(Performance.startDateTime,'%Y')=$year AND DATE_FORMAT(Performance.startDateTime,'%m')=$month What currently happens with my calendar is that it will list events for THIS month and the next three months. After that it hits next year (January 2012) and the calendar goes blank. It will also go blank if you choose Previous month (even though there are events that happened in September 2011 and before. You can see this if you go to http://www.myalaskacenter.com/calendars/calendarSample3.php. Does anyone know what should be done to the code to fix this? Similar Tutorialsmy problem is if my local date is february 1 or march 30... if i press previous month i cant see the month of february, but if i press the change the local date to february 2 or march 29 i can see the month of february in my event calendar... what should i do to see the month of february even i set the local date in february 1 or march 30.... heres the code Code: [Select] if (isset($_GET['day'])){ $day = $_GET['day']; } else { $day = date("j"); } if(isset($_GET['month'])){ $month = $_GET['month']; } else { $month = date("n"); } if(isset($_GET['year'])){ $year = $_GET['year']; }else{ $year = date("Y"); } $currentTimeStamp = strtotime( "$day-$month-$year"); $monthName = date("F", $currentTimeStamp); $numDays = date("t", $currentTimeStamp); Hi, this one has me stumped! For some reason February refuses to show up in my calender, that is, month 2 reads as march as well as month 3 (being correct). Here is my code which is fine except for this silly bug: $month = $_GET['month'] ; $year = $_GET['year'] ; if(!$month) $month = date('n') ; if(!$year) $year = date('Y') ; $days = cal_days_in_month(CAL_GREGORIAN, $month, $year) ; echo "<div style='width:100%;text-align:center;font-size:1.3em;font-weight:bold;'>" ; if($month == 1) echo "<a href=\"?month=12&year=" . ($year-1) ; else echo " <a href=\"?month=" . ($month-1) . "&year=" . $year ; echo "\"><img style='border:none;' width='16' src='prev-month.png' /></a>" ; echo " Classes for " . date("F, Y", strtotime("$year-$month")) . "\n" ; if($month == 12) echo "<a href=\"?month=1&year=" . ($year+1) ; else echo " <a href=\"?month=" . ($month+1) . "&year=" . $year ; echo "\"><img style='border:none;' width='16' src='next-month.png' /></a>\n" ; echo "</div>\n" ; for($i=1;$i < 8;$i++) { // Create day headers... echo "<div style='float:left;width:110px;margin:20px 5px 0px 5px;text-align:center;background:#1552ff;color:white;border:1px solid #155BFF;'>" . date("l", strtotime("$year-$month-$i")) . "</div>\n" ; } for($i=1; $i < $days+1;$i++) { // Create days... $result = mysql_query("SELECT * FROM classes WHERE DAY(classDate) = '$i' AND MONTH(classDate) = '$month' AND YEAR(classDate) = '$year'")or die(mysql_error()) ; $classCount = mysql_num_rows($result) ; while($row = mysql_fetch_assoc($result)) { $classes .= $row['title'] . "<br />" ; } echo "<div style='float:left;width:104px;height:104px;margin:0px 5px 0px 5px; border:1px solid #155BFF;border-top:none;cursor:pointer;padding:3px;' onmouseover=\"this.style.background='#ffbdec';\" onmouseout=\"this.style.background='none';\" title=\"" . str_replace('<br />', "\n\n", $classes) . "\" alt=\"" . str_replace('<br />', "\n\n", $classes) . "\">\n" ; echo "<div style='float:left;height:84px;width:104px;'>\n" ; echo "<span style='font-weight:bold;'>$i</span><br />\n" ; echo "<span style='font-size:0.7em;'>" ; echo $classes ; echo "</span></div>\n" ; echo "<div style='float:left;height:20px;width:104px;text-align:center;'>\n" ; echo "<a href='#' style='font-size:0.7em;'>click to book a class</a>\n" ; echo "</div>\n" ; echo "</div>\n" ; $classes = '' ; } working example he www.caketopper.co.uk/2011/class-schedule.php delete Hi, As the title says, I'm trying to get the last working day of the month (by this I mean excluding Saturday and Sunday). My thinking was that I basically need to this: If (day = Sat) { -1 day } elseif (day = Sun) { -2 days } else { keep it as it is } So far, all I have is the below to echo out the day of date("t/m/y"), however, all I'm getting is Thursday, whereas the last day of March is a Saturday Code: [Select] <?php $lastdateofthemonth = date("t/m/y"); $lastworkingday = date('l', strtotime($lastdateofthemonth)); echo $lastworkingday; ?> Can anyone help, or point me in the way of where this may have been answered in the past? I've searched all over Google but can't find what I'm looking for. Thanks I have to make a calendar which can go back & forth between years and months. when you click on the month it is supposed to show the calendar of that month and the year you clicked. you can view the site where i can put the php. http://helios.ite.gmu.edu/~easad/lab7.php Thanks a bunch! Code: [Select] if ($_GET["year"]=="") { $year=date("Y"); $previousYear = $year-1; $nextYear = $year+1; } else { $year=$_GET["year"]; $previousYear = $year-1; $nextYear = $year+1; } if ($_GET["month"]=="") { $month=date("n"); } else { $month=$_GET["month"]; } Hello everyone, hopeing this is the correct place to place this, if not I apologize. I dont have a script, but here is what I hope to accomplish. There are 4 crew working, each works two days, then two nights then gets 4 off. Ex.. A platoon works 17th day, 18th day 19th night, 20th night then gets 4 off B platoon works 19th day, 20th day, 21st night, 22nd nght then gets 4 off C platoon works 21st day, 22nd day, 23rd night, 24th night then gets 4 off D platoon works 23rd day, 24th day, 25th night, 26th night then gets 4 off A platoon works 25th day, 26th day...... This schedule revolves like that for the entire year. (if A is working days, then D is working nights etc) I wanted to know if anyone could help me create a script that displays which crew is currently working, a script example that knows it is the 23rd and outputs "D platoon is on Duty" If anyone understands this and can help, please let me know. Thanks Trying to get the below to generate the month in word form from a numeric entry in a database. Code: [Select] elseif($_GET['rma']=="calander"){ $sql101010="SELECT DISTINCT rma_year_issued FROM $tbl_name4 ORDER BY rma_year_issued"; $result101010=mysql_query($sql101010); while($row101010=mysql_fetch_array($result101010)){ extract($row101010); $content.='<a href="./acp_admincp.php?rma=calander&year='.$rma_year_issued.'">'.$rma_year_issued.'</a> <br />'; } if(isset($_GET['year'])){ $logout.=' | <a href="./acp_admincp.php?rma=calander">Back to RMA Calander</a>'; $rma_year_issued=$_GET['year']; $sql111010="SELECT DISTINCT rma_month_issued FROM $tbl_name4 WHERE rma_year_issued='$rma_year_issued' ORDER BY rma_month_issued"; $result111010=mysql_query($sql111010); while($row111010=mysql_fetch_array($result111010)){ extract($row111010); $months = array('Janurary', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); for($i=0; $i <=11; $i++){ if($rma_month_issued=$i){ $rma_month_issued2=$months[$i]; } } $content=""; $content.='<a href="./acp_admincp.php?rma=calander&year='.$rma_year_issued.'&month='.$rma_month_issued.'">'.$rma_month_issued2.'</a> <br />'; } } } Basically in the data base I may have 2,5,7 under the year 2011. I want to get the numeric months into words for use in the text of the link. The above is returning December even though the entry in the database is 5. Hi.. I need help in getting the 3 Months Name from my table field FromMonth and ToMonth. Here is the scenario. First, I select FromMonth and ToMonth. Ex. FromMonth = 5 ToMonth = 7 So it means FromMonth is May ToMonth is July. Now I save the MonthNumber to my database: table- so_month FromMonth = 5 ToMonth = 7 Now I need to get the between Months Name from FromMonth to ToMonth which are (May, June, July). How does it possible? Thank you so much. So I am creating a list of events. There will be a drop down menu to change between months. I only want the months to be listed if an event during that month exists. So if I have events listed for September and November, list only September and November, skipping October. Any idea on how to approach this or if there are any functions for such a thing? Hello, I am pasting code below that isn't working corrrectly. One problem is the pagination. When I get more than 10 records, it will show the next 10 link but when I click on it, it just takes me back to an empty page with NO results. How do I fix this? Also where do I insert the block of code for a table to structure my results. As of now, the returned results are all over the page! Thanks! This is the code: Code: [Select] <?php // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set echo "Results"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["1st_field"]; echo "$count.) $title" ; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> MOD EDIT: [code] . . . [/code] BBCode tags added. Hello PHP Wizards, i wonder if anyone can help, Ive got an associative array set up with a bunch of items, the idea is to compare the array items with items from a form using $_POST. So far ive got the items displaying from the form as follows Code: [Select] <?php while ($client_prices = each($_POST)) { /* sets the name of the array to $client_prices for easy identification */ echo $client_prices['key']; /* Displays the keys withing the $client_prices array */ echo ' - '; echo $client_prices['value']; /* Displays the values within the $client_prices array */ echo '<br />'; } ?> and for the sake of it ill display the array ive set up on the server side using similar code : Code: [Select] <?php while ($server_prices = each($coffee_prices)) { /* sets the name of the array to $server_prices for easy identification */ echo $server_prices['key']; /* Displays the keys withing the $server_prices array */ echo ' - '; echo $server_prices['value']; /* Displays the values within the $server_prices array */ echo '<br />'; } ?> now, what i want to do is make sure that the keys (name of items) and the values (cost of items) from the client side are the same as the keys and values ive set on the server. so i created an if statement : Code: [Select] <?php if( $client_prices['key'] === $server_prices['key'] && $client_prices['value'] === $server_prices['value'] ) echo 'Prices Match'; else echo '<h2>Oops! Somthing Has Gone, Please Call Us To Place Your Order</h2>'; ?> so i thought i had it all working when as it came back with 'prices match', i thought all is good. however when i purposely change the value of one of the items in my server side array so it will be different from the incoming client value, it still says 'prices match' when they clearly don;t? Anyone help would be appreciated p.s. im fairly new to php, and this is for my learning, not a real client. Hi, i am trying to add a very simple shopping cart script to my site, and the session is simply used to keep the contents of the shopping cart, yet its not working properly! Ok ignoring the layout issues with the cart here is the issues. Only two links to the same script First one is a link to the shopping cart with an action to add the item ID to it. http://www.heliuk.co.uk/index.php?n=pages/shop-cart-action&id=1&action=add This works, it adds the item to the session "cart", if that's successful it then shows the cart from the session. But if i just go to the shopping cart with no actions (so just to view it) it shows no items http://heliuk.co.uk/index.php?n=pages/shop-cart-action And what this is doing is checking it the cart is empty, if not show the cart, if it is then show nothing, which is what happening. But if you go back to the first link and add the item again, it is adding it on to the cart so the session is there and working? I don't understand what's happening! Here the shopping cart page. Code: [Select] <?php error_reporting(E_ALL ^ E_NOTICE); $product_id = $_GET["id"]; //the product id from the URL $action = $_GET["action"]; //the action from the URL //if there is an product_id and that product_id doesn't exist display an error message if($product_id && !productExists($product_id)) { die("Error. Product Doesn't Exist"); } switch($action) { //decide what to do case "add": $_SESSION['cart'][$product_id]++; //add one to the quantity of the product with id $product_id break; case "remove": $_SESSION['cart'][$product_id]--; //remove one from the quantity of the product with id $product_id if($_SESSION['cart'][$product_id] == 0) unset($_SESSION['cart'][$product_id]); //if the quantity is zero, remove it completely (using the 'unset' function) - otherwise is will show zero, then -1, -2 etc when the user keeps removing items. break; case "empty": unset($_SESSION['cart']); //unset the whole cart, i.e. empty the cart. break; } ?> <table class='main' cellspacing='1' cellpadding='4'> <tr class='head'> <td class='head' colspan='2'>HeliUK Shop - Your Shopping Cart</td> </tr> <tr> <td style='Text-align:left;' class='con1' colspan='2'> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <?php error_reporting(E_ALL ^ E_NOTICE); if($_SESSION['cart']) { //if the cart isn't empty //show the cart echo "<table border=\"1\" padding=\"0\" width=\"100%\">"; //format the cart using a HTML table //iterate through the cart, the $product_id is the key and $quantity is the value foreach($_SESSION['cart'] as $product_id => $quantity) { //get the name, description and price from the database - this will depend on your database implementation. //use sprintf to make sure that $product_id is inserted into the query as a number - to prevent SQL injection $sql = sprintf("SELECT title, description, price FROM items WHERE id = %d;", $product_id); $result = mysql_query($sql); //Only display the row if there is a product (though there should always be as we have already checked) if(mysql_num_rows($result) > 0) { list($name, $description, $price) = mysql_fetch_row($result); $line_cost = $price * $quantity; //work out the line cost $total = $total + $line_cost; //add to the total cost echo "<tr>"; echo "<td style=\"border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px\" width=\"145\">"; echo "<font face=\"Tahoma\" size=\"2\">$quantity</font></td>" ; echo "<td style=\"border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px\" width=\"693\">"; echo "<font face=\"Tahoma\" size=\"2\">$name</font></td>" ; echo "<td style=\"border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px\" width=\"162\">"; echo "<font face=\"Tahoma\" size=\"2\">$line_cost</font></td>" ; echo "<td style=\"border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px\">"; echo "<p align=\"center\"><a href=\"$_SERVER[PHP_SELF]?action=remove&id=$product_id\">" ; echo "<img border=\"0\" src=\"empty-cart.jpg\" width=\"24\" height=\"24\"></a></td>" ; echo "</tr>"; } } //show the total echo "<tr>"; echo "<td colspan=\"0\" align=\"right\">Total</td>"; echo "<td align=\"right\">$total</td>"; echo "</tr>"; //show the empty cart link - which links to this page, but with an action of empty. A simple bit of javascript in the onlick event of the link asks the user for confirmation echo "<tr>"; echo "<td colspan=\"0\" align=\"right\"><a href=\"$_SERVER[PHP_SELF]?action=empty\" onclick=\"return confirm('Are you sure?');\">Empty Cart</a></td>"; echo "</tr>"; echo "</table>"; }else{ //otherwise tell the user they have no items in their cart echo "You have no items in your shopping cart."; } ?> </table> </td> </tr> </table> <? //function to check if a product exists function productExists($product_id) { //use sprintf to make sure that $product_id is inserted into the query as a number - to prevent SQL injection $sql = sprintf("SELECT * FROM items WHERE id = %d;", $product_id); return mysql_num_rows(mysql_query($sql)) > 0; } ?> I want to make it so that whoever is sending the fame (sender) doesn't send it to themselves (receiver). However, I can't get it to block that. Everything else works, so something must be up with that specific requirement. Any help would be appreciated! Thanks! <?php //error_reporting(E_ALL); //ini_set('display_errors', 1); include("fightfunc.php"); include("lib.php"); define("PAGENAME", "GFame"); $player = check_user($secret_key, $db); $x = $player->username; if($_SESSION['234asdfas']){$y = $_SESSION['234asdfas'];}else{echo 'Error: You do not have a session variable set'; exit;} $command = 1; if (isset($_POST["sendfame"])) { $maxgfame = $player->gfame; include("tmpconfig.php"); $checkquery = mysql_query("SELECT * FROM `users` WHERE `username`='".ucwords(strtolower($_POST['receiver']))."'"); extract($_POST); if($sender == "") { echo "You must put a sender's name in the text box.";//The amount would create a negative balance - implement error condition } elseif ($gfamesent == 0) { echo "Enter an amount greater than 0."; } elseif ($gfamesent < 0) { echo "Enter an amount greater than 0."; } elseif (!is_numeric($gfamesent)) { echo "Enter a numerical amount!"; } elseif ($gfamesent == "") { echo "Enter a numerical amount!"; } elseif ($receiver == "") { echo "You must put a name in the Receiver field."; } elseif ($gfamesent > $maxgfame) { echo "You don't have that much gfame to give."; } elseif ($receiver == $sender) { echo "You can't give gfame to yourself."; } elseif (mysql_num_rows($checkquery) == 0) { echo "That player does not exist."; } else { $query = $db->execute("UPDATE `users` SET `gfame`=? WHERE `id`=?", array($player->gfame - 1, $player->id)) or die("querya failed: ". mysql_error()); if($query) $qry = $db->execute("select * from `users` where `username`=?", array(ucwords(strtolower($_POST['reciever'])))) or die("qry failed: ".mysql_error()); $rw = $qry->fetchrow(); if($qry){ $query2 = $db->execute("UPDATE `users` SET `fame`=? WHERE `username`=?", array($rw['fame'] + 1, $rw['username'])) or die("query2 failed: ". mysql_error()); if($query2){ echo("<br><br>You have successfully transfered your gfame over.<br>"); } } }} $player = check_user($secret_key, $db); ?> <br /><br /><blockquote><center>GFame is fame you can award 1 other person for what you feel is "noteworthiness". In otherwords, if you feel someone is doing a superb job of role-playing their character, you can "reward" them for their actions. You may send 1 gfame point per day. And no, you cannot send it to yourself.</center></blockquote><br /><br /> <table width="100%"> <tr> <td colspan="2"><fieldset> <legend>Transfer GFame:</legend> You have <b><?=$player->gfame?></b> GFame to give.<br /> <form method="post" action="gfame.php"> <input name="sender" type="hidden" value="$player->id" id="sender" /> <input type="submit" value="Transfer" name="sendfame"> <input type="text" value="1" name="gfamesent"> to <input name="receiver" type="text" id="receiver"> </form> </fieldset></td> </tr> </table> if ($content['size'] == "sizel") {$content['size'] = "Large";} echo "{$content['size']}"; This doesn't work and just echo's "sizel". Why? I am using the following request on my site (index.php) Code: [Select] $compass = $_REQUEST['compass']; I wanted to use an if statement to echo an error message if $compass was anything other than north,east,south or west. However the code im using is constantly displaying the error message even when /index.php?compass=north etc. Can anyone see what I have done wrong? Code: [Select] if (($compass != "north") || ($compass != "east") || ($compass != "south") || ($compass != "west")) { echo '<strong>Stop cheating!</strong>'; } Hey guys, I don't know why but the following script is not working for me. Its a simple login script which check the validity of username and password and based on the uses header function to redirect the user. Please have a look at the script Code: [Select] <?php include('dbinfo.inc'); if(empty($_POST['username']) || empty($_POST['pword'])) { header('Location: http://localhost/vits/index.php?login=error'); } else { $username = $_POST['username']; $pword = $_POST['pword']; $actype = $_POST['actype']; $connect = mysql_connect($host,$dbuser,$password) or die("Cannot connect to DB"); mysql_select_db($dbname,$connect); $sql = "select * from memberinfo where username='$username'"; $result = mysql_query($sql,$connect); $row = mysql_fetch_assoc($result); } if($row['username'] == $username && $row['pword'] == $pword && $row['actype'] == $actype) { session_start(); $_SESSION['username'] = $_POST['username']; $_SESSION['loggedin'] = TRUE; $_SESSION['actype'] = $_POST['actype']; header('Location: http://localhost/vits/index.php?login=correct'); } else { header('Location: http://localhost/vits/index.php?login=incorrect'); } ?> Now the problem is it never succeeds i.e. it never goes into the if block where the checking is being done for username and password and of course actype. No matter what I enter in login information it always throws me to this http://localhost/vits/index.php?login=incorrect' Please help as am not able to sort out this problem Ok, I have most of my CMS done. I have the data being displayed from the database. I also have the code working to create new pages and menu items. However, I am faced with two issues. 1. The menu will not display horizontally. This is not a major issue but would be good for people who use my script to be given that option if they want to modify the template. 2. Each page has an ID that is created in the database. The script creates a new page and tells the database to define a new ID for each page. For example page.php?id=2 This works fine. But, if I go to say page.php?id=2 and then click on the Home button to go back to the index, the home button also inherits the same URL as the page with the ID. I also noticed that any link on the page with the id= defined, also inherits that URL. I am unable to figure it out and was hoping someone here could help. Here is the page.php code: Code: [Select] <?php /***************************** * * Name: osPHPSite * Version: 0.0.1 * Developer: Dan O'Riordan * Email: dan@vichost.com * Copyright (c) 2010 VicHost * Date: September 2010 * Website: www.osphpsite.com * Licence: GNU/GPL v3 * ******************************/ include "language/english/english.php"; include "includes/settings.php"; include "includes/version.php"; include "includes/config.php"; include "templates/default/header.tpl"; include "nav.php"; ?> <div class="art-content-layout"> <div class="art-content-layout-row"> <div class="art-layout-cell art-content"> <div class="art-post"> <div class="art-post-body"> <div class="art-post-inner art-article"> <?php //if no id defined then load the home page. if(isset($_GET['id'])){ $id = $_GET['id']; if(!is_numeric($id)){ include "includes/404.php"; exit; } database_connect(); $query = "SELECT * from content where id = $id;"; $echo = mysql_error(); $result = mysql_query($query); $num_rows = mysql_num_rows($result); if ($num_rows == 0) { include "includes/404.php";; exit; } while ($row = mysql_fetch_assoc($result)) { $title = $row['title']; $text = $row['text']; $description = $row['description']; $keywords = $row['keywords']; } } include("includes/body.php"); ?> </div> </div> </div> </div> </div> </div> <?php include "templates/default/footer.tpl"; ?> This creates the pages defined in the database and also tells nav.php to create a new menu item. And here is the nav.php Code: [Select] <?php database_connect(); $query = "SELECT * from content WHERE status = 1 ORDER by position;"; $error = mysql_error(); if (!$result = mysql_query($query)) { print "$error"; exit; } $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $id = $row['id']; $menutitle = $row['menutitle']; //if no menu title entered, then use the title. if ($menutitle == ""){ $menutitle = $row['title']; } $startpage = $row['startpage']; $href = "page.php?id=$id"; if ($startpage == 1) { $href = ""; } ?> <ul class="art-vmenu"> <li> <a href="<?php echo $href; ?>"><span class="l"></span><span class="r"></span><span class="t"><?php echo $menutitle; ?></span></a> </li> </ul> <?php } ?>The HTML part of this relies on CSS for the layout. At the moment I have the menu displayed virtically, until I can figure out the horizontal bit body.php: Code: [Select] <?php database_connect(); $navquery = "SELECT * from content WHERE status = 1 ORDER by position;"; $navresult = mysql_query($navquery); while ($row = mysql_fetch_assoc($navresult)) { $navid = $row['id']; $menutitle = $row['menutitle']; $startpage = $row['startpage']; //if no menu title entered, then use the title. if ($menutitle == ""){ $menutitle = $row['title']; } if ($startpage == 1) { $href = "/"; }else{ $href = "page.php?id=$navid"; } $startpage = NULL; } echo $text; ?> Can anyone see where I am going wrong? Any help would be appreciated. I'm getting the following error with the code below: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\wamp\www\flow\fpdf\rev.php on line 47 Can I get another set of eyes to look at it & see what I'm missing? Code: [Select] <html <head> <?php require('connection.php'); if (isset($_GET['op']) && $_GET['op'] == "d") if($_GET['op'] == "d" && !empty($_GET['id']) ) { { $result = mysql_query($query) or die(mysql_error()); } $query="SELECT fid, pacts, fname, lname, employee, dock, due_owner, due_attny, due_suspo, due_clerk, interv_date, due_rev, assgn_date, sent_date FROM psrinfo"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array( $result )) { ?> <?php } require('connection.php'); if (isset($_GET['op']) && $_GET['op'] == "d") if($_GET['op'] == "d" && !empty($_GET['id']) ) { $result = mysql_query($query) or die(mysql_error()); } $query="SELECT fid, pacts, fname, lname, employee, dock, due_owner, due_attny, due_suspo, due_clerk, interv_date, due_rev, assgn_date, sent_date FROM psrinfo WHERE employee = 'employee1' "; $result = mysql_query($query) or die(mysql_error()); echo '<form action="111.php" method="post"> <h2> <center> Paper Review </center></h2> <table width="75%" border="1">'; while($row = mysql_fetch_array( $result )) { echo '<tr> <td><b>PACTS:</b> <br><input type="text" name="pacts" size="25" maxlength="30" value="'. $row['pacts'] .'" /><br> </td> <td><b>Reviewer:</b> <br><input type="text" name="dock" size="25" maxlength="30" value="''" /><br> </td> </tr> <tr> <td><b>First Name:</b> <br><input type="text" name="fname" size="25" maxlength="30" value="'. $row['fname'] .'" /><br> </td> <td><b>Last Name:</b> <br><input type="text" name="lname" size="25" maxlength="30" value="'. $row['lname'] .'" /><br> </td> <td><b>Dock:</b> <br><input type="text" name="dock" size="25" maxlength="30" value="'. $row['dock'] .'" /><br> </td> </tr> <tr> <td><b>Sent Date:</b> <br><input type="text" name="sent_date" size="25" maxlength="30" value="'. $row['sent_date'] .'" /><br> </td> <td><b>Assign Date:</b> <br><input type="text" name="assgn_date" size="25" maxlength="30" value="'. $row['assgn_date'] .'" /><br> </td> <td><b>Interview Date:</b> <br><input type="text" name="interv_date" size="25" maxlength="30" value="'. $row['interv_date'] .'" /><br> </td> </tr> <tr> <td></b><br><input type="text" name="assgn_date" size="30" maxlength="30" value="Given to Reviewer" /> <br><input type="text" name="assgn_date" size="30" maxlength="30" value="Given to SUSPO" /> <br> <input type="text" name="assgn_date" size="30" maxlength="30" value="Given to Clerk" /> <br> <input type="text" name="assgn_date" size="30" maxlength="30" value="PSR Disclosed to Attn" /> <br> <input type="text" name="assgn_date" size="30" maxlength="30" value="PSR Disclosed to owner" /> </td> <td><b>Initials</b> <br><input type="text" name="dock" size="30" maxlength="30" /> <br> <input type="text" name="dock" size="30" maxlength="30" /> <br><input type="text" name="dock" size="30" maxlength="30" /> <br> <input type="text" name="dock" size="30" maxlength="30" /> <br> <input type="text" name="dock" size="30" maxlength="30" /></td> <td><b>Due Date:</b> <br><input type="text" name="due_rev" size="25" maxlength="30" value="'. $row['due_rev'] .'" /> <br> <input type="text" name="due_suspo" size="25" maxlength="30" value="'. $row['due_suspo'] .'" /> <br> <input type="text" name="due_clerk" size="25" maxlength="30" value="'. $row['due_clerk'] .'" /> <br> <input type="text" name="due_attny" size="25" maxlength="30" value="'. $row['due_attny'] .'" /> <br> <input type="text" name="due_" size="25" maxlength="30" value="'. $row['due_owner'] .'" /> </td> <td><br><input type="text" name="assgn_date" size="30" maxlength="30" value="Given to Reviewer" /> <br><input type="text" name="assgn_date" size="30" maxlength="30" value="Given to SUSPO" /> <br> <input type="text" name="assgn_date" size="30" maxlength="30" value="Given to Clerk" /> <br> <input type="text" name="assgn_date" size="30" maxlength="30" value="PSR Disclosed to Attn" /> <br> <input type="text" name="assgn_date" size="30" maxlength="30" value="PSR Disclosed to Owner" /> </td> <td><b>Actual Date:</b><br><input type="text" name="assgn_date" size="30" maxlength="30" value="" /> <br> <input type="text" name="assgn_date" size="30" maxlength="30" value="" /> <br> <input type="text" name="assgn_date" size="30" maxlength="30" value="" /> <br> <input type="text" name="assgn_date" size="30" maxlength="30" value="" /> <br> <input type="text" name="assgn_date" size="30" maxlength="30" value="" /> </td> </tr>; <td> <b>Employee Notes:</b> <br> <textarea name = "notes" rows=9 cols=100></textarea> </td> </tr>'; } echo '</table> </form>'; mysql_close(); // Close the database connection. ?> </tbody> </table> if($value != "0"){ $errors[] = 'Invalid option chosen'; }$value is a string. IF $value equals '00', it doesn't work why? It does not equal 0? I'm trying to check if a value equalis 1 or 0. LITERALLY the string has to be 1 or 0, if not I need to error out. Why is this so difficult? How does 2 zero's (00) = 0? Doesn't make sense. Especially when it's matching 2 STRINGs.. If it were a numeric value I could see PHP saying 00 might equal 0. But how does 00 and 0 equal the same thing? makes no sense. Edited by Monkuar, 23 January 2015 - 06:27 PM. Hey guys, I'm using a PHP form for my website & I can't get it to send the email correctly, all it send me is the first and last name, but none of the other boxes, any help? Also how can I secure it?
This is the PHP file:
<!DOCTYPE html> |