Jump to content

HarryMW

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Everything posted by HarryMW

  1. Hello, In short, i'm generating rows of records, and checkboxes with them that represent either 1 for ticked or 0 for not... The echo tickbox: <?php echo '<input name="abc_'.$row_ab['id'].'" value="1" type="checkbox" id="val" '; if($row_ab['ABC']>=1) echo 'checked="checked"'; echo ' />';?> The top code: <?php foreach ($_POST as $fieldname => $field) { if((substr($fieldname,0,4) == "abc_") == '1'){ $ABC = '1'; } else { $ABC = '0'; } ... if (substr($fieldname,0,4)=="abc_") mysql_query("UPDATE `table` SET `ABC` = '$ABC' WHERE `id`='".substr($fieldname,4)."' AND `ID` = '$ID'"); } ?> Now the problem is, obviously it will always set the value to 1; I dont quite know what to replace the substr with as it will always be bifferent depending on the id of the entry i'm not too sure how I change rectify that, any ideas?
  2. Evening! I've been iffing and ahhing over this and well im not too sure, hence the post. // Redirects if there is no session id selected and echos the error on the previous page if(!isset($_GET['get']) || ($_GET['getget'])){ header("Location: #.php?error"); } So it should simply check if get is set if it isnt then see if getget is set? If not redirect and show the error. Now ive tried it and even when get/getget is set it still redirects, probably something silly. Care to share anyone? Harry.
  3. Well I have a history page and basically it loops all of the results etc... then the id of the result is passed through to the next page with: And if I put the echo at the top (which I did in the begining to check) is echo's the id. I'm just stumped.
  4. Why exactly is the _get returning just nothing everytime? $seshid = $_GET['finish']; // Little things in here ... ///Add lesson plan if(isset($_POST['addinc'])){ if(!empty($_POST['inc'])){ $inc = addslashes($_POST['inc']); mysql_query("INSERT INTO `group_sessions_lplan` (`group_sessions_lplan_id`, `group_session_id`, `plan`) VALUES ('', '$seshid', '".strip_tags($inc, "<a><b><strong><u><i><span>")."')"); header("Location: ?id=".$seshid."#I"); exit(); } } Not too sure myself, anyone know how I can get it to show its actual value?
  5. I have tried wrapping the table, query and while loop in a big if statement however that doesn't seem to work.
  6. Hello, I have a simply query that will if a simple two different things: $cssyn = mysql_query("SELECT `12` FROM `12345` WHERE `abc` = '$_SESSION[number]'"); $cssy = mysql_fetch_row($cssyn); if($cssy[0] == "YES") { echo "Yes"; } else { echo "No"; } The YES or NO result is stipulated earlier on so thats not the problem. But basically before I added the if statement simply would have echoed a table with all the rows etc from another query. However I would like to give the user a choice between echoeing the results into one table or a neater two. I have separated the code for the table and the queries into two separate files but say if I use: file_get_contents then it just prints the HTML and doesnt actually populate it will the queried parts. Nor if I use something like include() then it wont echo anything, which it wouldnt unless called so what I am asking is: Is there a way to get EVERYTHING from the file if the answer is YES or the other file if NO.
  7. No news? Just to clarify. A typical database entry would be 1500. (3PM) A typical text field entry would 10 or even 00:10:00 (H:M:S) I would like to plus the text field entry onto the database entry. So it would become 1510. Harry.
  8. Little confuzzled. I have got a bunch of listings that will be printed at the end of the page but I need to subtract a time specified in a textbox (send it to itself) on the page. $row['active'] = (strtotime('$row[etd]') + $rwy1 = $_POST['tmatttextfield']); Well this just converts the time in the database which is always going to be a four character number such as: 1300 for 1PM into a time and adds the textbox value to the time. <td width="50" bgcolor="<?php echo $bc?>"><strong><?php echo date('hi', $row['active']);?></strong></td> That just prints it all out formatting the time to only Hours and Minutes. So just to clarify the user would put in say '10' in the textbox which would constitute 10 minutes. The code above should then define that '10' as 10 minutes. Define the database result, ie. 1500 as 3PM and add the 10 minutes to it so it would become 1510. I have been getting some wierd and wonderful results whilst trying to get it to work. Mainly just 1200 though. Harry.
  9. Well. Alright then. To make it clearer what I would like the code to do end product. It would take the $start + $end values. Minus the start from the end to get a value at which point it would put either Hours or Hour. Not just put the word Hours or Hour. But actually echo the time value of the event duration then add the Hours/Hour on the end. Harry.
  10. Thanks that works just perfectly. How would I then go to subtract the start time from the finish to get the duration and if say it was over an hour echo Hours otherwise Hour? Harry.
  11. Hi... again. I really should donate to here or something, I use it so much and feel so bad. Ah well. All I need to do (in theory) is change something like this 1500 into a time which would obviously be 1PM. Basically I am going to be plotting a beautiful graph with all this but need the axis to begin with. In the case below the time it starts is 1500 and finishes at 2200. // LOOP FROM START TO END $i = $eventecho['etd']; $ii = $eventfecho['eta']; while ($i <= $ii) { if($i == $ii) break; echo $i . "<br>"; $i = $i + 30; } This outputs: 1500 1530 1560 1590 1620 1650 1680 1710 1740 1770 1800 1830 1860 1890 1920 1950 1980 2010 2040 2070 2100 2130 2160 2190 Which is should. But obviously I just want the values: 1500 1530 1600 1630 etc.. ? So how exactly do I get the raw value which would be: "1500" and "2200" to turn magically into a time. Thanks, Harry. (Again, apologies for always posting, but im in the shtook.)
  12. I would edit but I cant so I will have to re-post in accordance to what you said sasa. Here is the code in full including the last bit for the movements per hour: // TIME FUNCTION FOR THE ARRIVALS function my_sec($a){ $a = explode(':', $a); $out = $a[0]; for($i=1;$i<count($a);$i++){ $out *= 60; $out += $a[$i]; } return $out; } $time1 = $_POST['tmarrtextfield']; $time2 = $_POST['tmatttextfield']; $numberresult = my_sec($time1) / my_sec($time2); $hourresult = my_sec($time1) / 3600; Problem: If for example I put in 30 minutes and click the button it will come up with an answer of 3 for moves per hour, which is impossible. Or. If I put in 20 minutes and try to get the moves per hour I get a return of 2, which is incorrect too... Harry.
  13. If I try 02:30:00 and 00:30:00 I get an answer of 2.5 - Not sure how I can iron that lil problem out there as well you should get 2 movements an hour. Also when I put the: $hourresult = my_sec($time1) / 3600; Under the rest of the code, it messes up the original full count and only shows the per hour.
  14. Thank you Crayon, I did knock up my own script before reading the submition by sasa which worked. Sasa... That works brilliantly. What would I need to add to the script to finalise it slightly. As currently you just have a count of the overall amount of movements, I would like to add another count but of movements possible per hour. How can I achieve this?
  15. Ok so I basically have two textfields and a submit button. The first text field basically allows the user to input a duration of an event in the format of Hours:Minutes:Seconds such as: 02:30:00 is two and a half hours. The second textfield allows the user to put in an average time 'something' does something in the same format as above. So for example 00:20:00 is 20 minutes. 1st Textfield: <input name="tmarrtextfield" type="text" class="textbox" id="tmarrtextfield" value="00:00:00"> 2nd Textfield: <input name="tmatttextfield" type="text" class="textbox" id="tmatttextfield" value="00:00:00"> What I need is for when the form is submitted to the same page.. the code to...: 1. Convert the normal text info into actual time data. 2. Divide the duration by the average timing so for example: 02:30:00 (150 minutes) / 00:20:00 (20 minutes) = 7.5 (Would return a rounded down number or up, doesn't matter) then store the number as a variable that will be echoed later. Harry.
  16. Problem solved, I was missing something in the code.
  17. Okay, so I have sorted the problem for about 140 entries... Except for one entry that still stretches the table width despite there being routes with longer entries which go onto new lines with no problem.
  18. Hello, I feel really really silly asking this as I am sure it is something completley obvious and i'm just been a twit as 1:15 in the morning but ive basically got a normal page and one of the returns that is displayed is a 'route', the table its housed in is 400px wide but the 'routes' are always longer than the table and don't go onto a newline and just distort the table by making it as big as it has to be to house the 'route'. Now for the life of me, (really silly part) what do I need to add to get the results to NOT distort the table in any way and go onto the next line if it can't fit on one. Harry.
  19. I've pm'd you the schema and a typical entry.
  20. Hi there, I have placed in these: $atc_arrivals_selectquery = mysql_query("SELECT a.callsign, a.planned_destairport, a.cid, a.atcarrivals, COUNT(b.cid) AS matchcount FROM CLIENTS a LEFT OUTER JOIN CLIENTS b ON a.callsign = b.callsign AND b.clienttype = 'ATC' GROUP BY a.callsign, a.planned_destairport, a.cid, a.atcarrivals"); Unfortunately, when you run the script it just returns the value: "1", for everything. Which is not correct, I am positive.
  21. Hiya, I've tried it but get the following error: "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/assuranc/public_html/testing/test7.php on line 138" Reffering to this line in the code: while($atc_arrivals_row = mysql_fetch_array($atc_arrivals_selectquery)) Regards.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.