Jump to content

murfitUK

Members
  • Content Count

    207
  • Joined

  • Last visited

Everything posted by murfitUK

  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 prob
  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
  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.
  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
  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 T
  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, 2
  8. This related to MYSQL (not SQL).I have a table with a field called HBRef. This value can be null but if a value is entered it must be unique. In mysqladmin I have set the field's default value to null and the attribute to unique. Now I cannot enter a new record with HBRef as null because such a value already exists.How do I set it up so that the field HBRef has a unique value unless it is null?Thanks.
  9. It's been a while since I've used jquery but I think you do something like this:$("#date").datepicker( "option", "yearRange", '1950:2011' );
  10. Thanks Deirdre's Dad. I am updating my php as we speak - I was still on some old version. The new function certainly goes some way to simplifying things.
  11. Yes, I suppose I am just venting but my point remains: working with dates in php is not as straightforward as it should be.justsomeguy's 4 lines of code does exactly what is required and is the way I've been doing it for ages but... its still 4 lines of code just to work out next week's date.
  12. I know I can put it all into a function - ready to call up whenever its needed. But why can't it be simpler? Look at mysql. If I type this inSELECT DATE_ADD('2011-08-23', INTERVAL 7 DAY);it gives the answer. Surely php should be able to do the same just as easily? Working with dates must be a really common task when using php but it isn't really as easy as it should be.I think I am getting more impatient in my old age!
  13. I have a string with a date: $date="2011-08-23". All I want to do is add seven days to this to get "2011-08-30".There must be an easy way to do this with php. I'm fed up messing around with mktime and strtotime and exploding strings and all the rest. Please help otherwise it won't just be the string that explodes!
  14. murfitUK

    Array problem

    Sounds as though that could be the solution but not sure were I start the iteration? Do I put the for loop inside the while statement or the other way round? I've just got myself so confused with this that I can't think straight now!
  15. murfitUK

    Array problem

    Maybe there is a way to do this that is so easy I can't see it!Have a database with a table of staff schedules. The table has an ID field, a field to identify the user, a date field and a text field. Each user obviously has a unique ID. If I want to see what William's schedule (user number 12) is for April 2011 I run the querySELECT * FROM `schedule` WHERE `user`=12 AND `date` LIKE '2011-04-%' ORDER BY `date`;Then I can do the usual while ($row = mysql_fetch_array($result)){print substr($row['date'],8,2) . " - " . $row['note'] . "<br />";}which will give me something like04 - Annual L
  16. murfitUK

    Array Problem

    The problem is that I don't know what info will be returned. Some staff might not have any sick leave (type S) or unpaid leave (type U) so I can't rely on $data[0] always containing type S info. If he hasn't had any sick leave then $data[0] might contain type F (flexi leave) info.Is there any way of taking the mysql result and turning it into an array with `type` as the keys. If that is possible then I might be able to get the info that way.
  17. murfitUK

    Array Problem

    Thanks. I thought there might be a quicker way of doing it - like print $data[F][A][tot]; to give me 1.0 - but doesn't seem to be possible.
  18. murfitUK

    Array Problem

    I'm having difficulty working out how to solve this problem. I run a mysql query // find other types of leave in period (flexi, sick, paid, unpaid) $slq = "SELECT `type`, `status`, SUM(`len`)/2 AS `tot` FROM `lvd` WHERE `user`={$_SESSION['userid']} AND `period`={$row['id']} GROUP BY `type`, `status`;"; if (!($connection = @ mysql_connect($hostname, $dbuser, $dbpass))) die("Cannot connect"); if (!(mysql_select_db($dbname, $connection))) showerror(); if (!($slr = mysql_query($slq, $connection))) showerror(); while ($data[] = mysql_fetch_array($slr,MYSQL_ASSOC)) {} and printing $data with <
  19. Removed the name from the form, gave the select an id and a name and now it works fine. Thanks.
  20. OK, thanks for that. I have changed the select to<select id='choice'>and changed the validation script toif (document.getElementById('choice').value=='d')but it has stopped working.Can someone please let me know how to do it the correct way. Do I still have to give the form a name, I've tried but it doesn't work either.
  21. Here's what I've come up with and it seems to work with the limited testing I have done. I added a name and an onsubmit to the form (in capitals below) and then the validate script returns true (as default) unless the delete option has been submitted - in which case it return the result of the confirm box. <form action='claimsactions.php' method='post' NAME='EXPENSES' ONSUBMIT='RETURN VALIDATE_EXPENSES();'>...this bit generates the list of claims with checkboxes...<p>Apply the following action to the claims I have ticked...</p><select name='action'><option value='0
  22. Sorry, but I really can't get the hang of javascript. I've tried. Anyway....I know how to generate an alert box confirming if the user wants to delete something using this sort of line:print "<a href=/"noticedel.php?notice=$row['id']}\" onclick=\"return confirm('Are you sure you want to delete this Notice?')\">delete</a>";What I am trying to do now is to confirm deletion of items when the delete option is part of a drop-down select list. The page produces a list of a users expenses claims with a checkbox next to each one, then they choose which option to apply to the ones they h
  23. Would it not be easier to add a couple of lines to your upload script so that it checks for any file in the folder that is older than 4 hours? This way user A can upload several files in a short period of time but none will be deleted. Here's what I use: // delete any file in this directory that is more than 4 hours old$dir = "./users";if ($d = @opendir($dir)){while (($file = readdir($d)) !== false){$ftime = filemtime($dir.'/'.$file);if (time()-$ftime > 14400) {unlink($dir.'/'.$file);}}closedir($d);} This will only run after an upload so a file could stay on the server for weeks if no o
  24. I've solved it! Deirdre's Dad hadif (mycheckboxes[x].type.toLowerCase() = "checkbox")whereas it should be a double equal sign ==Thanks everyone.
  25. Thanks Deirdre's Dad. How do I set up the loop now though. I take it I still need to find the number (the equivalent of var i in my previously posted code). Would it be something like var i = mycheckboxes.length - tried that but it doesn't work. And once I've got that does the loop still start at 0, or is the first element called 1?Also, in your first line should it be document.GetElementById
×
×
  • Create New...