PHP - I Have No Idea What Is Going On. Php Not Working.
OMFG! I have no idea what is going on!
Code: [Select] <?php if (isset($user_log)) { //************************************************************************************************************************************************ $user = $_SESSION['user']; $query = " SELECT title, sum, story_id FROM draft WHERE user='$user' "; $select = mysql_query($query); while($rows = mysql_fetch_assoc($select)); { $titledb = $rows['title']; $sumdb = $rows['sum']; $id_db = $rows['story_id']; echo "$titledb"; } } //************************************************************************************************************************************************* ?> I have no idea whats going on I have tried: 1. Using mysql_num_rows I get a number (1) 2.Trying to use the mysql_fetch_assoc outside of the while loop. The values are getting echo'ed out, but when I put the code in the while loop and the Code: [Select] $rows=mysql_fetch_assoc in the while peramiters, nothing happening. I have also tried putting other code in the while loop and it works. Its just the mysql values. also I tried using or die(mysql_errror()), It dies but no mysql error Similar TutorialsPHP newb here - apologies if the answer to this is really simple.
I've tried to add a geotargetting code into my website but it appears the elseif part isn't working, no matter what I do.
Here's the code - any idea why if is fine, and else is fine, but elseif isn't?
<?php if (function_exists('showCountryContentInPage')) { if(showCountryContentInPage(array("us", "ca"),1)) { // US $region = 'USA'; $country = codediesel_get_users_country(); $store_url = 'URL here'; } elseif(showCountryContentInPage(array("at", "es", "cy", "fi", "ee", "fr", "de", "el", "ie", "it", "mt", "lu", "lv", "nl", "pt", "sk", "si", "be"),1)) { // Europe $region = 'Europe'; $country = codediesel_get_users_country(); $store_url = 'URL here'; } else { // UK $region = 'UK'; $country = codediesel_get_users_country(); $store_url = 'URL here'; } ?> Hi there I am never the one to use something I don't simply understand but I was wondering if you could help me through why an errors occuring with my first attempt at a very primative MVC. Ok I understand them as being somewhat Model (data whether that be a database or a file system it's just data!), View is the way the page is assembled in (ZF that would be also the Layout right?) and then finally Controller (that handles all the user known and unknown requests), the controller is responsible for sending any responses back to the user, would you ever have view take the data from the model or would it always go via the controller? I know it wouldn't get output to the user as they may never understand it in it's raw form. But this is what I have come up with from this tutorial he http://php-html.net/tutorials/model-view-controller-in-php/ This is what I have done in I think completion: index.php: Code: [Select] <?php // NOT TO BE SHOWN IN A PRODUCTIONAL APPLICATION ALWAYS USE FALSE WHEN IN A PRODUCTIONAL SERVER! ini_set('display_errors', true); // We require the class for this to work so we do so using the require_once construct: require_once 'Controller.php'; // We ask for an object to be created of class/blueprint Controller but with no parameters $controller = new Controller(); // We then make invoke action as a function within Controller class $controller->invoke(); Controller.php: Code: [Select] <?php require_once 'Model.php'; class Controller { public $model; public function __construct() { $this->model = new Model(); } public function invoke() { if(!IsSet($_GET['book'])) { $books = $this->model->getBookList(); require 'booklist.php'; } else { $book = $this->model->getBook($_GET['book']); include 'viewbook.php'; // we could actually include this as one file though right? } } } Model.php: Code: [Select] <?php require_once 'Book.php'; class Model { public function getBookList() { return array('Jez\'s Great Book!'=> new Book('Jez\'s Great Book!', 'The best book on the planet about MVC\'s'), 'PHP5 and MySQL Bible'=> new Book('My most enterprising PHP and dynamic page content book ever!')); } public function getBook($title) { $allbooks = $this->getBookList(); return $allbooks[$title]; } } Book.php: Code: [Select] <?php class Book { public $title; public $author; public function __construct($title='', $author='') { $this->title = $title; $this->author = $author; } } booklist.php: Code: [Select] <?php foreach($books as $title=>$book){ echo "<pre>"; echo '<a href="index.php?book='.$book->title.'">$book->title</a>'; echo "</pre>"; } viewbook.php Code: [Select] <?php echo $book->title; echo $book->author; It's not the same as the tutorial exactly but I just wanted to see if I could get it working, the only problem is (I mean my sample data's just for the fun of it), however when I go to see the booklist.php The problem I am having is how to understand it getting the values into the list, when it says the 2nd one's basically not an index, does this come up for yourselves? I am just a bit confused, happy though kind of got this working, thank you in advance, Jeremy. Hi First of all, I know VERY little about PHP, The effort below is a wile guess that has gone wrong. I get this error Parse error: syntax error, unexpected T_IF in /home/repairyo/public_html/shop/includes/content/viewOrders.inc.php on line 57 I have no idea what ive done wrong, may be I am stupid for attempting it. Cheers Paul This is the original code Code: [Select] $view_orders->assign('VAL_STATE',$lang['glob']['orderState_'.$orders[$i]['status']]); This is the modified code Code: [Select] $view_orders->assign('VAL_STATE',$state = $results[$i]['status'] if ($state == '1') { "<font color='#ff9900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '2') { "<font color='#009900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '4') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '5') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '6') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '7') { "<font color='#ff9900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else { $lang['glob']['orderState_'.$orders[$i]['status']]); } I have a dropdown list where the values are retrieved form the mysql the dropdownlist is coded in php as below: $data = mysql_query("Select * From Project"); echo "<select name = 'Project' onchange = 'showUser(this.value)'>n"; while ($row = mysql_fetch_assoc($data)) { $id = $row['Project_Id']; $ProjectName = $row['ProjectName']; echo "<option value = $id>$ProjectName"; } echo"</select>"; echo "<br/>"; echo "<br/><div id='txtHint' style='width:30em; margin:0 auto;'></div><br/>"; this dropdownlist will retrieved the names of PROJECTS available in the database. when the user click any of the rpojects, it will displayed the engagements that belong to the selected PROJECT. This is also retrieved and display in a dynamic table using ajax. i have created a javascript function as below: <script type="text/javascript"> function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","try.php?q="+str,true); xmlhttp.send(); } </script> function showUser is placed in the "<select name = 'Project' onchange = 'showUser(this.value)'> my question is, is it possible that i display the data retrieved in the tables as hyperlinks? I want the user to be able to view the informations of the displayed engagements in another php page. the user can view the informations when they clicked on the hyperlinks of the engagement name that is displayed. the sample of table can be seen in the attachment. any idea on how to do this. Let me know cause im stuck So if I wanted to make sure my users were logged in, and had cookies & JavaScript enabled would this work...? Users enter site at index.php which sets a test cookie and calls itself (header location self in other words) if the test passed the user is redirected to the main page, if not then redirected to a page that has a we need cookies enabled page. Once in the main pages the cookie is checked and if present all good if not send back to index. Then I use session variables to track user data. I see this in my head but I'm not sure it works like I think and I am not sure how to code it. Your feedback would be greatly appreciated, and any pointers in how to code it would be prized as it would help me learn more so I don't have to ask next time. HI, I'm writing a auction website .in auction website we need to check for new information every second so it needs to be ajax. we have a timer which calculate the end time of every auction and it needs to be updated every second.Do you have any idea for reducing the process of calculating maybe a client side but something that is updated by server? I mean , the timer works with client side and when the users BID , the timer needs to be refresh.So every time that Bid button hilted the time should be refresh. What's you idea?How can do something like that? Thanks This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=313729.0 A few friends of mine run a little competition between ourselves for a bit of fun. This has been in the past, a sports prediction spreadsheet where we predict the outcomes of champions in various football leagues around the world.
Up to now its always been a very laborious spreadsheet with that my friend can no longer be bothered to do.
is there any way I can do this in php / html?
There would be 8 players predicting the outcome of 6 leagues. We award points for who gets the most, half points for coming close etc.
Any ideas as to what way to approach this would be appreciated. I amvery proficient in HTML and CSS, but a bit of a novice in PHP......but if there is a script or some idea to get this up and running I would be very appreciative.
Thanks
I was wondering if this is faster or better performance. Each time a user submit's a post on my forum I will make it +1 the .txt file on my main server directory called test.txt, then I can just call that on my main forum index to show the amount of total posts our board has, instead of using mysql queries to sum all of it from the tables... good idea? or am i retarded? Hi guys, I have a little issue, I have already got a quiz, here is some of the code from the quiz. Code: [Select] <?php session_start(); session_name("Question_Test"); require_once('questionsandanswers.php'); require_once('functions.php'); if (!isset($_SESSION['questions'])) $_SESSION['questions'] = array(); $id = which_question($_POST['some_field']); $score = 0; if (!isset($_POST['submit'])) { $_SESSION['dclty'] = $_POST['dclty']; if ($_SESSION['dclty'] == "beg") { ?> <script> window.open("extrahelp.php", height=300,width=300); </script> <?php } if ($_SESSION['dclty'] == "int") { ?> <script> window.open("pointers.php", height=300,width=300); </script> <?php } } if (!isset($_POST['submit'])) { $_SESSION['correct'] = array(); $_SESSION['wrong'] = array(); $_SESSION['finished'] = 'no'; if (isset($_SESSION['error'])) { unset($_SESSION['error']); $_SESSION['$num'] = 0; } else { $_SESSION['score'] = $score; $_SESSION['correct'] = array(); $_SESSION['wrong'] = array(); $_SESSION['finished'] = 'no'; $_SESSION['$num'] = 0; } } else { $_SESSION['$num'] = (int) $_POST['num']; $postedanswers = str_replace("_"," ",$_POST['answers']); if ($postedanswers == $answers[$_SESSION['$num']]['0']) { $_SESSION['score'] ++; $_SESSION['correct'][] = $postedanswers; } else { $_SESSION['wrong'][] = $postedanswers; } if ($_SESSION['$num'] < count($questions)-1) { $_SESSION['$num']++; } else { $last = true; $_SESSION['finished'] = 'yes'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Forensics E-learning Package</title> <?php echo $_SESSION['score']; if (!isset($last)) { echo "<script type=\"text/javascript\" src=\"form.js\"></script>"; } ?> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="wrapper"> <div id="header"> <div id="toplinks"> </div> </div> <div id="menu"> <ul> <li><a class="selected" href="home.html">Home</a></li> <li><a href="initialquiz.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> </ul> </div> <div id="content"> <div id="main"> <h1>Initial Quiz</h1><BR /><BR /> <h1>Protection Section</h1><BR /><BR /> <?php if (!isset($last)){?> <h2>Questions <?php echo $_SESSION['$num']+1; ?>:</h2> <p><strong><?php echo $questions[$_SESSION['$num']]; ?></strong></p> <form id="questionBox" method="post" action="initialquiz.php"> <?php $pattern = ' '; $replace = '_'; $shuffledAnswers = shuffle_assoc($answers[$_SESSION['$num']]); #var_dump($newanswers); foreach ($shuffledAnswers as $answer) { $answer2 = str_replace($pattern,$replace,$answer); echo "<li><input type=\"radio\" id=\"$answer2\" value=\"$answer2\" name=\"answers\" />\n"; echo "<label for=\"$answer2\">$answer</label></li>\n"; } ?> <input type="hidden" name="num" value="<?php echo $_SESSION['$num']; ?>" /> <input type="submit" id="submit" name="submit" value="Submit Answer" /></p> </form><BR /><BR /><b> <?php } else { echo "<p id=\"compare\"><a href=\"detection.php\">Next Section! <img src=\"images/arrow.png\" /></a></p>"; } ?> <?php $_SESSION['$ProtectionPercent'] = number_format(($_SESSION['score'] * 100) / 5); ?> </b> </div> <div id="right"> <h2>Right Menu</h2> <div class="rightitem"> <ul> <li><a class="selected" href="home.html">Home</a></li> <li><a href="initialquiz.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> </ul> </div> </div> </div> <div class="clearbottom"></div> <div id="footer"> <p id="legal"> </p> </div> </div> </div> </body> </html> The problem is, is that everytime i refresh my page the score counter increments. I have been chatting to a friend and they recommended some coding ideas that may work to stop this, however can any1 help me with a little more on implementing it to my systems? here is the recommended code Code: [Select] session_start(); if (!isset($_SESSION['questions'])) $_SESSION['questions'] = array(); # assuming which_question gives the proper id for the question $id = which_question($_POST['some_field']); # Only handle post data if questions hasn't allready been answered if (!isset($_SESSION['questions'][$id])) { # remove anything other than a-z, A-Z and regular whitespace from answer $answer = preg_replace('#[^a-zA-Z ]#', '', $_POST['answer']); $_SESSION['questions'][$id]['answer'] = $answer; $_SESSION['questions'][$id]['points'] = grade_answer($answer); # ... } Any help would be hugely Appreciated. Thanks Labce I'm building a game and I'm wanting to create mobile monsters for people to click on and fight. I have an arena that works fine, but I would love to have this additional feature. Here's what it would entail: Clicking on the name of the monster. Starting the fight (which is already designed and implemented) I need help with: Is there a way to make a mobile link, essentially. The monsters themselves are identified in a mySQL database with a specific ID. In the arena, the players click on a monster, and the battle begins. So, I need a way to make this "link" mobile. Thoughts? Ideas? Suggestions? Thanks! i dont know how to fix this problem..please help me guys --- so this is my index Code: [Select] <? session_start(); if(!isset($_SESSION['administrator'])){ header("location:../login.php"); } include ("../config.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>e-Leave</title> <link rel="stylesheet" href="../style.css" type="text/css" media="all" /> </head> <body> <!-- Header --> <div id="header"> <div class="shell"> <!-- Logo + Top Nav --> <div id="top"> <h1>e-Leave (Cpanel)</h1> <div id="top-navigation"> Welcome <a href="#"><strong><? $user=($_SESSION['administrator']); echo $user; ?></strong></a> <span>|</span> <a href="index.php">Home</a> <span>|</span> <a href="logout.php">Log out</a> </div> </div> <!-- End Logo + Top Nav --> <!-- Main Nav --> <? include ("../header/header_cpanel.php"); ?> <!-- End Main Nav --> </div> </div> <!-- End Header --> <!-- Container --> <div id="container"> <div class="shell"> <!-- Main --> <div id="main"> <div class="cl"> </div> <!-- Content --> <div id="content"> <? if(isset($_GET[view])) { $view = $_GET[view]; } if ($view == '' ){ include ('employeeleaveapplication.php'); } if ($view == 'createaccount' ){ include ('createaccount.php'); } if ($view == 'createaccounta' ){ include ('createaccount_add.php'); } if ($view == 'createaccounti' ){ include ('createaccount_insert.php'); } if ($view == 'createaccountd' ){ include ('createaccount_delete.php'); } if ($view == 'createaccounte' ){ include ('createaccount_edit.php'); } if ($view == 'createaccountu' ){ include ('createaccount_update.php'); } if ($view == 'createlogina' ){ include ('createlogin_add.php'); } if ($view == 'createlogini' ){ include ('createlogin_insert.php'); } if ($view == 'employeedirectory' ){ include ('employeedirectory.php'); } if ($view == 'employeedirectoryl' ){ include ('employeedirectory_list.php'); } if ($view == 'employeedirectorya' ){ include ('employeedirectory_adjustment.php'); } if ($view == 'employeedirectoryai' ){ include ('employeedirectory_adjustment_insert.php'); } if ($view == 'employeedirectoryca' ){ include ('employeedirectory_cancel_adjustment.php'); } if ($view == 'employeedirectorycl' ){ include ('employeedirectory_cancel_application.php'); } if ($view == 'changepassword' ){ include ('changepassword.php'); } if ($view == 'changepasswordi' ){ include ('changepassword_insert.php'); } if ($view == 'branch' ){ include ('setup_branch.php'); } if ($view == 'brancha' ){ include ('setup_branch_add.php'); } if ($view == 'branchi' ){ include ('setup_branch_insert.php'); } if ($view == 'branchd' ){ include ('setup_branch_delete.php'); } if ($view == 'branche' ){ include ('setup_branch_edit.php'); } if ($view == 'branchu' ){ include ('setup_branch_update.php'); } if ($view == 'designation' ){ include ('setup_designation.php'); } if ($view == 'designationa' ){ include ('setup_designation_add.php'); } if ($view == 'designationi' ){ include ('setup_designation_insert.php'); } if ($view == 'designationd' ){ include ('setup_designation_delete.php'); } if ($view == 'designatione' ){ include ('setup_designation_edit.php'); } if ($view == 'designationu' ){ include ('setup_designation_update.php'); } if ($view == 'leavetype' ){ include ('setup_leavetype.php'); } if ($view == 'leavetypea' ){ include ('setup_leavetype_add.php'); } if ($view == 'leavetypei' ){ include ('setup_leavetype_insert.php'); } if ($view == 'leavetyped' ){ include ('setup_leavetype_delete.php'); } if ($view == 'leavetypee' ){ include ('setup_leavetype_edit.php'); } if ($view == 'leavetypeu' ){ include ('setup_leavetype_update.php'); } if ($view == 'publicholiday' ){ include ('setup_publicholiday.php'); } if ($view == 'publicholidayd' ){ include ('setup_publicholiday_delete.php'); } if ($view == 'publicholidaya' ){ include ('setup_publicholiday_add.php'); } if ($view == 'publicholidayi' ){ include ('setup_publicholiday_insert.php'); } if ($view == 'publicholidaye' ){ include ('setup_publicholiday_edit.php'); } if ($view == 'publicholidayu' ){ include ('setup_publicholiday_update.php'); } if ($view == 'report' ){ include ('report.php'); } if ($view == 'report_leave' ){ include ('report_leave.php'); } if ($view == 'print' ){ include ('report_print.php'); } ?> </div> <!-- End Content --> <!-- Sidebar --> <? include ("../header/dashboard_cpanel.php"); ?> <!-- End Sidebar --> <div class="cl"> </div> </div> <!-- Main --> </div> </div> <!-- End Container --> <div id="footer"> <? include ("../footer/footer.php"); ?> </div> </body> </html> -- this is my dashboard panel code Code: [Select] <div id="sidebar"> <!-- Box --> <div class="box"> <!-- Box Head --> <div class="box-head"> <h2><b>Dashboard</b></h2> </div> <!-- End Box Head--> <div class="box-content"> <a href="index.php?view=createaccount"><span> <img src="../images/createaccount.jpg"/> Create Account</span></a> <div class="cl"> </div> <div class="cl"> </div> <a href="index.php?view=employeedirectory"><br><span> <img src="../images/employee.jpg"/> Employee Directory</span></a> <div class="cl"> </div> <a href="index.php?view=report"><br><span> <img src="../images/status-report1.jpg"/> Report</span></a> <div class="cl"> </div> <div class="cl"> </div><a href="index.php?view=changepassword"><br> <span> <img src="../images/key.jpg"/> Change Password</span></a> </div> </div> <div class="box"> <!-- Box Head --> <div class="box-head"> <h2><b>Setup</b></h2> </div> <!-- End Box Head--> <div class="box-content"> <a href="index.php?view=branch"><br><span> <img src="../images/branch.jpg"/> Branch</span></a> <div class="cl"> </div> <div class="cl"> </div><a href="index.php?view=designation"><br> <span> <img src="../images/designation.jpg"/> Designation</span></a> <div class="cl"> </div> <div class="cl"> </div><br> <a href="index.php?view=leavetype"><span> <img src="../images/leave.jpg"/> Leave Type</span></a> <div class="cl"> </div> <div class="cl"> </div><br> <a href="index.php?view=publicholiday"><span> <img src="../images/pb.jpg"/> Public Holiday</span></a> </div> </div> </div> ----- and this is the where the problem page is Code: [Select] <!-- Box --> <div class="box"> <!-- Box Head --> <div class="box-head"> <h2 class="left">Report</h2> </div> <!-- End Box Head --> <!-- Table --> <div class="table"> <div class="right"> <br> </div> <div id="box" valign="top"> <br> <h3><FORM name ="reportbutton" method="post" align="left" action="index.php?view=report"> <strong>Leave Application Listing </strong>| <Input type = "Submit" Name = "Submit1" Class="button" VALUE = "Back To Report"> </h3> </FORM> <br><br> <form name="leavebutton" method="post" action="index.php?view=report_leave"> <? $b=$_GET['b']; $m=$_GET['m']; $y=$_GET['y']; if ($b <> '' && $m <> '' && $y <> '') { $branch=$b; $leavemonth=$m; $leaveyear=$y; } else { $branch=$_POST['branch']; $leavemonth=$_POST['leavemonth']; $leaveyear=$_POST['leaveyear']; } $connection=mysql_connect("$server", "$username", "$password") or die("Could not establish connection"); mysql_select_db($database_name, $connection) or die ("Could not select database"); $query="SELECT * from tblworkgroup"; $result=mysql_query($query);?> Branch <select name="branch" > <option value="all">ALL Branches</option> <? while($row=mysql_fetch_array($result)) { ?> <option value= "<?=$row['WorkGroupID']?>" <? if ($branch==$row['WorkGroupID']){ echo 'selected'; } ?> ><?=$row['WorkGroupName']?></option> <? } ?> </select> </td> </tr> <br><br><br> Month <select name="leavemonth" > <option value = "1" <? if ($leavemonth==1){ echo 'selected'; } ?>>January</option> <option value = "2" <? if ($leavemonth==2){ echo 'selected'; } ?>>February</option> <option value = "3" <? if ($leavemonth==3){ echo 'selected'; } ?>>March</option> <option value = "4" <? if ($leavemonth==4){ echo 'selected'; } ?>>April</option> <option value = "5" <? if ($leavemonth==5){ echo 'selected'; } ?>>May</option> <option value = "6" <? if ($leavemonth==6){ echo 'selected'; } ?>>June</option> <option value = "7" <? if ($leavemonth==7){ echo 'selected'; } ?>>July</option> <option value = "8" <? if ($leavemonth==8){ echo 'selected'; } ?>>August</option> <option value = "9" <? if ($leavemonth==9){ echo 'selected'; } ?>>September</option> <option value = "10" <? if ($leavemonth==10){ echo 'selected'; } ?>>October</option> <option value = "11" <? if ($leavemonth==11){ echo 'selected'; } ?>>November</option> <option value = "12" <? if ($leavemonth==12){ echo 'selected'; } ?>>December</option> </select> Year <select name="leaveyear" > <option value = "2010" <? if ($leaveyear==2010) { echo 'selected';} ?>>2010</option> <option value = "2011" <? if ($leaveyear==2011) { echo 'selected';} ?>>2011</option> <option value = "2012" <? if ($leaveyear==2012) { echo 'selected';} ?>>2012</option> <option value = "2013" <? if ($leaveyear==2013) { echo 'selected';} ?>>2013</option> <option value = "2014" <? if ($leaveyear==2014) { echo 'selected';} ?>>2014</option> <option value = "2015" <? if ($leaveyear==2015) { echo 'selected';} ?>>2015</option> <option value = "2016" <? if ($leaveyear==2016) { echo 'selected';} ?>>2016</option> <option value = "2017" <? if ($leaveyear==2017) { echo 'selected';} ?>>2017</option> </select> <input type='submit' name='submit' value='Preview' Class="button" onclick='return validate()'> </div> </form> <br /><br /> <div id="box" valign="top"> <h3> <strong>Leave Application Details</strong>  </h3> <br><br> <FORM name="printbutton" method="post" align="left" action="report_print.php" target="_blank"> <input type="hidden" name="leavemonth" value="<?php echo $leavemonth; ?>"> <input type="hidden" name="leaveyear" value="<?php echo $leaveyear; ?>"> <input type="hidden" name="branch" value="<?php echo $branch;?>"> <Input type = "Submit" Name = "Submit1" Class="button" VALUE = "Print Leave Details"> </form> <table width="80%" align="center" > <thead> <tr> <th width="700px" align="left">Name</a></th> <th width="500px" align="center"></a>Application Date</th> <th width="500px" align="center"></a> </th> <th width="500x" align="right"></a>Reason</th> </tr> </thead> <tbody> <? /*echo "branch:".$branch.'<br />'; echo "leavemonth:".$leavemonth.'<br />'; echo "leaveyear:".$leaveyear.'<br />';*/ //-------------------------------------------------- if ($leavemonth =='' || $leaveyear =='' || $branch == '') { // one value missing, so don't display } else { // start display data $branchtracker = ''; if ($branch=='all'){ $branch = '%'; } $rs = mysql_query( " call vwleavereport('$leavemonth', '$leaveyear', $branch, 0);"); $query="SELECT *, MONTH(tblleaveapplication.DateFrom) as DFMonth, MONTH(tblleaveapplication.DateTo) as DTMonth, YEAR(tblleaveapplication.DateFrom) as DFYear FROM `tblleaveapplication` LEFT JOIN `tblemployee` ON tblleaveapplication.employeeid = tblemployee.id WHERE WorkGroupID LIKE '".$branch."' AND ( (MONTH(tblleaveapplication.DateFrom)=".$leavemonth." AND YEAR(tblleaveapplication.DateFrom)=".$leaveyear.") OR (MONTH(tblleaveapplication.DateTo)=".$leavemonth." AND YEAR(tblleaveapplication.DateFrom)=".$leaveyear.") ) ORDER BY WorkGroupID "; $result = mysql_query($query); while($row=mysql_fetch_array($result)) { if ($branchtracker<>$row['WorkGroupID']){ echo '<tr><td colspan=4 style="background-color: #e8e8e8; font-weight: bold;">'.$row['WorkGroupID'].'</td></tr>'; $branchtracker = $row['WorkGroupID']; } echo '<tr>'; echo '<td>'.$row['EmployeeName'].'</td>'; echo '<td>'.$row['DateFrom'].'</td>'; echo '<td>'.$row['DateTo'].'</td>'; echo '<td>'.$row['Purpose'].'</td>'; echo '</tr>'; } } ?> </table> The problem is the panel should be out on the RIGHT side..how do i fix it. Hi I know my title doesn't give any information but I really have no idea what my problem is. The problem I have is that for some reason my code just stopped working, it was working fine in the beginning and then all of a sudden I'm getting undifined index: item, and I'm not sure what it was that I did wrong since it was working fine in the beginning. Can someone please help because this has me confused Thank you Hi all, i want to write seating plan page, i want it to work by having the logged in user click on a link or image and the system will mark that users username into that seat. I have everything working in terms of the log in but as far as this page goes i really have no idea how i would start with it. If your not sure what i mean i can put it this way to make it much more understandable. If my page had the numbers 1 through to 49 listed down the side and next to each number it says as default "availible", but if the user click on that number the text next to that number changes from "availible" to the users username and no one others can click on that number as its "seat" or "number" has been taken. My users are stored within a mysql database and my site uses sessions like so: $_SESSION[username] = $row[username]; Many thanks for your help
Hi guys, thanks I think a switch break will help in this situation but I am definitely open to suggestions The problem I am have is that if there are 2 "Funner" or "Funnest" in the database then it displays duplicates in the in the column. I know that is what the code is telling it to do. If you look at the first row it should split them if there are 2 and display one in each column. In one time slot there is only allowed: - 1 Fun - 1 Funner or Funnest - 1 Funner or Funnest The case I am working with is there is 1 Fun and 2 Funners. The 2 Funners should split and display one in each "Funner/Funnest" column. There are planty of unique identifiers if someone has an idea for me. function taken($theType, $theTime){ $day_view = $_GET['date']; $DOP = explode("-", $_GET['date']); $topDOP = date("M", mktime(0, 0, 0, $DOP['1']))." ".$DOP['2'].", ".$DOP['0']; $dayDOP = date("l", mktime(0, 0, 0, $DOP[1], $DOP[2], $DOP[0])); connect(); $sql = "select * from party_times where dates = '$day_view' and paidID ='paid' and times = '$theTime'"; $result = mysql_query($sql) or die(mysql_error()); $day_count = mysql_num_rows($result); while($info = mysql_fetch_assoc($result)){ if($info['type'] == "$theType" && $info['times'] == "$theTime"){ $conID = "select DISTINCT confirmID from party_receipt where partyID = '".$info['partyID']."'"; $conqu = mysql_query($conID) or die(mysql_error()); while($con = mysql_fetch_assoc($conqu)){ $cid = $con['confirmID']; echo "<a href='party_booked.php?view=$cid'>RESERVED</a>"; }free($conqu); } }free($result); } Call the function: Code: [Select] <tr> <td width="25%"></td> <td width="25%" align="center">Fun</td> <td width="25%" align="center">Funner / Funnest</td> <td width="25%" align="center">Funner / Funnest</td> </tr> <tr> <td>11:00 AM</td> <td class = "res"><?php taken("Fun", "11:00 AM"); ?></td> <td class = "res"><?php taken("Funner", "11:00 AM"); ?></td> <td class = "res"><?php taken("Funnest", "11:00 AM"); ?></td> </tr> Thank you! i have a drop-down list of coures from course table. then i have two text field to enter No of Ques: Allocated Marks: for example: if i select PHP course and enter 4 for No of Ques , 25 for Allocated marks then it should srote in anothe database table like this Course | QuesNo | Marks PHP 1 25 PHP 2 25 PHP 3 25 PHP 4 25 Can anyone help for this code.hope this will not too dificult for you guys. i will really apriciate. Thanks I've been trying to think of the best way to build a PHP based chat room. Obviously a push method would work the greatest but I have been unable to find any such techniques using PHP so this is the only alternative I can think of. When a user logs in to the chat, a file is created in a secure directory on the server for the user. This file will store messages to be sent to the user. Each time someone sends a message to the chat, the message is inserted into every user's file. Then, using AJAX, the user in chat will "reload" the chat every few seconds, which will simply access a PHP script that reads the file, sends it to the user, then truncates the file contents to zero. My concern is obviously the high frequency of server loads to access the chat file, but this is why I would try to minimize the server's effort for retrieving chat content and focus the efforts more on sending messages since this action is done less often. I'm looking for suggestions on what would be best to keep the system efficient... maybe some ideas of headers to send which may help with optimization. Thank you for your time. OK here is what I have going on right now. Currently I'm trying to build a excel spread sheet into a dynamic form via php. The results are basically questions and are stored each week so for one section they may be asking how many visitors, employee's , etc.. now some of these values that are being entered are going to be used in another question per-say but the result may come from other values that were already submitted so these questions would not be shown in the form that needs to be made later on. The form I'm having trouble with is the initial form to help generate the formula's for these different questions. So what I was going to start doing was have it list all the questions with a check box next to the question if the formula for said question was something like add these two questions and the divide by this set of questions or a whole number then it would display a list of questions for adding together and the get the total from that set and then do a expression afterwards like adding, subtracting, multiplying or dividing. So I was thinking I should list like a set of buttons I think in the beginning. What is the first task at hand Totaling, Adding, Subtracting, Dividing, Multiplying and then when they click on this it would refresh the page and bring up a box that lists all the different questions for them. Then saving the values as which ever button they clicked and once they do this. Then they could either click on say a more button which would pass the values as a array back to the page and continue on or they could click submit and pass the values into a db field as a formula but this is my first concept and would like to know if there may be a better way of doing it. Hello guys I am developing my own system with event calendar but I stucked in the part where I should mark in the same way event which continue more than one day.What is my point - lets take for example google calendar, here you can see how the bar is purple for all 3 days marked for street cleaning : http://www.file-extensions.org/imgs/app-picture/6718/google-calendar.jpg Can you give me only an idea how I should proceed,what to use to achieve such result,what are my best options ? Thank you |