PHP - Stats Calculation
I have a table of members (18) with games played, won, drawn, lost and would like to know if its possible to have the points and percentage update automatically, example-
ID Member Grade Played Won Drawn Lost Points % 1 Player name 142 13 1 10 2 6 46.15 My web-page is currently static and i go to http://math.about.com/library/weekly/aa061502a.htm fill in the games played and points and it gives the percentage, i have very little knowledge of php and by some miracle have managed to create a database using wamp and have extracted the data onto local host web page, my code as follows please let me know if i have any errors- Code: [Select] <?php require "connect.inc.php"; echo "<table width='700'> <tr> <th></th> <th>Member</th> <th>Grade</th> <th>Played</th> <th>Won</th> <th>Drawn</th> <th>Lost</th> <th>Points</th> <th>&#37;</th> </tr>"; $result = mysql_query("SELECT * FROM members"); while ($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['member'] . "</td>"; echo "<td>" . $row['grade'] . "</td>"; echo "<td>" . $row['played'] . "</td>"; echo "<td>" . $row['won'] . "</td>"; echo "<td>" . $row['drawn'] . "</td>"; echo "<td>" . $row['lost'] . "</td>"; echo "<td>" . $row['points'] . "</td>"; echo "<td>" . $row['percentage'] . "</td>"; echo "</tr>"; } echo "</table>"; ?> Please tell me how i can have the points and percentage update automatically and keep in mind im a novice with php. Best wishes, John Similar TutorialsHiya, What's the best way of finding out and displaying the total number of users currently online, along a breakdown of how many of these users are members or guests? I also wish to find out and display the total number of users who were online today, along with a breakdown of how many of these users are members or guests. I've noticed that users of the same computer could of course use a different browser preference to another user of the same computer. What should happen in this situation? Any help is much appreciated. Cheers! Hello i whant to creat stats page for my website can sombady help me how can SELECT database id |user_id | site_id | date 1 | 2222 | 18 | 2011-11-28 06:10:06 select id COUNT(site_id ) from table WHERE date = ? i whant to select last 7 days from database and count site_id per day . Hey guys, I want to create stats of visitors and some other values in the database depending on time. The stats are supposed to be created one time per hour. What can I use for it? Cronjob? What will be if it doesn't work?? Thanks for helping! Hi Everyone, I have seen on the web that you can purchase some server monitoring applications, which mainly run using PHP. Because I don't necesserally need something so powerful, I just want to monitor memory usage and cpu usage. Is there anyway that I can do this using PHP? I have SMNP enabled if that helps? Thanks Matt I tried to code this, but failed miserably. What I wanted was a admin page that contained various stats of a football match. TEAM 1....................TEAM 2 0...........Score...........0 0.......Shots on target.......0 0.......Shots off target.......0 ect, ect.... The first way I layed it out was a table, i entered the data and it saved to a text file, which then displayed on stats.php in a table format. That then displayed elsewhere via an iframe. I was wondering if someone would code me a stats center like I've explained! You could even help me do it, I don't mind....As long as I get it! I need a simple line graph for my PHP site showing page views against date (monthly). Have tried to find plugins but can't find an appropriate one. Can someone please help with a script or direct me to a plugin. Attached is the kind of graph I'd like to have. Hi, Competitors vs. against each other and are recorded in a database. Each participant equally has 4 matches each, as you can see in the attatchment following the points gained in their played matches. I want to be able to determine the qualified participants according to either their "points" or "wins/losses". If two competitors have the same points, then I have already made a solution that another match must be generated for the two participants with the same points and draws can not be submitted which means the points will always be different for each team. I want to pick out half of participants 8/16 (screenshot below) with highest points which will be the qualifiers, or pick out half participants 8/16 with best match stats according to wins/losses. Any help I would be very grateful, thanks. Hey guys, What im trying to do is get the users screen resolution and place it into a database so that i can call it up and place it onto a stats page. So far i get the idea that you have to use Javascript to get the resolution then use PHP to pull that information. What i want to do is pull the screen resolutions and place them into a database so that i can call upon them to place into a stats page So far i have the following getting certain bits of information and banging them into the database using the stats.inc.php then calling them up and placing them onto stats.php. the stats.inc.php is included on every page of my site so it can track where a users has been etc etc. Im assuming i can insert something into my headerLoggedin.inc.php file that will pull the users resolution then use some PHP in the stats.inc.php script to pull that information and then insert it into my database which i can then easily pull from and place into the stats.php page. I know this seems like a bit of a silly thing to be doing, its for a college assignment and im pretty stumped. Any help is appreciated thanks guys. headerLoggedin.php Code: [Select] <?php include('includes/security.inc.php'); ?> <?php include('includes/stats.inc.php');?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="en-us" /> <link rel="stylesheet" href="css/index.css" type="text/css"/> <title>############</title> </head> <body> <!-- Start of wrapper div--> <div id="wrapper"> <!-- Start of header div--> <div id="header"> <div id="logo"><img src="./images/logo.png" width="412" height="32" alt="Elite Recruitment Services" /></div> <div id="navigation"> <ul class="nav"> <li><a href="news.php">News Page</a></li> <li><a href="edit.php">Edit text file</a></li> <li><a href="upload.php">Upload text file</a></li> <li><a href="stats.php">Stats</a></li> <li><a href="logout.php">Logout</a></li> </ul> </div> </div> <!--End of header div--> <!--Start of loginContainer div--> <div id="formsContainer"> stats.inc.php Code: [Select] <?php $db_host = "localhost"; // Databases host name $db_username ="#######"; // Database Username $db_password ="#######"; // Database Password $db_name ="dannymit_stats"; // Databases name $db_table="statTracker"; // Database table where the logins are stored mysql_connect("$db_host", "$db_username", "$db_password"); // Connects to the database using the preset host, username and password mysql_select_db("$db_name"); // Selects the database. //collect information... $browser = $_SERVER['HTTP_USER_AGENT']; // get the browser name $curr_page = $_SERVER['PHP_SELF'];// get page name $ip = $_SERVER['REMOTE_ADDR']; // get the IP address $from_page = $_SERVER['HTTP_REFERER'];// page from which visitor came $page = $_SERVER['PHP_SELF'];//get current page $width = $_GET['width']; //Gets users screen width $height = $_GET[['height']; //Gets users screen height //Insert the data in the table... $query_insert = "INSERT INTO statTracker (browser,ip,thedate_visited,page,from_page) VALUES ('$browser','$ip',now(),'$page','$from_page')" ; $result=mysql_query ( $query_insert); if(!$result){ die(mysql_error()); } ?> stats.php Code: [Select] <?php // Header include include('includes/headerLoggedin.inc.php'); include('includes/stats.inc.php'); ?> <br/><br/> <?php $db_host = "localhost"; // Databases host name $db_username ="######"; // Database Username $db_password ="######"; // Database Password $db_name ="dannymit_stats"; // Databases name $db_table="statTracker"; // Database table where the logins are stored mysql_connect("$db_host", "$db_username", "$db_password"); // Connects to the database using the preset host, username and password mysql_select_db("$db_name"); // Selects the database. $sqlquery = "SELECT * FROM `$db_table`"; $result = mysql_query($sqlquery); $num = mysql_num_rows($result); mysql_close(); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { printf ("Browser:<br/> %s<br/> IP Address:<br/> %s<br/> Date Visited:<br/> %s<br/> Page Visited:<br/> %s<br/> Paged Visited From:<br/> %s<br/>", $row[1], $row[2], $row[3], $row[4], $row[5]); echo "<br />"; } ?> <?php include('includes/footer.inc.php');?> I want to automatically import some affiliate stats from a few sites into my website. How can I do it? I am new to php. Dear All, I am trying to fetch the sum of a column for current date and subtract a value from the sum for currently selected record. The query i build works fine in MySql but when the same query i placed in php no result it's blank. Below is the query.
<?php //Calculation for no of paxs. $query2=mysqli_query($con,"SELECT SUM(noopaxs-gattl) FROM tblsupvisitor where date(EnterDate) = CURDATE() || gst = 'INH' || gst = 'IN' GROUP BY confno"); $calc_no_paxs_for_today=mysqli_fetch_row($query2); $gattl=$calc_no_paxs_for_today['gattl']; ?>
and her is the assignment to the textbox.
<div class="row form-group"> <div class="col col-md-3"> <label for="textarea-input" style="color: purple" class=" form-control-label"><strong>Total No. Of Adults</strong></label> </div> <div class="col-12 col-md-9"> <input name="gattl" id="gattl" rows="9" class="form-control" required="" value="<?php echo $gattl;?>"> </div> </div>
Any help in this regard will be highly appreciated.
Kind Regards, Naveed. This is a bit of a puzzle. Look at the sum and result below: Code: [Select] $markTotal += ($session['Mark'] / 100 * $session['SessionWeight']); Result on Browser Module: CHI2550 - Modern Database Applications 41.2 (this is $markTotal) Session: AAB 72(this is $session['Mark']) 20% (this is $session['SessionWeight']) (The percentage signs are just add ons) Session: AAE 67(this is $session['Mark']) 40% (this is $session['SessionWeight']) As you can see the answer to the calculation above is right, the answer is 41 .2 as it adds up the two session marks, divide by 100 and then times it by the total amount of the percentage. But I want to include a total mark where except it is out of the total session percentage (60% for above example), it is out of a 100% but I can not work as simple as that as in above example one session is worth more than other. I have worked out that the answer for the total mark of the above example out of 100% should be 69, but how do I achieve this in my calculation. Thank you and any help is much appreciated So how Hi, I have an itinerary form at http://www.happydaysremovals.com/estimate.html Customers fill this in, and it uses phpmailer-fe to email the results to myself. I use a HTML .tpl file so I can make the output email look as I want. All that is fine, but I would like a volume calculator. Next to each item on the form, the customer enters the amount of that item, usually 1 or 2. If it was say a setee, I want to define that a setee = 30 cubic feet, for example. Then I want the calculator to calculate the total cubic footage for all the variables, and include it in the html email. I know with javascript this can be done, but I was hoping for a PHP result and for it to somehow work in with phpmailer-fe, for example: </style> <script language="JavaScript"> function write_this() { var setteelarge; var setteemedium; var setteesmall; var setteelarge2; var setteemedium2; var setteesmall2; var setteelargeresult; var setteemediumresult; var setteesmallresult; var total; setteelarge = document.form1.LargeSettee.value; setteemedium = document.form1.MediumSettee.value; setteesmall = document.form1.SmallSettee.value; setteelarge2 = 45 setteemedium2 = 31 setteesmall2 = 22 setteelargeresult = (setteelarge * setteelarge2); setteemediumresult = (setteemedium * setteemedium2); setteesmallresult = (setteesmall * setteesmall2); total = (setteelargeresult+setteemediumresult+setteesmallresult) document.form1.Total_Cubic_Feet.value = total } </script> Basically, I want to be able to include the cubic feet total value to also be emailed to me in the HTML email, but preferably all in PHP. At the moment, I get everyones itinerary, but want to be automatically be able to work out the cubic footage. Thanks Hi, I have a calculation issue in my php. Below is my code: $ Code: [Select] moduletotal = 0; $modulecount = 0; $sessionweight = 0; while ($row = mysql_fetch_array($result)){ $moduletotal += $row['Mark']; $modulemark = (int)($moduletotal); // Here and above is the calculation which is simply adding the total number of marks // Below is the code that displays my results. The variable of the calculation is shown at the end of the last if statement (3rd one down) $output = ""; $studentId = false; $courseId = false; $moduleId = false; if($studentId != $row['StudentUsername']) { $studentId = $row['StudentUsername']; $output .= "<p><strong>Student:</strong> {$row['StudentForename']} {$row['StudentSurname']} ({$row['StudentUsername']})"; } if($courseId != $row['CourseId']) { $courseId = $row['CourseId']; $output .= "<br><strong>Course:</strong> {$row['CourseId']} - {$row['CourseName']} <br><strong>Year:</strong> {$row['Year']}</p>"; } if($moduleId != $row['ModuleId']) { $moduleId = $row['ModuleId']; $output .= "<p><br><strong>Module:</strong> {$row['ModuleId']} - {$row['ModuleName']} {$row['Credits']} $modulemark</p>"; } $output .= "<p><strong>Session:</strong> {$row['SessionId']} {$row['Mark']} {$row['Grade']} {$row['SessionWeight']}%</p>"; } echo $output; ?>The Results look like this at the moment (The answer the calculation is next to each Module): Student: Mayur Patel (u0867587) Course: INFO101 - Bsc Information Communication Technology Year: 3 Module: CHI2550 - Modern Database Applications 20 72 (72 is the answer to the calculation for the first module but this is incorrect at it should also add the 67 and thus become 139) Session: AAB 72 A 20% Session: AAE 67 B 40% Module: CHI2513 - Systems Strategy 20 200 (200 is the answer to the calculation for this module but this is incorrect it should be only 61. But what it has done is that it has added the 72 and 67 from the first module and added it with the 61 in this module) Session: AAD 61 B 50% SO WHAT MY QUESTION IS HOW CAN I GET THE CALCULATION SO THAT IT ONLY ADDS UP EACH SESSION MARKS THAT BELONGS TO A MODULE ONLY? IN THE EXAMPLE ABOVE IT SHOULD ONLY ADD THE MARKS FOR SESSION AAB AND AAE IN THE MODERN DATABASE APPLICATIONS MODULE AND THEN WHEN IT GETS TO THE NEXT MODULE WHICH IS SYSTEMS STRATEGY, THE MARKS FOR THAT MODULE SHOULD START AGAIN AND ADD ON THE MARKS FOR THE SESSION AAD IN THAT MODULE. HOPEFULLY YOU UNDERSTAND AND THANK YOU Below is the query if you want to look at it: Code: [Select] $query = " SELECT c.CourseName, st.CourseId, st.Year, st.StudentUsername, st.StudentForename, st.StudentSurname, s.ModuleId, s.SessionId, s.SessionWeight, gr.Mark, gr.Grade m.ModuleName, m.Credits, FROM Course c INNER JOIN Student st ON c.CourseId = st.CourseId JOIN Grade_Report gr ON st.StudentId = gr.StudentId JOIN Session s ON gr.SessionId = s.SessionId JOIN Module m ON s.ModuleId = m.ModuleId WHERE (st.StudentUsername = '".mysql_real_escape_string($studentid)."') ORDER BY c.CourseName, st.StudentUsername, m.ModuleName, s.SessionId "; The time dosen't calculate correctly!!! When the local time is 3:15pm on16th Nov 2010 - "Time Expired" dosen't show. When I echo $drawT-time() it shows 60000 odd. What's wrong here? $drawH = 15; $drawM = 15; $drawM = 11; $drawD = 16; $drawY = 2010; $cutoffT = 4; $drawT = mktime($drawH, $drawM, 0, $drawM, $drawD, $drawY); date_default_timezone_set("Australia/Melbourne"); if($drawT-time() < $cutoffT*60) { echo "Time Expired."; } Please help me calculate this according to the "if" condition. $scoreM['newtag'] + $scoreU['newPrice'] $SomeVar = 'currentPrice'; $queryU = "SELECT * FROM db1 WHERE bookprice = '".$SomeVar."'"; $resultU = mysql_query($queryU); $scoreU = mysql_fetch_assoc($resultU); echo $scoreU['newPrice']; echo $scoreU['weeklyScr']; echo $scoreU['priceX']; //// $WinVar = 'additionalAmount'; $query = "SELECT * FROM db2 WHERE booklist = '".$WinVar."'"; $result = mysql_query($query); $scoreM = mysql_fetch_assoc($result); echo $scoreM['newtag']; echo $scoreM['priceY']; if($scoreU['priceX']== $scoreM['priceY']) { $udatedValue = ($scoreM['newtag'] - $scoreU['newPrice']); echo(udatedValue); } else{ $udatedValue = ($scoreM['newtag'] + $scoreU['newPrice']); echo(udatedValue); } When I use this: echo number_format(150 + 20.95 + .5, 2); ... I get 170.95. Yet on my calculator, 150 + 20.95 + .5 gives me 171.45. Why is that? Good day! I've been stumbled into a situation wherein the user have predefined time (this will be the expiration time) and the system will have to compare the user time based on server time. I've done the job in getting the time with timezone inclusion using javascript var userDate = new Date(); // output : Tue Dec 06 2011 16:18:23 GMT+0800 (PHT) I passed that javascript value using ajax to the server, the problem I encounter is the compare the current server date with the userDate. Any solution? Thanks in advance. This is a bit of a puzzle. Look at the sum and result below: Code: [Select] $markTotal += ($session['Mark'] / 100 * $session['SessionWeight']); Result on Browser with explanation to help you: Module: CHI2550 - Modern Database Applications 35% (this is $markTotal) ... This is where I want add the total mark for 100% Session: AAB 100% (this is $session['Mark']) 10% (this is $session['SessionWeight']) Session: AAE 50% (this is $session['Mark']) 50% (this is $session['SessionWeight']) All percentage marks above are just add ons. As you can see the answer to the calculation above is right, the answer is 35 as it adds up the two session marks, divide by 100 and then times it by the total amount of the percentage. But I want to include a total mark where except it is out of the total session percentage (60% for above example as one Session is 40% and the other is 20%), it is out of a 100% but I can not work as simple as that as in above example one session is worth more than other. The total mark out of 100% of the above example should be 65%, but how do I achieve this in my calculation. It is not as simple as dividing the $session['Mark'] because one session is worth more than the other. So the above example will have 2 marks: one mark out of total percentage of the Sessions which for the above example is 35% and second mark is out of the full 100% of the module which is 65%. Thank you and any help is much appreciated Hi. I am writing software to choose employees for drug testing. Originally it was choosing 5 per day, Mon-Thu. No problem there, that's easy. Now, they want to ensure everyone gets tested each calendar year. So now I need the program to look at the date and calculate the days between now and 12/31 then divide the people that haven't been tested by days to get number per day that need testing so it gets all done by the end of the year.
The snag I hit is how to calculate it. I can easily get days to 12/31, but I need to drop the Fridays, Saturdays and Sundays of each week. That has me a little perplexed. Is there a way to make that kind of calculation? Thanks!
Hi I don't understand what I'm doing wrong, I want to subtract 6 months from my date, but I get 1969/07 as an answer? Code: [Select] <?php $date = date('Y/m'); echo $date; echo "<br/>"; $date1 = date ("Y/m", strtotime("-6 month", strtotime($date))); echo $date1; ?> |