Jump to content

murfitUK

Members
  • Posts

    207
  • Joined

  • Last visited

1 Follower

Recent Profile Visitors

3,328 profile views

murfitUK's Achievements

Member

Member (2/7)

0

Reputation

  1. My brain has gone to sleep and I cannot work out how to write this simple query! Note, this is for mysql. I have a table called `calls` which is used to collect telephone call information. Some of the fields are: `id` `client_id` `date` There are others such as what the call was about, but that's not important right now. I can get the total number of phone calls received during a specified period with the query: SELECT COUNT(*) AS `total` FROM `calls` WHERE `date` BETWEEN '{$rsd}' AND '{$red}' [rsd and red are report start date and report end date] So far, so good. My problem is that I now need to find out how many clients made 1 phone call, how many made 2 calls, how many made 3 calls, etc. I do not need to know which clients called 3 times - just the total number of clients. The output of the query will be displayed something like: 241 clients called 1 time(s) 187 clients called 2 time(s) 45 clients called 3 time(s) 38 clients called 4 time(s) ... etc I've tried many combinations of count, distinct, group by etc but only succeed in getting myself even more confused. I know there is an easy way to do this but I can't find it! If anyone can help I would be very thankful.
  2. Mudsaf is correct that your website host has probably disabled this function. If you can call a script on one of your websites from a different website then it means others can do so to - and you don't want that to happen. You should google for cURL and look at some of the tutorials available. You might be able to do it that way instead, although some hosts disable this as well.
  3. murfitUK

    2 function or 1?

    Will your users know if they are regular or business users before they fill the form in? What if they fill in a business form and then find out they should have filled in the regular form (or the other way round)? To make it easier for your users - and for you - why not have just one form. Some fields will always have to be filled in (name, email etc) and some will be optional and these can all be on the same form. One of the things I have learned since taking up programming and web design is that the best way of starting a project is to get a pen and paper and write down EXACTLY what it is you want to achieve and then the steps you can take to reach it. So the first question you should ask (based on your post) if... why do I need two different forms? If you have no good answer than stick to one.
  4. I'm so glad it turned out to be a php problem and not that I'd forgotten everything I had ever learned! I didn't realise that sin and cos needed radians and not degrees. Interestingly, my apache server returns PI as 0. I have to use M_PI. Don't know why. The succesful result is attached as graph2. The eventual aim is for my users to be able to generate a chart like that attached as example. At the moment they use excel but want the data stored on their client database instead. I have already got the database set up for them to enter the data and now concentrating on creating the results. Thanks everyone. graph2.pdf example.pdf
  5. murfitUK

    Mathematical help

    I am attempting to use php and a pdf creator to generate a chart. It is the mathematical bits I need help with. Basically, the chart has 7 lines (spokes) radiating at equal angles from the centre. <?php// create the pdfinclude ("class.ezpdf.php");$pdf =& new Cezpdf();$pdf -> selectFont("./fonts/Helvetica.afm"); // these value determine the position and size of the graph// (0,0 is the bottom left hand corner of the page)// x1 is the x centre of the graph$x1 = 200;// y1 is the y centre of the graph$y1 = 200;// s is the scalar$s = 100; // create the skeleton of the graphfor ($spoke=1; $spoke<=7; $spoke++) { $angle = ($spoke-1) * (360/7); $x2 = (sin($angle) * $s) + $x1; $y2 = (cos($angle) * $s) + $y1; // draw a line from (x1,y1) to (x2,y2) $pdf -> line($x1, $y1, $x2, $y2); } // output the result$pdf -> ezStream();?> The first spoke works OK but it all goes downhill from there. I have attached the pdf output so you can see what I mean. What makes this worse is that my university degree is in mathematics!!! But it was 30 years ago and I've forgotten everything I ever learned. graph.pdf
  6. After much hair-pulling and gritting of teeth I have finally solved my problem. I realised I wasn't counting sessions properly. I had COUNT(`item`.`desc`) instead of COUNT(*) which was giving incorrect results. The query I've produced is: SELECTCONCAT(`children`.`lastname`, ', ', `children`.`firstname`) AS `Name`,IFNULL(`item`.`desc`, 'Total--->') AS `Activity`,COUNT(*) AS `Sessions`,SUM(`item`.`hours`) AS `Total`FROM`record`, `children`, `item`WHERE`record`.`child_id`=`children`.`id`AND`item`.`record_id`=`record`.`id`AND`record`.`end`='0000-00-00'GROUP BY`Name`,`item`.`desc`WITH ROLLUP This give me the results I expected. However I've just realised that if two children have the exact same name then it will group them both together - the totals will still be correct but it won't differentiate between the two. I will have to include the child id and then use that to group instead of name but that will throw up its own problem because we can't use order by with groupings. So I think it would be easier to ensure we never have two children with the same name!
  7. I need some help setting up a query. There are three tables and the relevant fields are shown below: CHILDREN (id, firstname, lastname)RECORD (id, child_id, startdate, enddate) [enddate will be 0000-00-00 if not yet ended]ITEM (id, record_id, date, desc, hours) Children table might show something like17, Peter, Brown22, Sammy, Watkins Whenever a child is accepted into our service we create a record with the start date and eventually an end date when they leave. The record table will also show their support worker and other info but that's not important right now. Record table might show:6, 22, 2012-02-10, 0000-00-00 [shows Sammy's record starting 10th Feb and still ongoing as no end date]9, 17, 2012-03-25, 0000-00-00 [shows Peter starting on 25th March] Whenever a child undertakes an activity it is entered in the item table.Item table might show1, 9, 2012-03-26, Chess Club, 4.00 [Peter attended chess club for 4 hours]2, 9, 2012-03-28, Theatre Group, 2.00 [Peter - theatre group for 2 hours]3, 9, 2012-04-10, Chess Club, 3.50 [Peter - chess club for 3.5 hours]4, 6, 2012-03-28, Theatre Group, 2.00 [sammy - theatre group for 2 hours]5, 6, 2012-04-05, Music Therapy, 1.50 [sammy - music therapy or 1.5 hours]6, 9, 2012-04-17, Chess Club, 4.00 [Peter - chess club for 4 hours]7, 6, 2012-04-14, Theatre Group, 2.50 [sammy - theatre group for 2.5 hours]8, 6, 2012-04-20, Music Therapy, 1.00 [sammy - music therapy for 1 hour]and so on. Now, I need a list of all activites undertaken by each child with an open record (that is - no end date). My basic query isSELECTCONCAT(`children`.`lastname`, ' ', `children`.`firstname`) AS `name`,`item`.`desc` AS `activity`,`item`.`hours` AS `time`FROM`children`, `record`, `item`WHERE`record`.`child_id`=`children`.`id`AND`item`.`record_id`=`record`.`id`AND`record`.`end`='0000-00-00'ORDER BY `children`.`lastname`, `children`.`firstname` This gives something like:Brown Peter, Chess Club, 4.00Brown Peter, Theatre Group, 2.00Brown Peter, Chess Club, 3.50Brown Peter, Chess Club, 4.00Watkins Sammy, Theatre Group, 2.00Watkins Sammy, Music Therapy, 1.50Watkins Sammy, Theatre Group, 2.50Watkins Sammy, Music Therapy, 1.00 This will do... but I would like to group each child's activities together to count the number of sessions and then the total hours for each activity. So the results will be:Brown Peter, Chess Club, 3, 11.50 [ie he has had three sessions in the chess club totalling 11.5 hours]Brown Peter, Theatre Group, 1, 2.00 [1 session totalling 2 hours etc]Watkins Sammy, Theatre Group, 2, 4.50Watkins Sammy, Music Therapy, 2, 2.50 I'm getting confused with counts, sums and group by statements and would appreciate your help. Ideally I would also like to include some sort of roll up so that I can get Peter showing a total of 4 sessions totalling 13.5 hours and Sammy showing 4 sessions totalling 7 hours but this is not important if it is going to be too difficult.Thanks for your help.
  8. Try this:body { background-image: url('http://img155.imageshack.us/img155/7028/bebop2rc6.jpg'); background-repeat: no-repeat; background-position: bottom right; }
  9. Yes, just put this in your CSS. This example shows how can have different styles for the different input types (text, select, button).input.textual { background-color: #e6ac73; color: #406480; border: 1px solid #ffffff; padding: 3px; font-size: 100%; font-weight: bold; }select.dropdown { background-color: #e6ac73; color: #406480; border: 1px solid #ffffff; padding: 3px; font-size: 100%; font-weight: bold; }textarea { background-color: #e6ac73; color: #406480; border: 1px solid #ffffff; padding: 3px; font-size: 100%; font-weight: bold; }input.button { background-color: #e6ac73; color: #406480; padding: 3px; font-size: 100%; font-weight: bold; }input.check { background-color: #e6ac73; border: 1px solid #ffffff; padding: 3px; font-size: 100%; font-weight: bold; }Then your html will be something like:<input type="text" name="name" class="textual"> for a line of text<input type="checkbox" name="name" class="check"> for a checkbox<input type="submit" name="name" class="button"> for a button<textarea name="name">bbbb</textarea> (don't need to do a class because textarea is defined in the cssand for the drop down list:<select name="name" class="dropdown"> <option value="value">text bit here</option>..</select>You can leave out the class and just have one defined if you want all your inputs to look the same:input { background-color: # etc;}and then you only need your html<input type="text" name="name"> without having to declare the class.
  10. Ah. My local machine is still on 4.0.24, and I don't really want to go about changing things because it was so much trouble getting php, mysql and phpmyadmin all set up originally.The web host company that I use is on 4.1 and I've tried it online - the sub query works just fine.Thanks Vijay, at least I know where the problem lies now.
  11. murfitUK

    IE6 Bug

    I don't get the same problem when I try with IE6. Anyway, it sounds like it could be one of IE's known bugs. Go to the site below and have a look at the guillotine bug.http://www.positioniseverything.net/explorer.html
  12. Hi Vijay - thanks for the reply. Sorry, but I still can't get it to work.This works:SELECT DISTINCT(catID) FROM details; - gives value 1,3,4This works:SELECT kind FROM category WHERE id IN (1,3,4); - gives values Chairs, Clocks, LightingAnd this works:SELECT kind FROM category WHERE id NOT IN(1,3,4); - gives value BedsBut I just can't combine the two without getting an error 1064 - you have an error in your syntaxSELECT kind FROM category WHERE id IN (SELECT DISTINCT(catID) FROM details);What am I doing wrong? I've tried the ` round the field names but still an error. I'm using mySQL - is the above only valid for SQL?
  13. Two tables:1) called "category" with 3 fields: id, kind, description eg0, "Tables", "We have a wide range of tables..."1, "Chairs", "Our large selection of chairs..."etc2) called "details", has numerous fields including one called "type" which has the id from the category table as all products are slotted into a category (so each category could have a large number of products).Trying to do a query to find which categories are not currently used for any products in the details table, but failing miserably. For example, might have in "category":2, "Beds", "All our beds are made from the finest materials..." etcbut if there are no beds in the details table then its an unused category which is what I'm trying to find.I know this should be simple to do but....Please help!
  14. Thanks for the replies - I think the thumbnail page will be the best way forward.After some experimentation I found that if I do <a href="file:pics"> (or file://pics or something like that) it opens a window in IE but not FF. I'll investigate further when I get time!
  15. Hi everyone. I'm back from my holiday in Australia and have put my travel experiences on my website. (If you want to look: websiteI'm creating a disc to send to my mum who has a computer but no internet access (she can't be trusted) and I've made it autorun so she just needs to stick it in the CD drive. The first page will have two options 1) view the website which is saved on disc and 2) open the pics folder so she can browse the photographs.Here's the problem. If I put a link to the pics folder using <a href="pics/"> it opens the folder in the browser with a list of filenames. I really want it to open up the folder as though she had double-clicked her way from the My Computer icon.This is what I mean...I don't want thishttp://www.murfituk.com/pics/no.jpgThis is what I wanthttp://www.murfituk.com/pics/yes.jpgThe reason is that she can then double-click on the first icon and it will open with Microsoft picture viewer which has the next and previous buttons at the bottom, so she can work her way through.Can anyone tell me how to do this? I'm stuck.Thanks.
×
×
  • Create New...