
dweb
Members-
Posts
122 -
Joined
-
Last visited
Everything posted by dweb
-
Thanks for your suggestion, but I tried your QUERY and it only returned 2 of the users, not sure why? The reason there are two separate tables, is because they contain no real related data, apart from what I am trying to do here. I also think, maybe it adds a little bit extra security, rather than storing lots of data in one single table
-
at last, this seems to work, does it look correct? SELECT sp.member_id, st.stage, total_count FROM student_points sp LEFT JOIN (SELECT st.* FROM student_times st WHERE st.class = 'math' ORDER BY st.id DESC) AS st ON st.member_id = sp.member_id LEFT JOIN (SELECT sp1.*, SUM(sp1.total) AS total_count FROM student_points sp1 WHERE sp1.class = 'math' GROUP BY sp1.member_id ORDER BY sp1.id DESC) AS sp1 ON sp1.member_id = sp.member_id WHERE sp.class = 'math' GROUP BY sp.member_id
-
Hi Sorry if my example was not clear. My current data looks like INSERT INTO `student_points` (`id`, `member_id`, `class`, `total`) VALUES (16, 4, 'math', '111'), (25, 15, 'math', '44'), (42, 21, 'math', '22'), (43, 21, 'math', '1'), (45, 21, 'math', '2'), (46, 21, 'math', '1'); INSERT INTO `student_times` (`id`, `member_id`, `class`, `stage`) VALUES (16, 4, 'math', '23'), (25, 15, 'math', '34'), (42, 21, 'math', '56'), (43, 21, 'math', '67'), (45, 21, 'math', '22'), (46, 21, 'math', '5'); if I run the following query then the results are correct SELECT sp.member_id, SUM(sp.total) as total FROM student_points sp WHERE sp.class = 'math' GROUP BY sp.member_idand I get this member_id total 4 111 15 44 21 26so the above is correct all i want to do is add onto the results, the latest `stage` record that is stored in the `student_points` table so it would look like member_id total stage (from the `student_times` table) 4 111 23 (from ID 16) 15 44 34(from ID 25) 21 26 5(from ID 45)does that make more sense? thanks
-
Hi I have these 2 tables; student_points id member_id class stage 16 4 math 23 25 15 math 34 42 21 math 56 43 21 math 524 46 21 math 251 student_times id member_id class total 16 4 math 111 25 15 math 44 42 21 math 22 43 21 math 1 45 21 math 2 46 21 math 1 what i am trying to do, is get the following result member_id class total stage 4 math 111 23 15 math 44 34 21 math 26 251 I have this query SELECT st.member_id, sp.member_id, SUM(sp.total) as total, st.stage FROM student_points sp LEFT JOIN student_times st ON st.member_id = sp.member_id AND st.class = 'math' WHERE sp.class = 'math' AND st.stage != 0 GROUP BY st.member_id ORDER BY st.stage, sp.total DESC but it returns member_id class total stage 4 math 111 23 15 math 44 34 21 math 104 251 the value for `total` should be 26, not 104 why would it return 104? thanks
-
thank you very much, i'll check that out :-)
-
is it possible? or what other information do you need? thanks
-
Thanks What I mean is; If the user wanted 3 spaces and * "Maths" had 3 slots * "Science" had 4 slots * They both had the same difficulty level Then it would select just 1 course, rather than taking 1 slot from Maths and 2 from Science. Does that explain it?
-
hi all wonder if someone can help me i have a table called "course_selection" id course spaces difficulty 1 IT 4 220.10 2 Maths 3 154.43 3 Science 1 154.43 4 Dance 9 50.01 I have a var which defines how many spaces are needed $spaces_needed = 2; so i want to run a query which 1: returns the courses available that can accomodate the spaces needed, but spreading the spaces over the least number of courses 2: returns the rows in an order with the least difficult first My table and var example, it would return id course spaces spaces_now spaces_used difficulty 4 Dance 9 7 2 50.01 because i need to spread results over the least number of courses, if the var was $spaces_needed = 11; then it would return id course spaces spaces_now spaces_used difficulty 4 Dance 9 0 9 50.01 2 Maths 3 1 2 154.43 if the var was $spaces_needed = 10; then it would return id course spaces spaces_now spaces_used difficulty 4 Dance 9 0 9 50.01 3 Science 1 0 1 154.43 if the var was $spaces_needed = 12; then it would return id course spaces spaces_now spaces_used difficulty 4 Dance 9 0 9 50.01 3 Science 1 0 1 154.43 2 Maths 3 1 2 154.43 any help would be great thanks
-
Thanks for the tip, any suggestion on who should supply the SSL? Any ideas on others things mentioned?
-
hi i have a limited php5 hosting plan and i want to create a secure login script which just displays a user id on the screen when they login. so its as simple as 1: login 2: user id displayed the user id is really important that its kept secret and no one can hack in and find out anothers user id i am stuck on the best way to make a secure login script ive looked around and seen injection examples such as Session Hijacking SQL Injections Cross Site Scripting Network Eavesdropping Brute Force Attacks but i wonder what the best way is to cover all the above bases and anything that i might not have listed i dont expect a script, all im looking for is some help on extra things i can do to secure and protect to the max also, i wonder if you have any suggestions on the best way to secure my database and protect anyone from getting access and changing details is it a good idea to store the user id on another server? to help extra protection? thankyou
-
Hi all Wondering if anyone can tell me why the following doesn't work; function img_checker() { $('#img1').load(function() { alert('loaded ok') }) } setInterval(function() { img_checker(); }, 500); I basically want javascript to check every X number of seconds to see if an image has been fully loaded any ideas?
-
thanks, but I dont want to output the <br /> tag, I just want line breaks excluding the tag
-
hi i wonder if someone can help i have some code to make a simple XML output <?php header('Content-type: text/xml'); header('Pragma: public'); header('Cache-control: private'); header('Expires: -1'); echo "<?xml version=\"1.0\" encoding=\"utf-8\"?> <xml> <customers> <id>song_path</id> <name>David</name> <promos> D123OO M876TT B765DC LO122M </promos> </customers> </xml>"; ?> my problem is; when the XML is displayed in the browser, it forces the values in <promos> onto 1 line <promos>D123OO M876TT B765DC LO122M</promos> is it possible to keep the formatting, so it outputs <promos> D123OO M876TT B765DC LO122M </promos> i have tried lots of different things but nothing seems to work \r\n \n\r \n \r <br /> <p> the only option which came close was <br />, but the XML actually displays the <br /> tag can anyone help? thank you
-
hi i am running this php image resize and crop script function img_process($max_width, $max_height, $source_file, $dst_dir) { $imgssize = getimagesize($source_file); $width = $imgssize[0]; $height = $imgssize[1]; $mime = $imgssize['mime']; $dst_imgs = imagecreatetruecolor($max_width, $max_height); $src_imgs = imagecreatefromjpeg($source_file); $width_new = $height * $max_width / $max_height; $height_new = $width * $max_height / $max_width; if($width_new > $width) { $h_point = (($height - $height_new) / 2); imagecopyresampled($dst_imgs, $src_imgs, 0, 0, 0, $h_point, $max_width, $max_height, $width, $height_new); } else { $w_point = (($width - $width_new) / 2); imagecopyresampled($dst_imgs, $src_imgs, 0, 0, $w_point, 0, $max_width, $max_height, $width_new, $height); } imagejpeg($dst_imgs, $dst_dir, 100); if($dst_imgs)imagedestroy($dst_imgs); if($src_imgs)imagedestroy($src_imgs); } can anyone tell me how to get it producing higher quality images? thanxs
-
Hi al I have the following code; <style> .mybox { margin-left:50px; margin-top:50px; position:relative } .myboxtitle { position:fixed; margin-top:-120px; margin-left:20px; background-color:#CCC; padding:20px } .mybox img:hover { opacity:0.1; } </style> <div class="mybox"><img src="file1.jpg" width="300" /><a><h1 class="myboxtitle">Image 001</h1></a></div> <div class="mybox"><img src="file2.jpg" width="300" /><a><h1 class="myboxtitle">Image 002</h1></a></div> which works well. the problem is when i hover over the div (myboxtitle) the image opacity is lost how can i retain the image opacity when hovering over the div (myboxtitle), but i don't want any opacity applied to the div, just the image can anyone help me? thanks
-
Hi I need to run a query that does a date range search. My dates are stored as the following format Fri Jan 05 2014 I know how to run a query when the dates are stored as YYYY-MM-DD but I cannot figure out how to run a query with the format my dates are stored in I can't change the format of the fields as it's part of a bigger system Does anyone have any suggestions?
-
worked a treat, thanks
-
Hi all I have a simple HTML form, but have around 250 radio buttons, which are all needed. All the radio buttons have different "name" attributes. How can I run a check to make sure at least one of the radio buttons has been selected? Is this possible without passing the "name" attribute? thanks
-
Hi all I have the following database table ID NAME 1 David 2 John 3 Vicky 4 Rob 5 Suzzie and I run the following Query SELECT * FROM `staff` ORDER BY `name` ASC LIMIT 4 Which is cool and works great I want to keep my Query as it is, but I want to sort the output by the ID So it keeps the ORDER BY `name` ASC but the actual sorting is by `id` ASC Can that be done? Thanx
-
Hi I've got a HTML page which I use some CSS and jQuery to produce a CSS style overlay lightbox effect The code can be seen > http://jsfiddle.net/DQaHK/1/ The problem I have is that when the browser window height is resized, the overlay starts to disappear into the top and bottom of the browser window, with no way to see the contents of it. How can I alter my code, so that when the height of browser window is less than the height of the overlay div, then scroll bars show, allowing you to scroll to the top and bottom of the overlay div. Thanks
-
Hi all I have the following value $var = 'hello|goodbye|morning|evening'; and i'm doing some str_replace to remove certain words, for example $var = str_replace('goodbye', '', $var); which is all cool, but it leaves me with $var = 'hello||morning|evening'; how can I tell PHP to strip multiple instances of ||, so it would look like $var = 'hello|morning|evening'; sometimes im left with a value such as $var = '|||evening'; so I need to strip multiple | symbols into just 1 thanks
-
nice one, that's pretty sweet. is there a way to make sure the value ends with a comma? and if not, add one on?