
mastubbs
Members-
Posts
52 -
Joined
-
Last visited
Everything posted by mastubbs
-
Thanks all. Actually i only wanted to echo error message if no par was passed at all. psychos method almost works except it echos the default message for par >= 6. I adapted it as below which works in my case because par 99 is not a real par number. probably not the most elegant way but its worked this time. $par = isset($_GET['par'])?$_GET['par'] : 99; switch (true) { case ($par >= 0 && $par <= 2): echo 'par 0-2'; echo '<br/> PAR: '.$par; break; case ($par >= 3 && $par <= 5): echo 'par 3-5'; echo '<br/> PAR: '.$par; break; case ($par >= 6 && $par != 99): echo 'par >=6'; echo '<br/> PAR: '.$par; break; case ($par = 99): echo 'ERROR: invalid PAR score passed. Please contact server administrator'; break; default: echo 'ERROR: invalid PAR score passed. Please contact server administrator'; }
-
Thanks very much all for helpful replies. All worked to some extent, i have gone with Psycho's method. However, still if no par is passed it echos 'par 0-2 PAR:' This closer than before certainly, but it still doesnt echo the default message 'ERROR: invalid PAR score passed. Please contact server administrator'...
-
Ok so i have a few rather odd problems with switch case. I have no clue why these things are happening: PAR IS: <?php $par = isset($_GET['par'])?$_GET['par'] : ''; switch ($par) { case $par >=0 && $par <=2: echo 'par 0-2'; echo '<br/> PAR: '.$par; break; case $par >=3 && $par <=5: echo 'par 3-5'; echo '<br/> PAR: '.$par; break; case $par >=6: echo 'par >=6'; echo '<br/> PAR: '.$par; break; default: echo 'ERROR: invalid PAR score passed. Please contact server administrator'; } ?> if par >=1 the script works no problems BUT 1) if par is 0 echos 'par 3-5 PAR: 0' rather than 'par 0-2 PAR: 0' this seems very odd as 1 and 2 work fine! 2) if there is no value for par, it returns 'par 3-5 PAR: ', not default message These problems seem very odd to me. does anyone have a clue why this is happening?? Thanks in advance for any replies!
-
Hi thanks for the help, So i tried to set both php and mysql to use London/Europe by: <?php $connect = mysql_connect("localhost","jasperss_par1","password"); if (!$connect) { die("MySQL could not connect!"); } $DB = mysql_select_db('jasperss_par1pats'); if(!$DB) { die("MySQL could not select Database!"); } date_default_timezone_set('Europe/London'); mysql_query("SET time_zone = 'Europe/London'"); if (date_default_timezone_get()) { echo 'date_default_timezone_set: ' . date_default_timezone_get() . '<br />'; } if (ini_get('date.timezone')) { echo 'date.timezone: ' . ini_get('date.timezone'); } ?> but this returns : date_default_timezone_set: Europe/London date.timezone: America/New_York Should it not return: date_default_timezone_set: Europe/London date.timezone: Europe/London ?? Maybe i cant change it from New York time for some reason? Assuming for now i have to store the datetimes as new york time, i should still be able to return these times as london time right? I tried this but i get a syntax error, am i using it wrongly? <?php $connect = mysql_connect("localhost","jasperss_par1","password"); if (!$connect) { die("MySQL could not connect!"); } $DB = mysql_select_db('jasperss_par1pats'); if(!$DB) { die("MySQL could not select Database!"); } if(isset($_GET['mrn'])) { $Search = $_GET['mrn']; $Find_Query1 = mysql_query("SELECT CONVERT_TZ('_sfm_form_submision_time_','America/New_York','Europe/London') DATE_FORMAT(_sfm_form_submision_time_,'%H:%i') AS time, SBP FROM obs WHERE mrn='$Search' AND DATE(_sfm_form_submision_time_) = CURDATE() order by time ASC"); if(!$Find_Query1) { die(mysql_error()); } while($row = mysql_fetch_assoc($Find_Query1)) { echo '<br/> TIME: '.$row['time']; echo '<br/> SBP: '.$row['SBP']; echo '<br/>'; } $numCount = mysql_num_rows($Find_Query1); if ($numCount < 1) { print("no sbp found for that mrn today"); } } ?> Thanks again for the help.
-
Hia, You mean like this? $Search = $_GET['mrn']; mysql_query("SET time_zone = 'Europe/London'"); $Find_Query1 = mysql_query("SELECT DATE_FORMAT(_sfm_form_submision_time_,'%H:%i') AS time, SBP FROM obs WHERE mrn='$Search' AND DATE(_sfm_form_submision_time_) = CURDATE() order by time ASC"); if(!$Find_Query1) { die(mysql_error()); } It doesn't change the times returned, they are still 4 hours behind :-(
-
Hi all, Ok so i have a bit of a tricky question. I am using a query to return just time from a datetime variable '_sfm_form_submision_time_' based on a few conditions as follows: if(isset($_GET['mrn'])) { $Search = $_GET['mrn']; $Find_Query1 = mysql_query("SELECT DATE_FORMAT(_sfm_form_submision_time_,'%H:%i') AS time, SBP FROM obs WHERE mrn='$Search' AND DATE(_sfm_form_submision_time_) = $chosendate() order by time ASC"); if(!$Find_Query1) { die(mysql_error()); } while($row = mysql_fetch_assoc($Find_Query1)) { echo '<br/> TIME: '.$row['time']; echo '<br/> SBP: '.$row['SBP']; echo '<br/>'; } $numCount = mysql_num_rows($Find_Query1); if ($numCount < 1) { print("no sbp/time found for that mrn on chosen date"); } However, i want to make a correction to the returned 'time', for daylight saving. In the UK daylight saving time (British Summer Time - BST) starts at 1am on the last Sunday in March (1am GMT), and finishes at 2am BST (ie 1am GMT) on the last Sunday in October. To make things more complex, my server saves datetimes as 4 hours behind GMT (which i cant change), so i also want to correct for this. So, if the date '_sfm_form_submision_time_' was recorded was in daylight saving time I want to add 3 hours to 'time', otherwise i want to add 4 hours to 'time'. Does anyone have any clue how to do this?? Any help anyone can give would be amazing! Thanks Matt
-
SQL and PHP : Select time from datetime when date is current date
mastubbs replied to mastubbs's topic in PHP Coding Help
Perfect, both worked. Thanks. -
Hi all, Im new to php and im trying to do something a bit fiddly. I was wondering if anyone knows how... I have a table 'obs' with columns '_sfm_form_submision_time_' (date and time of submission of dataset in format YYYY-MM-DD HH:MM:SS), 'mrn', 'sbp' and a few other variables. I want to echo the sbp and TIME (in the format HH:MM from _sfm_form_submision_time_), as long as the DATE of submission was today (ie date in _sfm_form_submision_time_ is current date) for a given value for mrn (passed from previous page). Ie, if 3 data sets were entered today for mrn 001 then i want to display the times these were entered, and the sbp entered. I have this so far but it keeps telling me no results for mrns that have datasets enetered today, so somewhere the code must be wrong but i can't figure out where! Any help to find the problem would be amazing, thanks! <?php //STEP 1 Connect To Database $connect = mysql_connect("localhost","jasperss_par1","password"); if (!$connect) { die("MySQL could not connect!"); } $DB = mysql_select_db('jasperss_par1pats'); if(!$DB) { die("MySQL could not select Database!"); } //STEP 2 Check Valid Information if(isset($_GET['mrn'])) { //STEP 3 Declair Variables $Search = $_GET['mrn']; $Find_Query1 = mysql_query("SELECT DATE_FORMAT(_sfm_form_submision_time_,'%H:%i') TIMEONLY, SBP FROM obs WHERE mrn='$Search' AND _sfm_form_submision_time_=CURRENT_DATE()"); if(!$Find_Query1) { die(mysql_error()); } // STEP 4 Get results while($row = mysql_fetch_assoc($Find_Query1)) { echo '<br/> TIME: '.$row['_sfm_form_submision_time_']; echo '<br/> SBP: '.$row['SBP']; echo '<br/>'; } $numCount = mysql_num_rows($Find_Query1); // STEP 5 error message if no results if ($numCount < 1) { print("no sbp found for that mrn today"); } } ?> Thanks again! M
-
Some PHP and SQL questions... My first project
mastubbs replied to mastubbs's topic in PHP Coding Help
Just to help others who may have this question: the answer was i had missed that there was % (wildcard) before and after Search so it was performing a LIKE type search even if = was selected due to that - took me a lot of fiddling but i figured it out eventually! -
I did. is that bad?
-
Some PHP and SQL questions... My first project
mastubbs replied to mastubbs's topic in PHP Coding Help
Sadly this link does not really answer the question. I see how to return that there are multiple results, i don't see how you can return ONLY this, so that none of the results are displayed if there are multiple, which is what i want it to do - i just want to tell them to try again if there is not a single result. It also says that this extension is depreciated and will be removed soon, another reason not to use it? I don't suppose anyone know the answer to why '=' doesn't find anything but 'like' does, still cant get my head around that :-/ -
Some PHP and SQL questions... My first project
mastubbs replied to mastubbs's topic in PHP Coding Help
Hi Ignace, Thanks for your reply. great, thanks. Its because the patient's MRN numbers are unique numbers which sometimes start with a variable number of leading 0s. It is quite important that this is an exact search as i only want to return a single result, which is the correct patient for that number. In our current system the nurses are used to entering the leading 0s so i would like to keep them to avid confusion. I would have thought that replacing LIKE with = would do it, but it returns nothing even if the MRN number is exactly correct. Any idea why? where is the code does this go? I tried it as below but no joy. If there are multiple results i don't want to return any of them, i just want to echo 'multiple results', and a link back to the search.html page to try again. if(!$Find_Query1) { die(mysql_error()); } if(mysql_num_rows() > 1) echo 'multiple results, check MRN and try again'; while($row = mysql_fetch_assoc($Find_Query1)) { echo '<br/> MRN: '.$row['mrn']; echo '<br/> First Name: '.$row['fname']; echo '<br/> Last Name: '.$row['lname']; echo '<br/> Date of Birth: '.$row['dob']; } } ?> I also realised that 'echo 'no patients were found'; is returned whether or not there are patients found, so i have obviously used that wrongly! I guess you could use mysql_num_rows() = 0? How would i use both, im not sure how to do an if else statement in php. Thanks again for your help with this. Matt -
Hi All! So I’ve never really used SQL or PHP before, this is my first project. The idea is that nurses can search for patients in one table of a hospital database (patients table), and enter new records of their heart rate and blood pressure in a separate database table (observations table). I have managed to set up a database and the tables, and made a search form (searching using MRN, which is the patient's hospital number) which returns the patient details (name, dob, etc...) <?php //STEP 1 Connect To Database $connect = mysql_connect("localhost","jasperss_par1","k_dD6JsB"); if (!$connect) { die("MySQL could not connect!"); } $DB = mysql_select_db('jasperss_par1pats'); if(!$DB) { die("MySQL could not select Database!"); } //STEP 2 Check Valid Information if(isset($_GET['search'])) { //STEP 3 Declair Variables $Search = $_GET['search']; $Find_Query1 = mysql_query("SELECT * FROM patients WHERE mrn LIKE '%$Search%' "); if(!$Find_Query1) { die(mysql_error()); } while($row = mysql_fetch_assoc($Find_Query1)) { echo '<br/> MRN: '.$row['mrn']; echo '<br/> First Name: '.$row['fname']; echo '<br/> Last Name: '.$row['lname']; echo '<br/> Date of Birth: '.$row['dob']; echo '<br/> <a href="http://test.com/nextpage.php?mrn= ' .$row['mrn']>Click here</a>; } echo 'no patients were found'; } ?> There’s a few things I just can’t figure out how to do, although I should imagine it’s fairly straight forward when you know how! Any help or ideas anyone has would be very much appreciated. 1) The database will not record a number which starts with 0! (eg if I save a MRN number as 0001, it just saves as 1). I have tried various field types but can’t seem to do it. Does anyone know if there is a field type that will accept numbers starting with 0? 2) I only want my search to find the record if the exactly correct MRN number is entered. However, if I replace the ‘like’ condition with =, I get no returned results, even if I search for exactly the correct number, I can’t figure out why. 3) Because I only want to display one result, how do I echo ‘multiple results found’ if there is more than one record with the same mrn. 4) I want to link onto the next page, is there some way I can ‘post’ forward some of the data on this page (in order so i can autofill part of the form on the linked page with MRN and name, so the nurses can just fill in heart rate and blood pressure for that patient and submit it to observations table). You can see I have tried to do it by parsing the MRN in the link, but I must have the syntax wrong somewhere because its not working :-(. Thanks very much in advance for any help anyone can give me with this. Matt
-
Hia, Ahhh... ok I see. So i've managed to set up both tables using your tutorial. table_patients contains ID, name, dob and hospital number. table_records contains ID heart rate and blood pressure. How do i set it up so that the table knows ID is a foreign key? Thanks so much for the help!
-
Ok so ive been experimenting based on your tutorial (which was very useful by the way, thanks!). Im still having that same problem though. Im trying to figure out how a user could open a patient, and add a new data under that patient with a automatic date and time added to it, without overwriting the old data. Hummm....
-
Yes, a bit.
-
Hi thanks for the response. I will have a good look through that, thanks. The bit that might be a bit complex is that each time a patient record is accessed i want to add a new row to a table to store a few variables (eg date time blood pressure heart rate etc...) the aim is to be able to pull this data into a graphical observation chart. Does your tutorial explain how to add new rows under the selected record in this way? thanks
-
Hi all, I found this nice php script which uses an iphone barcode scanner to return the barcode EAN number in a URL. I want to pass it to an HTML form on another webpage. Does anyone know how to do this? I suspect its pretty simple im just very new to PHP and HTML. Thanks in advance for any replies, Matt <?php $code = $_REQUEST['ean']; echo '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>'; ?> <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>test barcode reader</title> </head> <body> <div> <h1>test barcode reader</h1> <?php if ( $code ) : ?> <p> The barcode was <?php echo htmlentities( $code ); ?> </p> <?php endif; ?> <p> <a href="pic2shop://scan?callback=http://www.meandeviation.com/test/iphone/barcode.php?barcode=EAN">read barcode</a> </p> <p> This web page is for iPhone users only and needs <a href=""http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=308740640&mt=8">pic2shop</a> installed (it is free), which allows third party web apps and iPhone apps to use its bar code reading software as a form of local web service. </p> </div> </body> </html>
-
Hi all, I have very limited knowledge of HTML and SQL but I’m trying to create a web user interface to allow updating of medical records. The idea is to use an HTML web form to search a SQL database for a record based on a patient number, and return and display the patients name and date of birth, along with another form that can be used to enter a new record for that patient which could then update the database by adding this record. (ie would need to create a new database table with date, time and whatever data was input into the form (say 5 more fields). Im guessing that to do this one would need to pass the data using PHP somehow, but im afraid I don’t have enough knowledge of how. Can anybody help advise me on how to do this? Thanks in advance for any replies, Matt