PHP - Query Problem (slight Php Related)
Hey guys for some reason my script is being strange.
<? if(!empty($_POST['why'])) { $why = mysql_real_escape_string($_POST['why']); $answer = $_POST['answer']; $id = $_POST['cid']; if($answer == "Accept") { $query1 = mysql_query("UPDATE characters SET accepted = '1' WHERE id = '".$id."'"); $aquery = mysql_query("UPDATE applications SET tester = '".$_COOKIE['Username']."', accepted = '1', answered = '1' WHERE cid = '".$id."'") or die('Could not connect: ' . mysql_error()); echo"Successfully accepted"; } } If you notice the echo it outputs the successfully executed, tho the mysql query doesn't go through for some strange issue even through it says it does since I got the or die(mysql_error) thing and it still doesn't output a error. So I got a hard time finding the problem. Similar TutorialsHi I have been getting this error. mysql_fetch_array() expects parameter 1 to be resource, boolean given Its driving me mad I know its something really simple. Can anyone see what it is? Code: [Select] mysql_select_db("product", $con); $sqlout = mysql_query("SELECT * FROM 'tblt' WHERE 'UID' =('$ids')"); while($sqlres = mysql_fetch_array($sqlout)) Thanks James Hi, I'm trying to set up a page which first queries for mySQL record results matching a country that the user selects. This works fine, but in the event of there being no records for that country, I want it to look at another field, "Region" and pick the records matching that Region instead. For example, a user searches for "Australia" but there are no matching records. So, I want it to pick all the records for the region of Australasia, and display records for Australia, New Zealand, Papua New Guinea and so on. I had created the following: $query = "SELECT * FROM specialists WHERE Country LIKE '$country' ORDER BY SpecialistName"; // specify the table and field names for the SQL query //$query .= " limit $s,$limit"; $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); if ( $numrows == 0 ) { echo '<p>We don\'t have any results for specialists in countries near to yours at the moment. Please try <a href="specialists.php" style="text-decoration:underline;">searching a different country</a></p>'; } // get results $result = mysql_query($query) or die("Couldn't execute query"); // display the results returned while ($row= mysql_fetch_array($result)) { $region = $row["Region"]; $count++ ; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } echo '<table width="600" class="cardisplay"><tr>'; $count = 1 + $s ; echo $region; // Build SQL Query $query2 = "SELECT * FROM specialists WHERE Region LIKE '$region' ORDER BY SpecialistName"; // specify the table and field names for the SQL query //$query .= " limit $s,$limit"; $numresults=mysql_query($query2); $numrows=mysql_num_rows($numresults); // get results $result = mysql_query($query2) or die("Couldn't execute query"); // display the results returned while ($row= mysql_fetch_array($result)) { $title1 = $row["ID"]; $specialistname = $row["SpecialistName"]; $address1 = $row["Address1"]; $address2 = $row["Address2"]; $address3 = $row["Address3"]; $address4 = $row["Address4"]; $address5 = $row["Address5"]; $postcode = $row["Postcode"]; $country = $row["Country"]; $region = $row["Region"]; $website = $row["Website"]; $email = $row["Email"]; $telephone = $row["Telephone"]; $businesstype = $row["BusinessType"]; //followed by echoing out the various data etc. etc. But the problem is that $region is always blank / empty in the cases where $query is empty, so I can't pull the value out and therefore $query2 is also empty... Any ideas? Some of you may have seen one of my many posts about email issues. Some users don't get them, and I have determined it is probably because we are marked as spam.
We are a service that grades sales team members on their phone skills. Listening to pre-recorded calls, grading and uploading them to our site, and then another part of our business looks them over and sometimes leaves a message that then get's forwarded to this persons work email.
I have determined there is ways to get marked as spam as default by not having an opt out link. This is not an option, these sales members employer has opted in, and the emails are going to work related accounts hosted at that employer. Also, if one of these staff members is not so bright, or disgruntled they may mark us as spam anyways. The bottom line is that we have very little control over whether we are or are not marked as spam.
So we want to start looking into sending text messages and this is where I start to question how good of an idea this is.
First off, if it was me, and the messages where being sent to a device that my employer did not provide, I would in no way want work related text messages coming to me. Unless there is a vested interest in getting them. IE, I'm the boss at this place and am always on the clock. What if you are on the bottom? It's just a job for you.
What if it is a pre-paid device, text messages cost money. What then? What if they don't even have, or want a cell phone?
The short of it is this. If I'm at a job that is just another job, and this employer tells me that I have to get these messages. I'm going to look for another job. I see the organizations having continuous issues and complaints from their employees. Thus us as a business having issues keeping clients.
What am I getting into here? What are your opinions on this matter? What are your recommendations as to alerting users of something on our site that we can rest assured are being received 100% of the time?
Thanks!
Nick
My local IT department is migrating to a "hardened" LAMP/PHP environment. The PHP application at http://library.uww.edu/php/showrp.php is being moved to this new "hardened" environment and the "Title/Subject/Issue:" search option does not work in this environment. The "Title/Subject/Issue:" search option does however work within the "non-hardened" environment at http://library.uww.edu/php/showrp.php. Attached is the source code for the showrp.php. What is likely causing the failure of the "Title/Subject/Issue:" search option. Probably real basic but im nto great with the maths aspect of php, how would i get the $level + noto to show from the php below as currently i get, From: System 4 minutes ago You have reached level 1 + 1 in Notoriety, Please check the Skill Points section to see if you now qualify for any upgrades! $sql="INSERT INTO messages (to_username,from_username,message,type, timestamp) VALUES('$playerdata[username]','System','You have reached level $level + 1 in Notoriety, Please check the Skill Points section to see if you now qualify for any upgrades!','Player', NOW())"; mysql_query($sql) or die(mysql_error()); Hey guys, I am adding to my current php form processor and I need it to be able to support image uploads, that also show up as an attachment in the email with the rest of the form data. The only part I am having problems with is getting the image to work as an attachment in the email, at the moment, it is not showing up at all in the email but it is successful at showing up on the web server (which I have it doing for storage reasons). I have attached the code involved for the image processing portion, an also a snippet of code showing how the emails are sent. This code is for the image attachment processing <?php //Get the uploaded file information $name_of_uploaded_file = basename($_FILES['uploaded_file']['name']); //Get the file extension of the file $type_of_uploaded_file = substr($name_of_uploaded_file, strrpos($name_of_uploaded_file, '.') + 1); $size_of_uploaded_file = $_FILES["uploaded_file"]["size"]/1024;//size in KBs //Settings $max_allowed_file_size = 150; // size in KB $allowed_extensions = array("jpg", "jpeg", "gif", "bmp", "png"); //Validations if($size_of_uploaded_file > $max_allowed_file_size ) { $errors .= "\n File size too large! Max file size alowed is $max_allowed_file_size"; } //------ Validate the file extension ----- $allowed_ext = false; for($i=0; $i<sizeof($allowed_extensions); $i++) { if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0) { $allowed_ext = true; } } if(!$allowed_ext) { $errors .= "\n The uploaded file is not supported file type. ". " Only the following file types are supported: ".implode(',',$allowed_extensions); } //Copy the temp. uploaded file to server $path_of_uploaded_file = $upload_folder . $name_of_uploaded_file; $tmp_path = $_FILES["uploaded_file"]["tmp_name"]; if(is_uploaded_file($tmp_path)) { if(!copy($tmp_path,$path_of_uploaded_file)) { $errors .= '\n Error while copying the uploaded file'; } } ?> This is the header setup for sending the email, which for some reason I think i am missing something here, causing the image to not show up in the email. Code: [Select] $headers = "From: edited_out_for_this_post@edited_out_for_this_post.com\r\n"; $headers .= "Reply-To: no-reply@edited_out_for_this_post.com\r\n"; $headers .= "Return-Path: no-reply@edited_out_for_this_post.com\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; Thanks for your help in advance! I have a running total that I am pulling from a database that I need to sort by year. I have tried adding WHERE YEAR(datepicker) = '2015' but keep getting an error. Here is the original query that works fine when I run it. Just don't need all the records.
SELECT id, datepicker, startmiles, endmiles, O.totalMiles, car, section, (select sum(totalMiles) FROM vehicle WHERE id <= O.id) 'runningTotal' FROM vehicle O ORDER BY datepicker DESC im joining a table onto the query to show how many likes a post has but it is displaying the post x amount of times depending on how many likes there are. I think its something to do with the way im joining onto the pid of the post table: $post_query = $link->query("SELECT p.*, u.*, l.* FROM ".TBL_PREFIX."posts as p JOIN ".TBL_PREFIX."users as u ON (u.u_username = p.p_poster) LEFT JOIN ".TBL_PREFIX."post_likes as l ON (l.l_pid = p.p_pid) WHERE p_tid = '$tid' ORDER BY p.p_time_posted ASC")or die(print_link_error()); $likes = array(); while($post_info = $post_query->fetch()) { // SOF LIKE LIST if (count($post_info['l_pid']) >= 1) { $likes[] = $post_info['l_username']; $amount_likes = count($likes); $slice = array_slice($likes, 0, 4, true); $remain = array_slice($likes, 4, $amount_likes, true); $remain_num = count($remain); $like_list = ''; if($amount_likes > 4) { for($i=0; $i<=3; $i++) { $like_list .= profile_link($likes[$i]).', '; } $like_list .= 'and '.$remain_num.' other like this'; } elseif($amount_likes <= 3) { for($i=0; $i<3; $i++) { $like_list .= profile_link($likes[$i]).' '; } $like_list .= 'like this'; } } the likes are stored in their own database table seperate from the posts any advice? Having some odd issues with a simple query :S. The first problem is that i have selected all records but it miss's out records in a pattern (the first, fifth, ninth and so on). The second issue is i am trying to select by ascending order but it's just not doing it. The QUERY Code: [Select] $comments = "SELECT * FROM $commentsTable LIMIT $start, $per_page "; $commentResults = mysql_query($comments); $commentRows = mysql_fetch_array($commentResults); The while loop displaying the records Code: [Select] <?php while($commentRows = mysql_fetch_array($commentResults)){?> <div id="comments"> <div id="CommentWrapper"> <div id="comment"> <div id="UserName"><? echo $commentRows['id']." "; ?><? echo $commentRows['name'];?></div> <div id="UserComment"><? echo $commentRows['comment'];?></div> <div id="UserEmail"><a href="<? echo $commentRows['email'];?>"><? echo $commentRows['email'];?></a></div> <div id="PostDateTime"><i>Posted: </i><? echo $commentRows['datatime'];?></div> </div> </div> </div> <?php } mysql_close(); ?> http://dvplus.webuda.com/oophptest/database.query.php <<< the project Hello everybody. I have a query-question... I have a form that writes data into the database. BUT... I want to verify that data if it allready exists. There are 3 fields that needs to be checked: 1. Type; <- if yes, check 2. 2. Coordinates1 (+ or - 2 from existing record) <- if yes check 3. If no: insert record and echo: "Mine posted succesfully in the database!" 3. Coordinates2 (+ or - 2 from existing record) <- if yes echo: "There is allready a mine of this type in the database on that location!". If no: insert record and echo: "Mine posted succesfully in the database!" (One coordinate uses this format: xxxxxx,yyy (Where xxxxxx is coordinates1 and yyy is coordinates2). A comparison for 1 variable I can find, but not for three and also not how to incorporate the + or - 2. Any help is greatly appreciated. Christiaan code I have so far: Code: [Select] <? include 'mining_cfg.php'; // html collect variable $type = $_POST['type']; $level = $_POST['level']; $coordinates1 = $_POST['coordinates1']; $coordinates2 = $_POST['coordinates2']; if ($type == ".$type") AND if ($coordinates1 == ".$coordinates1") AND if ($coordinates2 == ".$coordinates2"){ echo "Mine posted succesfully!"; } else { echo "There is allready a mine of this type in the database on that location!"; } // sql insert into database $sql ="INSERT INTO mining(type, level, coordinates1, coordinates2) VALUES ('".$type."', '".$level."', '".$coordinates1."', '".$coordinates2."')"; //uitvoeren van de query : if (!($temp = mysql_query($sql,$connection))) showerror(); header ( "Location: http://swr.infiniteserve.com/swr-site/test/post_mining.php" ); ?> <form method="post" > <fieldset> <table> <tr> <td>naam van het gerecht:</td> <td><input type="text" name="nieuwgerecht" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 1:<input type="text" name="ingredient1" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 2:<input type="text" name="ingredient2" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 3:<input type="text" name="ingredient3" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 4:<input type="text" name="ingredient4" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 5:<input type="text" name="ingredient5" /></td> </tr> </table> <input type="submit" name="cmdvoegtoe" value="voeg toe" /> </fieldset> </form> <?php if(isset($_POST['cmdvoegtoe'])) { if (empty($_POST['ingredient1'])) { echo "<script>alert(\"ingredient nummer 1 moet zeker ingevuld zijn!\");</script>"; } else { $query="INSERT INTO tblgerecht VALUES(NULL, '$_POST[nieuwgerecht]')"; mysql_query($query, $connectie) or die('Error, insert query failed'); } } ?> Parse error: parse error in ... on line 118 problem with mysql query can someone help me with it Hi Im just working on a wordpress pugin at the moment and Iw as trying out this piece of code $mylink = $wpdb->get_row("SELECT * FROM $wpdb->testtable WHERE id = 1"); echo $mylink->id ; there is data in the table there is an id equal to one but it not coming up with anything I tried it with anouther pable and it works fine I can for example $mylink = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE id = 1"); echo $mylink->post_content ; That comes up fine with the data But the first one I dont know why its not working can anyone help Thanks James Hi all, Could someone have a look at the stuff below. I am able to show the $_POST variables, but from the moment i use mysqli_real_escape_string it goes wrong ( as in the variable seems empty) // mysqli connection file is above here // $clean_name = mysqli_real_escape_string(trim($_POST['name'])); $clean_email = mysqli_real_escape_string(trim($_POST['email'])); echo 'clean_name = '.$clean_name; //outputs noting echo 'clean_email = '.$clean_email; //outputs noting $query_control = "SELECT email FROM my_table WHERE email = $clean_email"; $result = mysqli_query($dbc, $query_control)or die(mysqli_error($con)); // <------- spotted: should have been $dbc //check for duplicates $number = mysqli_num_rows($result); echo $number; if($number === 0){ $output = 'valid'; }else{ $errormessage .= 'duplicate entry'; } } any help would be welcome edit- Oh i spotted some stuff (after changing it becamce: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1) But not able to fix it really. Im just trying to get this query to retrieve one peice of data about a user if they are logged in however instead of producing any sort of mysql errors or anything it just stops the page from loading properly. Can anyone help solve this? here is my query code: $query = "SELECT credits FROM users WHERE username = $session->username"; $res = mysql_query($query) or die (mysql_error()); $row = mysql_fetch_assoc($res); $ans = $res['credits']; When I use this query $sql1="select * from fagudtryk_muskler where latinsk like \"$trimmed%\" order by latinsk UNION ALL select * from fagudtryk_knogler where latinsk like \"$trimmed%\" order by latinsk"; //-run the query against the mysql query function $result=mysql_query($sql1); //-count results $numrows=mysql_num_rows($result); I get this error Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given How can I fix this? All other pages on my browser (Google Chrome) work, but whenever I open up register.php, I get this: Code: [Select] Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error. My register.php code: <?php include_once('includes/config.php'); include_once('functions.php'); $return_content = AccountRelated(null, null, 3); ?> <html> <head> <link rel="stylesheet" type="text/css" href="style/style.css" /> <title><?php echo $title; ?></title> </head> <body> <div class="logo"><a href="index.php"><img src="style/images/logo.png"></a></div> <center> <div class="background"> <div class="container"> <?php echo $return_content; ?> </div> </div> </center> </body> </html> functions.php <?php function AccountRelated($username, $password, $query_type) { if($query_type == 1) { $set_query = mysql_query("SELECT COUNT(d.username), u.date, u.username FROM uploads d, users u WHERE d.username = '$username' AND u.username = '$username' LIMIT 1") or die(mysql_error()); if(mysql_num_rows($set_query) == 0) { $content_return = 'Sorry, no information was found'; } else { $grab = mysql_fetch_assoc($set_query); //login information if($grab['COUNT(d.username)'] > 0) { $welcome_return = "You have uploaded ". $grab['COUNT(d.username)'] ." files. You've registered on ". $grab['u.date'] ."!"; } else { $welcome_return = "You have uploaded 0 files. You've registered on ".$grab['date'] . "!"; } } } elseif($query_type == 2) { $set_query = mysql_query("SELECT title,views,downloads,description,username,date FROM uploads LIMIT 20"); if(mysql_num_rows($set_query) == 0) { $content_return = "Sorry, there are currently no files uploaded to view."; } else { while($row = mysql_fetch_assoc($set_query) == 0) { echo $row['title']."<br/>"; } } } elseif($query_type == 3) { $username = mysql_real_escape_string($_POST['username']); $password = md5($_POST['password']); if(!$username || !$password) { $return_content = "All fields are required! <table><form action='register.php' method='POST'> <tr><td>Username</td><td><input type='text' name='username' maxlength='20'></td></tr> <tr><td>Password</td><td><input type='text' name='password' maxlength='30'</td></tr> <tr><td><input type='submit' value='Register'></td></tr> </form></table>"; AccountRelated($_POST['username'], $_POST['password'], 3); } else { $set_query = mysql_query("SELECT username FROM users WHERE username = '$username' LIMIT 1"); if(mysql_num_rows($set_query) == 0) { $return_content = "You have successfully registered the account ". $username ." with the password ". $password ."!"; } else { $return_content = "An account with this username already exists."; } } return $return_content; } else { //nothing to process } } ?> What I am trying to do is query a database using a loop conditional and return the data but my code only repeats the first instance multiple times! My code is below, I have tried to use comments to explain what should be happeing! $rows = null; $q1 = "SELECT * FROM table"; $r1 = mysql_query($q1) or die(mysql_error()); $i = 1; while($i <= 5){ $start = (1000 * $i); $end = ($start + 1000); while($a1 = mysql_fetch_array($r1, MYSQL_ASSOC)){ /* query the database where 'start' is >= 1000 and where 'end' is <= 2000, this should loop so the next time is where 'start' >= 1000 * $i should be 1000 then 2000, 3000 etc... and where 'end' should be 2000, 3000, 4000 etc... */ if($a1['start'] >= $start && $a1['end'] <= $end){ $rows .= $a1['col1'].':'.$a1['col2']."\n"; } } echo nl2br(trim($rows.'<p>')); $i++; } /* The problem is that it always shows multiple instances of the first result only where start = 1000 and end = 2000 */ Any help would be much appreciated!! How can I get this query to work? I am having problems with the HAVING section of it. Code: [Select] SELECT id,price, ( 6371 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM fuelstations HAVING distance < 250 , price > 0 ORDER BY price LIMIT 0 , 60; Hi, my site is displaying something weird, http://86.21.243.231/ on the table at the bottom, it should list the amount of tickets sold. if the user deposits 0.3, then it should display 3 seperate rows for 0.1 with their payout address. but for 0.3, it displays 2 rows of 0.15 instead. the code for the table is: Code: [Select] $sql="SELECT * FROM tickets WHERE `round` = '$round' AND `confirmed` = 'yes' ORDER BY timestamp ASC"; $result=mysql_query($sql); $row=mysql_fetch_array($result); $result=mysql_query($sql); while($row = mysql_fetch_array( $result )) { $ticketamount = $row['amount']; $ticketspurchased = (int)($ticketamount / $ticketprice); $ticketamount = $ticketamount / $ticketspurchased; for ( $counter = 1; $counter <= $ticketspurchased; $counter += 1) { $i++; echo "<tr><td>"; echo $i; echo "</td><td>"; echo $row['address']; echo "</td><td>"; echo $ticketamount; echo "</td><td>"; echo $row['confirmed']; echo "</td><td>"; echo $row['timestamp']; echo "</td></tr>"; } } 0.5 shows correctly Any ideas? Hi guys, Im just after a little help here because i cant seem to get my script to work correctly. Basically i have a table full of data and i want to be able to extract a months worth of data but split that data into weeks from within the month. This is my database structu Code: [Select] -- phpMyAdmin SQL Dump -- version 3.4.5 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Dec 13, 2011 at 09:13 AM -- Server version: 5.5.16 -- PHP Version: 5.3.8 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `time_man` -- -- -------------------------------------------------------- -- -- Table structure for table `clock_status` -- CREATE TABLE IF NOT EXISTS `clock_status` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` varchar(24) NOT NULL DEFAULT '0', `location` int(4) NOT NULL DEFAULT '0', `date_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `status` tinyint(1) NOT NULL DEFAULT '0', `amend_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `hours_worked` varchar(25) NOT NULL DEFAULT '', `lunch` int(11) NOT NULL DEFAULT '0', `break` int(11) NOT NULL DEFAULT '0', `sick` char(3) NOT NULL DEFAULT 'NO', `holiday` char(3) NOT NULL DEFAULT 'NO', `comments` text NOT NULL, `auth` tinyint(1) NOT NULL DEFAULT '0', `auth_date` date NOT NULL, `paid` tinyint(1) NOT NULL DEFAULT '0', `pay_rate` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=734 ; -- -- Dumping data for table `clock_status` -- INSERT INTO `clock_status` (`id`, `user_id`, `location`, `date_time`, `status`, `amend_time`, `hours_worked`, `lunch`, `break`, `sick`, `holiday`, `comments`, `auth`, `auth_date`, `paid`, `pay_rate`) VALUES (720, '653467435', 3301, '2011-10-12 04:00:00', 0, '2011-10-12 06:35:00', '9300', 0, 0, 'NO', 'NO', '', 1, '2011-10-13', 0, 'L'), (721, '653467435', 3301, '2011-10-12 06:30:00', 0, '2011-10-12 11:25:00', '17700', 0, 0, 'NO', 'NO', '', 1, '2011-10-13', 0, 'L'), (722, '5030341511007', 3301, '2011-10-13 17:45:00', 0, '2011-10-30 22:10:00', '15900', 0, 0, 'NO', 'NO', '', 1, '2011-10-13', 0, 'H'), (723, '653467435', 3301, '2011-10-13 01:15:00', 0, '2011-10-13 07:15:00', '21600', 0, 0, 'NO', 'NO', '', 1, '2011-10-13', 0, 'L'), (724, '653467435', 3301, '2011-10-13 03:15:00', 0, '2011-10-13 05:15:00', '7200', 0, 0, 'NO', 'NO', '', 1, '2011-10-13', 0, 'L'), (725, '653467435', 3301, '2011-11-11 05:45:00', 0, '2011-11-11 13:20:00', '27300', 0, 0, 'NO', 'NO', '', 1, '2011-11-11', 0, 'L'), (726, '653467435', 3301, '2011-11-11 01:15:00', 0, '2011-11-11 08:25:00', '3663', 0, 0, 'NO', 'NO', '', 1, '2011-11-22', 0, 'L'), (727, '12345678954565456', 3301, '2011-11-11 05:45:00', 0, '2011-11-11 16:25:00', '3662', 0, 0, 'NO', 'NO', '', 1, '2011-11-22', 0, 'L'), (728, '50226900', 3301, '2011-11-21 09:30:00', 0, '2011-11-21 17:00:00', '27000', 0, 0, 'NO', 'NO', '', 1, '2011-11-22', 0, 'H'), (729, '5030341511007', 3301, '2011-11-22 09:30:00', 0, '2011-11-11 15:30:00', '21600', 0, 0, 'NO', 'NO', '', 1, '2011-11-22', 0, 'H'), (730, '5030341511007', 3301, '2011-11-22 06:00:00', 0, '2011-11-17 09:20:00', '12000', 0, 0, 'NO', 'NO', '', 1, '2011-11-22', 0, 'H'), (731, '653467435', 3301, '2011-11-22 06:45:00', 0, '2011-11-22 12:30:00', '20700', 0, 0, 'NO', 'NO', '', 1, '0000-00-00', 0, 'L'), (732, '5030341511007', 3301, '2011-11-22 07:45:00', 0, '2011-11-22 15:15:00', '3661', 0, 0, 'NO', 'NO', '', 1, '0000-00-00', 0, 'H'), (733, '653467435', 3301, '2011-11-22 04:45:00', 0, '2011-11-22 14:05:00', '33600', 0, 0, 'NO', 'NO', '', 1, '0000-00-00', 0, 'L'); -- -------------------------------------------------------- -- -- Table structure for table `staff` -- CREATE TABLE IF NOT EXISTS `staff` ( `person_id` int(4) NOT NULL AUTO_INCREMENT, `name` varchar(60) NOT NULL DEFAULT '', `staff_number` varchar(20) NOT NULL DEFAULT '0', `dob` date NOT NULL DEFAULT '0000-00-00', `pay_rate` char(1) NOT NULL DEFAULT '', `date_amended` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `expiry` text NOT NULL, PRIMARY KEY (`person_id`), UNIQUE KEY `staff_number` (`staff_number`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=53 ; -- -- Dumping data for table `staff` -- INSERT INTO `staff` (`person_id`, `name`, `staff_number`, `dob`, `pay_rate`, `date_amended`, `expiry`) VALUES (16, 'Person Two', '3456', '1990-06-23', 'H', '2011-06-23 07:40:38', ''), (17, 'Person Three', '5678', '1986-05-29', 'H', '2011-01-24 12:18:03', ''), (15, 'Person One', '1234', '1995-11-29', 'L', '2011-01-18 16:59:53', ''), (47, 'Person four', '50226900', '1980-04-23', 'H', '2011-06-17 10:50:50', ''), (48, 'Person Two', '653467435', '1980-01-13', 'L', '0000-00-00 00:00:00', '01/02/1982'), (50, 'Person One', '5030341511007', '1983-07-13', 'H', '0000-00-00 00:00:00', ''), (52, 'Person Three', '12345678954565456', '2000-02-01', 'L', '0000-00-00 00:00:00', '01/03/2019'); -- -------------------------------------------------------- /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; This is the script so far... Code: [Select] <?php require_once("../includes/connection.php"); ?> <?php $date1 = '2011-10-28'; $date2 = '2011-11-27'; $ident = '3301'; $sql10 = "SELECT WEEK(date_time) as Week, staff.name, clock_status.user_id, sum( clock_status.hours_worked ) AS sum_hours, clock_status.hours_worked, clock_status.amend_time FROM clock_status, staff WHERE amend_time >= '$date1' AND amend_time < '$date2' AND clock_status.auth =1 AND clock_status.user_id = staff.staff_number AND clock_status.location = '3301' GROUP BY user_id ORDER BY Week, user_id"; $query10 = mysql_query($sql10) or die(mysql_error()); ?> <table style="border: 1 solid black;"> <tr> <th>Staff No</th> <th>Name</th> <th>Sum hours</th> <th>Week 1</th> <th>Week 2</th> <th>Week 3</th> <th>Week 4</th> <th>Week 5</th> </tr> <?php while ($row = mysql_fetch_assoc($query10)) { ?> <tr> <td><?php echo $row['user_id'] ;?></td> <td><?php echo $row['name'] ;?></td> <td><?php echo $row['sum_hours'] ;?></td> <td>Week 1 hours here</td> <td>Week 2 hours here</td> <td>Week 3 hours here</td> <td>Week 4 hours here</td> <td>Week 5 hours here</td> </tr> <?php } ?> </table> <?php require("../includes/footer.php"); ?>The table should list each person once, with the total hours, then the amount of hours in each week in a different column. As represented in my table. If someone could help me on this issue i would be eternally grateful... thanks in advance. |