[Solved] show leave record in each month

Please use field value as a column name then you can easily solved this. Use below query: SELECT leaves.id, SUM( CASE WHEN (leaves.type=”Annual”) THEN leaves.noOfDays ELSE NULL END ) AS Annual, SUM( CASE WHEN (leaves.type=”Casual”) THEN leaves.noOfDays ELSE NULL END ) AS Casual, SUM( CASE WHEN (leaves.type=”Medical” ) THEN leaves.noOfDays ELSE NULL END ) AS … Read more

[Solved] MySQL Select from three tables [closed]

something like this? QUERY: SELECT country, profession, MAX(money) AS money FROM ( SELECT u.country, g.profession, SUM(um.money) AS money FROM user_money um JOIN users u ON u.id = um.user_id JOIN groups g ON g.id = um.group_id GROUP BY g.profession, u.country ORDER BY um.money DESC ) t GROUP BY country ORDER BY money DESC SEE DEMO OUTPUT: … Read more

[Solved] PHP how to include everything i type in my textbox to mysql database [duplicate]

No, You dont use str_replace(), you have addslashes() and stripslashes(), those two are the two functions you are looking for. Changing a string with str_replace functions isnt a smart thing to do. Those functions aren’t created with this in mind, the add/striposlashes are. You might forget a character which you needed to str_replace with a … Read more

[Solved] PHP – Login Form does not show [closed]

(tested) The reason why your form is not showing is because of these two lines: 1) This one had a missing closing parentheses ) at the end. $password = md5(md5(“Ji5t63s”.password.”v5h2ih47″); Should be: $password = md5(md5(“Ji5t63s”.password.”v5h2ih47″)); 2) The <a href=”https://stackoverflow.com/questions/19200663/./member.php”> – Problem is the (unescaped) double quotes or use of single quotes. Your existing line: echo … Read more

[Solved] mysql user defined variables as derived table

Are you looking for something like this? SELECT * FROM ( SELECT 1 value UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 ) table1 Here is SQLFiddle demo You can easily produce it in php like this using implode() $myArr = array(1,2,3,4); $sql=”SELECT * FROM (SELECT “; $sql .= implode(‘ value … Read more

[Solved] Need to create a query for monthly data [closed]

You can get dynamic records using current month, by the following query SELECT * FROM table_name WHERE CREATED_DATE BETWEEN DATE_FORMAT(NOW(),’%Y-%m-20′) – INTERVAL 1 MONTH AND DATE_FORMAT( NOW(),’%Y-%m-20′) Check the live result at the fiddle http://sqlfiddle.com/#!2/4668c/7 7 solved Need to create a query for monthly data [closed]

[Solved] How to pass a variable from a page to other in php

You can store the order number in the session. This way, it will be protected and persisted across pages. When you insert the order in book_order.php, store it in the session: $sql2=mysql_query(….); // inserting if($sql2){ $_SESSION[‘order_id’] = mysql_insert_id(); } Now, in book_order2.php you can retrieve the order ID before you do the insert of the … Read more

[Solved] Trying to not have repeating data (MySQL, php) [closed]

I’m not sure what are you trying to do, but you don’t want to use the GROUP BY clause. If you want to select all entries, use: mysql_query(“SELECT * FROM `testimonials`”); If you want to select one random entry, use: mysql_query(“SELECT * FROM `testimonials` ORDER BY RAND() LIMIT 1”); and get rid of the while … Read more

[Solved] How to fetch all data from database? [closed]

DO NOT USE MYSQL, instead use MySQLi as MySQL is DEPRECATED . But: $tid=$_SESSION[‘id’]; $a=mysql_query(“select * from tbl_curriculum_sched where TEACHER_ID=’$tid'”) or die(“$ a error : “.mysql_error()); while($ad=mysql_fetch_array($a)){ $sql= mysql_query(“SELECT * from enrolled where CURRICULUM_SCHED_ID=’$ad[0]'”) or die(“inner while: “.mysqli_error()); … To those of you commenting and comlaining that the OP should be using $a, rather than … Read more

[Solved] How I Can Use Multi Table for While my data in php? [closed]

Here is a query writen to get all rows from your table. //connect to database $dbhost=”localhost”; $dbuser=”root”; $dbpass=””; $dbname=”databasename”; $conn = mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbname, $conn) or die (‘connection problem’); $html=””; $sql = “” . ” SELECT * FROM customer, sell, control ” . “”; $data = mysql_query($sql); if (mysql_num_rows($data) > 0) { $html .= … Read more

[Solved] Save position of element with Jquery, PHP and MySQL [closed]

I don’t know what do mean by “saving position of an element” and how can that be useful, but you can try jQuery position() and $.ajax() methods: Get the current coordinates of the first element in the set of matched elements, relative to the offset parent. var t = $(‘a.icon’).position().top; var l = $(‘a.icon’).position().left; $.ajax({ … Read more

[Solved] How to compare two variables in php

I want to compare coming get variable with nursery But then you are comparing with Nursery if ($results==”Nursery”) Are you aware that that comparison is case-sensitive? Also that code is poor. It should simply be $results=isset($_GET[‘results’]) ? $_GET[‘results’] : NULL; Do not use error suppression when you are learning something new. And Oh, How can … Read more