Jump to content

Search the Community

Showing results for tags 'sql'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I am working on a website, where you can have accounts and status'. I want to create a "recent status updates" area but I need a little help. Is there a way to like, check recent updates to a mysql database? like check how recently under the table member the area "status" has been updated? if anyone could point in the right direction for this, it would be quite helpful. And if you maybe need more info to help me, let me know. Thanks!
  2. Okay so I have a completely fully functional member system. Login works, register works, In this system I dont let people make two accounts with the same name, however if they have caps in different spots, it works. Any ideas how to prevent this? Any help is much appreciated! Thanks!
  3. hello I have a query which is long, but the main section I have a question about is GROUP BY id ORDER BY id DESC LIMIT 10 this works ok and gives me the first 10 records in descending order, so it gets oldest to newest what do I need to do, to keep the query (first 10 records) but order by newest to oldest can anyone help me, I've searched high and low, and tried lots of ideas, but cannot get it to work right thanxs
  4. I will paste the code below. Okay so I've benn trying to work with SQL in php connecting to a MySQL Database I have hosted on my own computer. I am trying to use an HTML form to get in info I need. But when I hit SUBMIT I don't get the output I was looking for. Any ideas why my code wont work? Also, I am sorry if this is the wrong section, I am new to the forum, if this is the wrong section, can someone please point me to where i need to go? Thanks! <html> <form action="index.php" method="post"> <input type="text" name="username"><br> <input type="text" name="password"><br> <input type="submit"> </form> </html> <?php $uname = $_POST[username]; $pword = $_POST[password]; $con=mysqli_connect('localhost', 'root2', '', 'first_db'); //Check conbnection if(mysqli_connect_errno()) { echo 'Failed to connect: ' . mysqli_connect_error(); } else{ $result = mysqli_query($con,"SELECT * FROM members WHERE username=$uname"); while($row = mysqli_fetch_array($result)) { echo $row['username']; echo $row['password']; echo $row['id']; } }
  5. I have 4 studies that I need to display on a page. I was printing them in order, but I would like to make a partition that clearly distinguishes each section, studyID and studyName. Here is the code thus far: $sql = 'SELECT * FROM tbl_studies'; $list = mysqli_query($dbcon, $sql); $numRecords = mysqli_num_rows($list); for ($i = 1; $i < $numRecords ; $i++){ $sql1 = 'SELECT * FROM tbl_studies JOIN tbl_childinformation ON tbl_studies.studyID = tbl_childinformation.studyID JOIN tbl_parentinformation ON tbl_childinformation.parentID = tbl_parentinformation.parentID'; $list1 = mysqli_query($dbcon, $sql1); $record1 = mysqli_fetch_assoc($list1); echo "<center>----------------------------------------------------------------------<br>"; echo "<center>" . $record1['studyID'] . ' ' . $record1['studyName'] . "</center>"; echo "----------------------------------------------------------------------</center><br />"; $sql = "SELECT * from tbl_studies JOIN tbl_childinformation ON tbl_studies.studyID = tbl_childinformation.studyID JOIN tbl_parentinformation ON tbl_childinformation.parentID = tbl_parentinformation.parentID WHERE tbl_childinformation.studyID = '$record1[studyID]'"; $list = mysqli_query($dbcon, $sql); while($record = mysqli_fetch_assoc($list)){ $newbirthdate = date('m/d/Y', strtotime($record['dateOfBirth'])); $newstudydate = date('m/d/Y', strtotime($record['dateOfStudy'])); echo $record['studyID'] . ' ' . $record['studyName'] . '<br>'; echo "<p class = \"smallerfont\"><em>ID:</em> " . $record['childID'] . "<p class = \"smallerfont\"><em>Name:</em> " . $record['childFirstName'] . ' ' . $record['childLastName'] . "<p class = \"smallerfont\"><em>Date of Birth:</em> " . $newbirthdate . "<p class=\"smallerfont\"><em>Twin?:</em> " . ($record['twin'] == 1 ? 'Yes' : 'No') . "<p class = \"smallerfont\"><em>Medical Conditions:</em> " . $record['medicalConditions'] . "<p class = \"smallerfont\"><em>StudyID:</em> " . $record['studyID'] . "<p class=\"smallerfont\"><em>Date of Study:</em> " . $newstudydate . '<br /><br />'; echo "<div id=\"parentblock\">"; echo "<a id= \"parentlink\" href=\"parentinformationlink.php?pid=" . $record['parentID'] . "\"> Link to " . $record['parentOneFirstName'] . ' ' . $record['parentOneLastName'] . (empty($record['parentTwoFirstName']) ? '</a>':' and ' . $record['parentTwoFirstName'] . ' ' . $record['parentTwoLastName']) . "</a>"; echo "</div>"; } } So basically, I figured I could count the number of studies there are after querying the tbl_studies, and then for a for loop, and only print the children that have matching studyID's. Works great for the first loop, but I need to reference the 2nd record, and so on. Is there a way to achieve this in php? Any advice is greatly appreciated!
  6. Hello, i have a table i have to fill out with info regarding other tables, is a join possible or do i have to make 2 queries? This is what i have right now. $date = date("Y-m-d H:i:s"); $sql = "INSERT INTO tblpaqueteria ( sender_id, reciever_id, AddTime, Estatus, ubicacion, tipo,slocalidad_id,rlocalidad_id ) VALUES ( '{$_POST['id_send']}', '{$_POST['id_rec']}', '{$date}', '0' , '0', '{$_POST['tipo_paq']}',0,0 )"; $res = mysql_query($sql,$this->conn); return $sql; What i need now is to change some of my insert into dynamic ones, i have to enter into "slocalidad_id" and into "ubicacion" the "id" of a table called localidad, and this id is being referenced from a table called "usuarios" (users) where "$_POST['id_send']" where localidad_id marks the id i need to insert into tblpaqueteria. I am not sure if I explained myself correctly so ill try and make an example. usuarios So for my sql above, without joins i would be receiving from POST id_send = 2 and from id_rec 11 so my query should insert this $sql = "INSERT INTO tblpaqueteria ( sender_id, reciever_id, AddTime, Estatus, ubicacion, tipo,slocalidad_id,rlocalidad_id ) VALUES ( '{$_POST['id_send']}', '{$_POST['id_rec']}', '{$date}', '0' , '2', '{$_POST['tipo_paq']}',2,4 )"; notice the numbers "2" and "4" being inserted, those are the ones i don't know how to enter dynamically, i think its a join, but i don't know how to use them in an insert. Thanks a lot
  7. I have a input tag <input type="radio" name="<?php echo $serial_number; ?>" /> now i want to save the value into a variable like if(isset($_POST['next'])) { $answer = $_POST['$serial_number']; // here is wrong what is correct syntax. can anybody help me. N.b: $serial_number is like (1,2,3..etc)
  8. Hi all, im using the following sql query to select data from two tables where the most recent value for 'par' is > 6. SELECT patients.*, addobs.*, DATE_FORMAT(addobs.datetime, '%d/%m/%Y %H:%i:%s') as dti1 FROM addobs INNER JOIN patients ON addobs.MRN = patients.MRN WHERE addobs.datetime = (SELECT MAX(OLAST.datetime) FROM addobs AS OLAST WHERE OLAST.MRN = patients.MRN) AND addobs.par > 6 AND NOT addobs.hidden = 'yes' AND COALESCE(patients.ward,'') != 'dc' order by addobs.par ASC I would like to extend this query to also return as 'dti2', the datetime value that par > 6 LAST BECAME true. To clarify, if i have 5 values as follows: datetime par 06-18-2013 05:00:00 7 06-18-2013 04:00:00 8 06-18-2013 03:00:00 7 06-18-2013 02:00:00 2 06-18-2013 01:00:00 10 Then the datetime to be returned by my query as dti2 would be 06-18-2013 03:00:00, as this is the time that par>6 LAST BECAME true (and it has STAYED true since this time) This is to be distinguished from 06-18-2013 01:00:00 (which is when PAR>6 FIRST became true) and also to be distinguished from 06-18-2013 05:00:0 (which is when PAR>6 was LAST true) To give some context for further clarity: PAR is a measure of how unwell a patient is (larger numbers = more unwell). So i am trying to create a list of unwell patients. I want to return patients who have a PAR score of >6 (which is what my query currently achieves) and the amount of time they have had CONSECUTIVE par scores >6. From my limited knowledge of sql i would have thought that this could be done somehow with coalesce but im not sure exactly how. i have tried a few different things with no luck. I hope that all makes sense, i get a little confused even explaining it! Thanks for any help anyone can give in advance, Best, Matt
  9. Hi All, So I am using this query to return some values.: $Find_Query2 = mysql_query("SELECT patients.*, addobs.* FROM addobs INNER JOIN patients ON addobs.MRN = patients.MRN WHERE addobs.datetime = (SELECT MAX(OLAST.datetime) FROM addobs AS OLAST WHERE OLAST.MRN = patients.MRN) AND addobs.par > 6 AND NOT addobs.hidden = 'yes' AND COALESCE(patients.ward,'') != 'dc' order by addobs.par ASC"); However, i one of the values ('datetime') is in the php datetime format yyyy-mm-dd hh:ii:ss. I want to return this in a different format dd/mm/yyyy hh:ii:ss. I tried using DATE_FORMAT as thats what i usually use to do this but i think my syntax is wrong as it is returning no results for 'datetime' in the way i am using it. I think im getting confused with my brackets somewhere. $Find_Query2 = mysql_query("SELECT patients.*, addobs.* FROM addobs INNER JOIN patients ON addobs.MRN = patients.MRN WHERE addobs.datetime = (SELECT DATE_FORMAT(MAX(OLAST.datetime), '%d/%m/%Y %H:%i:%s') FROM addobs AS OLAST WHERE OLAST.MRN = patients.MRN) AND addobs.par > 6 AND NOT addobs.hidden = 'yes' AND COALESCE(patients.ward,'') != 'dc' order by addobs.par ASC"); Can anybody tell me what im doing wrong here? Thanks in advance for any help, Matt
  10. I'm designing a website for a wine wholesaler that needs to be able to update and display their product catalog in a certain specific way. The site in development is at www.metrocellars.com/new/ Let me first begin by outlining the database tables in use: location​ - a table of 6 records, the broader breakdown of geographic location (Brazil, California, etc.) These rows are used in the navigation menu, and each location has many "regions" referencing them. region​ - the more specific area of origin of each product (wine). Each "Region" references one of the 6 broader "Locations". product​ - The meat of the db, each Product record references a Producer/Winery (PID), a specific Region (RID - which also references a broader Location), and a specific Varietal (VID - Wine type/color). The left part of the image below shows part of the Product table. winery​ - This table holds records of each Winery/Producer referenced by PID in Product table. varietals - This table lists each type of wine, (Pinot, Merlot, etc) referenced by VID in the Product table. ​ On the right side of the above image, I included a visual of the relevant tables with FK relation lines. I haven't figured out which ON DELETE/UPDATE to use, as I got errors a couple times from child rows as I was assigning indexes/keys. I'm a little rusty with the SQL at the moment. Using this model, I need to be able to output the data to a wine list page, but I am having problems putting together the right queries and loops to list the data in the requested format. Here is an example of what the page content should look like when the 'region' California (LID = 2) is clicked on the nav menu. California Slo Down Wines http://www.slodownwines.com/ Broken Dreams Sexual Chocolate Central Coast Jackhammer http://jackhammerwine.com Pinot Noir Happy Canyon of Santa Barbara Cimarone Winery http://www.cimarone.com/ 3CV Bank 3CV Cilla’s Blend Le Clos Secret Gran Premio 3CV Estate Sauvignon Blanc Dragonette Cellars http://dragonettecellars.com/ GMS Rose Sauvignon Blanc Happy Canyon Vineyards http://happycanyonvineyard.com/ Ten Goal Merlot http://happycanyonvineyard.com/ Piocho Margerum Wine Company Sybarite Sauvignon Blanc Paso Robles Spaceman Vineyards Reserve Airspace Santa Barbara County Ampelos Cellars Syrache - Syrah & Grenache Margerum Wine Company http://www.margerumwinecompany.com/ Chenin Blanc M5 Riesling Uber Reserve Tercero http://tercerowines.com/ Grenache Grenache Blanc The Climb Santa Lucia Highlands Jackhammer http://jackhammerwine.com Chardonnay Santa Maria Tyler Winery Bien Nacido Pinot Noir Sta Rita Hills Ampelos Cellars http://ampeloscellars.com/ Pinot Noir Lambda Reserve Rho Reserve Viognier Dragonette Cellars http://dragonettecellars.com/ In the above list, each heading is a record of each "Region" with the same LID as California in the Location table. LID = 2, so I need to list each Region within California, and within each of those listings, list each Wine that has the same RID as that Region, but grouped by their respective Wineries. Basically, there are a few Wineries that have products (child rows I believe) with differing Regions of origin. So, there are products that can have the same PID, but different RID. You can get an idea of the format from the above example. My problem is, is how would I nest the loops and queries, and what joins would be necessary? Any and all help is a godsend. This has been quite a headache.
  11. Hi all, So I have a page which uses mysql_query to select some variables from a table, and then produces an array in order to plot this information on a graph (data used for this depends on the unique id which is obtained by $_GET [‘mrn’]. This is all working fine. However, what I want to do now is include multiple copies of these graphs on a single page (graphs for different mrn’s). I tried to do this by including the files like this: <php $_GET[mrn] = "1"; include('graph.php'); ?> //some html <php $_GET[mrn] = "2"; include('graph.php'); ?> The problem with this method has been that although it works once, the second you include a second graph it stops working (presumably because I have tried to assign two different values to the same variable by effectively defining it twice?) My question is therefore, is there some way to include a file, get its output (draw its graph), and then stop including it, so that I can start including the next file (drawing next graph). My reading so far has led me to believe there probably isn’t a way? Am I correct about that? Does anyone have any ideas about how I might get this working using a different technique? Thanks in advance for any help, Matt
  12. OK time for a very tricky mysql query (well, tricky for me anyway)… I have two tables: ‘patients’ and ‘obs’ Variables in patients: MRN, name, others1 Variables in obs: MRN, par (numeric value), time_recorded (datetime value), others2 Each time a new par value is added to obs: MRN, datetime, others 2 are recorded also (there are no null values). Multiple par values are therefore added over time for the same MRN number (as different rows in the table) I want to make a query that will select * from patients and * from obs using inner join using MRN only when the most recent par value for each unique MRN in obs was >6 For some context: MRNs are hospital numbers of patients and par is a score of how unwell they are. I am trying to produce a list of all the patients who’s most recent par value recorded in obs is >6 and print their details. I think I have managed to work out the inner join part: SELECT * from obs INNER JOIN patients ON obs.MRN = patient.MRN. What I just can’t figure out however is how to select only records where the most recent par for that particular MRN (ie patient) was > 6. I suppose one way to do this is to select all data from both tables using inner join MRN where obs.par >6, and then sort by mrn, the sort by datetime decending, and then only print the top returned result for each unique mrn, but im not really sure if that last part is possible? I hope all that makes sense? Any guidance or ideas anyone has about how to achieve this would be very helpful. Thanks all in advance for any replies, Matt
  13. I have a SQL query where I am retrieving information to a table. I would like to only retrieve data from yesterday. I found some PHP code which I´ve formated to look exactly as the Date does in the database (2013-05-30) YYYY-mm-dd but I can´t get it to work. Does someone see what the error might be? <?php $date = new DateTime(); $date->add(DateInterval::createFromDateString('yesterday')); $conn = mysql_connect($dbhost, $dbuser, $dbpassword); if(! $conn ) { die('Could not connect: ' . mysql_error()); } mysql_select_db($dbname, $conn); echo '<STYLE TYPE="text/css">'; echo 'TD{font-family: Arial; font-size: 9pt;}'; echo '</STYLE>'; echo '<table border=1><thead><tr><th>Namn</th><th>Datum</th><th>SE Mail</th><th>SE Backoffice</th><th>DK Mail</th><th>DK Backoffice</th><th>NO Mail</th><th>NO Backoffice</th><th>FI Mail</th><th>FI Backoffice</th></tr></thead><tbody>'; $q = mysql_query("SELECT id, name, Date, SEMail, SEBackoffice, DKMail, DKBackoffice, NOMail, NOBackoffice, FIMail, FIBackoffice FROM maildata WHERE Date = $date->format('Y-m-d')"); while($f = mysql_fetch_array($q)) { echo '<tr><td>'.$f['name'].'</td><td>'.$f['Date'].'</td><td>'.$f['SEMail'].'</td><td>'.$f['SEBackoffice'].'</td><td>'.$f['DKMail'].'</td><td>'.$f['DKBackoffice'].'</td><td>'.$f['NOMail'].'</td><td>'.$f['NOBackoffice'].'</td><td>'.$f['FIMail'].'</td><td>'.$f['FIBackoffice'].'</td></tr>'; } echo '</tbody></table>'; mysql_close($conn); ?>
  14. Hi all, So im quite new to sql queries and ive been reading how to use if else but i ccant figure out what im getting wrong in this one. Can anyone help? I want to use a datetime variable (which is an automatic timestamp 'datetime') but only if the user has not manually over-ridden this by entering their own datetime ('datetime_man). I have tried to use IF ELSE but im getting it wrong somewhere. Is the syntax right? $Find_Query1 = mysql_query("SELECT DATE_FORMAT(datetime,'%Y/%m/%d %H:%i:%s') AS datetime2 IF datetime_man='null' ELSE DATE_FORMAT(datetime_man,'%Y/%m/%d %H:%i:%s') AS datetime2, DATE_FORMAT(datetime,'%H:%i on %d/%m/%y') AS datetime3 IF datetime_man='null' ELSE DATE_FORMAT(datetime,'%H:%i on %d/%m/%y') AS datetime3, SBP, SBP_R, SBP_B, DBP, DBP_R, DBP_B, HR, HR_R, HR_B, RR, RR_R, RR_B, SpO2, SpO2_R, SpO2_B, O2flow, O2flow_R, O2flow_B, O2device, O2deviceOther, TEMP, TEMP_R, TEMP_B, AVPU FROM addobs WHERE mrn='$Search' AND DATE(datetime)='$Date' AND NOT hidden = 'yes' order by datetime2 ASC"); Thanks in advance for the help, Matt
  15. Hello, I have a table called profiles. I have 3 colums, id,property,value The property has the items name,rating,birthday and the column value holds the value of each property. Now i want to order my results by the property rating and value Desc. I'm stuck here how i can do this ? Can anyone helps me with that ?
  16. hi, im a newbie here. im seeking help for my problem. i am also new in php but have some knowledge in sql here's my problem. my boss wants to enable update the baking chamber table once the Estimated End Time reached only. meaning if the end time doesn't meet there will be a pop up on the page that operator cannot finished unless the estimated end time is reached. Please kindly help check my code and see screenshot attached for your reference. Thanks in advanced guys. if($_POST['submit']=="Bake Finished") { $time = strftime('%I:%M %p'); $hours = strftime('%H'); $min = strftime('%M'); $query=mysql_query("SELECT * FROM tbl_baking_chamber"); while($result=mysql_fetch_array($query)) { $recno=$result['RecNo']; if(isset($_POST[$recno])!=NULL) { mysql_query("UPDATE tbl_baking_chamber set tbl_baking_chamber.TotalTime='$TotalTime' where RecNo='".$recno."'"); mysql_query("UPDATE tbl_baking_chamber set tbl_baking_chamber.EndTime='$CurrentDate - $time' where RecNo='".$recno."'"); mysql_query("UPDATE tbl_baking_chamber set tbl_baking_chamber.Status='Finished' where RecNo='".$recno."'"); } } } if($_POST['submit']=="On Baking" || $_POST['submit']=="Bake Finished") { echo "<table class='tbl_Forbaking' cellspacing='1' border='0' width='680'>"; echo "<form action='Applications.php?type=BGABaking' method='post'>"; echo "<tr>"; //echo "<td class='text2' align='center' bgcolor='e3e6e5' height='40'>"."MODEL"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."SERIAL NUMBER"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."DEFINED <br> BAKE TIME"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."BATCH"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."LOCATION"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."START TIME"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."ESTIMATED <br> END TIME"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."<input type='submit' name='submit' value='Bake Finished' class='btn_Bake'>"."</td>"; $Query = mysql_query("SELECT * FROM tbl_baking_chamber where Status='On Baking'"); $count = mysql_num_rows($Query); $bgcolor="e3e6e5"; while($result = mysql_fetch_array($Query)) { if($bgcolor=='e3e6e5') { $bgcolor='e9ebea'; } else { $bgcolor='e3e6e5'; } echo "<tr>"; //echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['Model']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['Serial']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['BakingHours']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['Batch']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['Chamber']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['StartTime']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['SEndTime']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>"."<input type='checkbox' value='$result[RecNo]' id='$result[RecNo]' name='$result[RecNo]'>"."</td>"; } echo "</form>"; echo "<tr>"; echo "<td>"."<br/>"; echo "<tr>"; echo "<td class='text4'>"."Total QTY.: $count"; echo "</table>"; }
  17. 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
  18. Dear all, Here is my scenario, I have a php page called index.php which is linked to dashboard. At the index page i will have 40-50 href's each with a id like dashboard.php/subcat=1 When a user click's particular href they will be forwarded to a page called dashboard and there i get this id. $subcat=$_REQUEST['subcat']; This dashboard is dynamic. In this page i have three different div's. Each with different query and result display. For example: My first div has a query and some 50 results. I want a display first four rows and remaining as a ajax pagination. similarly for the other two div's. There is no problem in using ajax pagination because it will be executed in different page and result will be display here. But the real problem is in each of my query i should pass the original subcat id which is what make the dashboard dynamic. Now, i need someway to pass this dynamic id for my external pagination for each query.
  19. 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
  20. 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
  21. 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
  22. So I have a site with product categories, sub-cats, sub-sub, sub-sub-sub, and even sub-sub-sub-sub. So each category could be up to 5 levels deep. I want to be able to go to a category page and pull all the categories, and sub-cats this category belongs to, to create a sitemap. The database is structured like: category_id | category_name | parent_id | category_url 1 | Clothes | null | clothes 2 | Shirts | 1 | shirts 3 | Designer Shirts | 2 | designer-shirts So if I was to create a sitemap for Designer Shirts, I would want <a href="index.php">Home</a> >> <a href="clothes">Clothes</a> >> <a href="clothes/shirts">Shirts</a> >> <a href="clothes/shirts/designer-shirts">Design Shirts</a> So I want to do a mysql join that will find me all the categories that belong to the current page, and pull the urls (urls also have the parents urls contained too). And the query has to be useable for any hierachy of the category page.
  23. What I'm doing is dynamically creating a table that automatically calculates the due date (based off of original, single DB entry) and what I need to do NOW is interrupt the loop at a certain point to inject a payment from another table. Here's the code that I have: while($startdate <= $today) { if ($startdate <= $pmt_date) { echo '<tr><td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'. date("m.d.Y", $startdate) . '</center></td>'; echo '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'. "$" . $english_format_number = number_format($row["supportamount"], 2, '.',',') . '</center></td>'; echo '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>$0.00</center></td>';echo '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'. $intacc . '</center></td>'; echo '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'. $appint . '</center></td>'; echo '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'. $appprinc . '</center></td>'; echo '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'. $bal . '</center></td></td>'; $startdate = strtotime('+1 month', $startdate); } else { echo '<tr><td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'. date("m.d.Y", $pmt_date) . '</center></td>'; echo '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>$0.00</center></td>'; echo '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'. "$".$english_format_number = number_format($row2["pmt_amt"], 2, '.',',') . '</center></td>'; echo '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'. $intacc . '</center></td>'; echo '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'. $appint . '</center></td>'; echo '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'. $appprinc . '</center></td>'; echo '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'. $bal . '</center></td></td>'; } } echo '</table>'; There's only one instance of what is needed being injected working, then it repeated continuously. What I need to do it have it only apply ONCE during that loop... possibly a foreach() statement? If so, how would I do that and have the $pmt_date array automatically generated and how would the table generate?
  24. need to generate the correct format of this report, please advise if what i want is feasible or not. what i want is that at the image below i only want to show a distinct value under Severity, Category 2 and Category 3 columns, meaning there should just be one entry for Severity 3 and Severity 5 under Severity column and same goes for the Category 2 and Category 3 column entries here is the image: below is my SQL statement which generated the image above: $dates = $_POST['dates']; $sql="SELECT DISTINCT trouble_type_priority, category_1, category_2, status FROM tbl_main WHERE resolved_date = '$dates' ORDER BY trouble_type_priority,category_1,category_2"; here is the other part of the code: echo "<table width='150' border=0 align='center'> <tr> <th colspan='2'>Remaining Tickets:</th> </tr> <tr> <th width='72'>Wireless:</th> <th><input type='text' name='WirelessRemaining' id='WirelessRemaining' size='7' /></th> </tr> <tr> <th>Wireline:</th> <th><input type='text' name='WirelineRemaining' id='WirelineRemaining' size='7' /></th> </tr>"; echo "<table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'> <tr> <th colspan='3' align='center'>Ticket Bucket</th> <th colspan='3' align='center'>Status</th> </tr> <tr> <th width='auto' align='center'>Severity</th> <th width='auto' align='center'>Category 2</th> <th width='auto' align='center'>Category 3</th> <th width='auto' align='center'>Resolved</th> <th width='auto' align='center'>Re-assigned</th> <th width='auto' align='center'>Closed</th> <th width='auto' align='center'>Grand Total</th> </tr>"; while($info = mysql_fetch_array($myData)) { echo "<form action='report.php' method='post'>"; echo"<tr>"; echo "<td align='center'>" . $info['trouble_type_priority'] . "<input type=hidden name=trouble_type_priority value=" . $info['trouble_type_priority'] . " size='1' maxlength='1' /> </td>"; echo "<td align='center'>" . $info['category_1'] . "<input type=hidden name=category_1 value=" . $info['category_1'] . "' /> </td>"; echo "<td align='center'>" . $info['category_2'] . "<input type=hidden name=category_2 value=" . $info['category_2'] . "' /> </td>"; echo "<td align='center'>" . $info['status'] . "<input type=hidden name=status value=" . $info['status'] . "' /> </td>"; echo "</tr>"; echo "</form>"; } } echo "</table>"; echo "<table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'> <tr> <th colspan='3' align='center'>Total</th> <th> </th> <th> </th> <th> </th> </tr>"; echo "</table>";
  25. I am moving my site and database to a new server. The configuration is nearly the same except the new server is 64bit. I can connect to the database remotely with the username and password that I have in my php code to connect. Here is my database connect code: <?php $serverName = 'Nick_C_Desktop\SQLEXPRESS'; $connectionInfo = array('Database'=>'CSLogs', 'UID'=>'cslogslogin', 'PWD'=>'123456'); $connection = sqlsrv_connect($serverName, $connectionInfo); ?> This code worked perfectly fine on my old server, but gives me this error: Fatal error: Call to undefined function sqlsrv_connect() in C:\wamp\www\cslogs\includes\db_connect.php on line 4 I have these two items in my php.ini file enabled: extension=php_pdo_sqlsrv_53_ts.dll extension=php_sqlsrv_53_ts.dll Which is what I had before. Using Wamp Server. PHP 5.3.13 all the same as before. What else am I missing that is not allowing this to connect to the SQL server. Thanks in advance!
×
×
  • 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.