Jump to content

unistake

Members
  • Content Count

    445
  • Joined

  • Last visited

Community Reputation

0 Neutral

About unistake

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  1. Cheers mac_gyver, Fortunately I was thinking along those lines. So far I have the code below however I do not know how to store my matched queries in a multidimensional array indexed firstly by $row['Code'] and then by $row['SectorDate'] as you mentioned. This is the code I have so far: <table class=""> <thead> <tr> <th> </th> <?php // Set timezone date_default_timezone_set('UTC'); // Start date $date = date("Y-m-d"); // End date $end_date = date ("Y-m-d", strtotime("+30 days", strtotime($date))); while (strtotime($date) <= strtotime($end_date)) { echo "<th>".date("D", strtotime($date))."<br />".date("d M", strtotime($date))."</th>"; $date = date ("Y-m-d", strtotime("+1 day", strtotime($date))); } ?> </tr> </thead> <tbody> <?php $today = '2016-05-18'; $sql = "SELECT rosters.Code,rosters.SectorDate,rosters.Duty,rosters.BeginTime,rosters.Dep,rosters.Arr,rosters.EndTime,Users.Ffname FROM rosters INNER JOIN Users ON rosters.Code = Users.Code WHERE Users.Base = 'DUB' AND rosters.SectorDate BETWEEN '2016-05-18' AND '2016-05-28' ORDER BY rosters.Code"; $result = mysqli_query($cxn,$sql) or die($cxn->error); while($row=mysqli_fetch_array($result)) { foreach($row as $key=>$value) { echo $key.' '.$value.'<br />'; } echo '<p> </p>'; } ?> </tbody> </table>
  2. I just need to show about 30 days in advance. So there will not be too a huge amount of rows to extract data from. A few hundred.. I have tried writing the script but I know it is far past my experience so far. Without even considering code, I cant think logically how this would work so I can attempt the right way to do it with php!
  3. Hi all, I have some data in a table to do with 20 users appointments every day for a month. I am trying to organise the appointments in to a large table so the clients can see all the appointments of every colleague by date (in columns) and by user name (in rows). for example: 20th May | 21st May | 22nd May | 23rd May Mike Jones London, Paris | Paris, Rome | Rome, London | London, New York 06:15 - 10:15 | 08:20 - 14:00 | 03:30-05:30 | 05:25-09:30 ----------------------------------------------------------------------------------------------------------------------------------------- Bethan Cray OFF | Belfast, Madrid | Madrid, Fez | Fez, Athens 11:15 - 16:35 | 08:45 - 12:10 | 13:55-15:30 | 09:25-13:20 The data is currently stored in the mysql table such as below, and has over 40 users with over 30 rows each in the same format. SectorDate Code BeginTime Dep Arr EndTime 2016-05-20 Mike Jones 06:15 London Paris 10:15 2016-05-21 Mike Jones 08:20 Paris Rome 14:00 2016-05-20 Bethan Cray 11:15 OFF 16:35 Please can someone show how best to arrange the mysql database to give the output above! Thanks
  4. hi requinix, Thanks for that. Actually there may well be multiple rows for each Code/SectorDate pair however its not guaranteed.
  5. Hi all, I am trying to make a list of users where two rows in a mysql database exist. My attempt so far: "SELECT * FROM mail_list INNER JOIN rosters ON mail_list.Code = rosters.Code WHERE rosters.SectorDate = '2016-01-04' AND EXISTS (SELECT * FROM rosters WHERE rosters.SectorDate = '2016-01-24' IS NOT NULL)" So basically, I want to select all the users information from mail_list table only if in the rosters table the user has a row that exists with the date 2016-01-04 and a second row 2016-01-24. I have tried several types of EXIST statements as above but no luck so far :/ Please help!! Thanks
  6. works a treat! thanks!! if (is_null($coldest) || $temp < $coldest) { $coldest_loc = $row['Name']; $coldest = $temp; } if (is_null($hottest) || $temp > $hottest) { $hottest_loc = $row['Name']; $hottest = $temp; }
  7. thanks for removing my id! sorry i just need the location and the temperature from the xml. Edit: I could just link the $row['Name'] to the temperature value though, i guess.
  8. I am using a weather XML from openweathermap to get the hottest and coldest location according to the locations found in a php query. The php query below works fine but i know the way I am trying to sort the array values is not working. I presume because it is multiple arrays. The output I got when printing the full array content previously was: Array ( [0] => SimpleXMLElement Object ( [0] => 9.29 ) [1] => SimpleXMLElement Object ( [0] => 11.37 ) [2] => SimpleXMLElement Object ( [0] => 13 ) [3] => SimpleXMLElement Object ( [0] => 14 ) [4] => SimpleXMLElement Object ( [0] => 8 ) [5] => SimpleXMLElement Object ( [0] => 13.81 ) [6] => SimpleXMLElement Object ( [0] => 19.84 ) [7] => SimpleXMLElement Object ( [0] => 22 ) ) <?php session_start(); include_once("cxn.inc"); $today = date("Y-m-d H:i:s"); $sql = "SELECT airports.Name,airports.Country FROM airports INNER JOIN rosters ON airports.IATA = rosters.Arr WHERE rosters.Code = '$code' AND rosters.SectorDate >= '$today'"; $result = mysqli_query($cxn,$sql) or die ($cxn->error); $hottest = array(); while($row=mysqli_fetch_assoc($result)) { $link = 'http://api.openweathermap.org/data/2.5/weather?q='.$row['Name'].','.$row['Country'].'&units=metric&mode=xml&appid=*'; /* WEATHER API */ $xml=simplexml_load_file("$link") or die ("Cannot create object."); $hottest[] = $xml->temperature[value]; } asort($hottest); // attempting to sort $hottest array by numerical value order /// OUTPUT GOAL /// echo reset($hottest); // coldest value echo '<br />'; echo end($hottest); // hottest value ?>
  9. yes! I have got confused as its not something I have attempted before and tried to mix multiple scripts found on other sites.
  10. Yes it's from XML. I have so far, <?php $sql = "SELECT * FROM airports GROUP BY airports.IATA ORDER BY Longitude + 0 DESC"; $result = mysqli_query($cxn,$sql) or die ($cxn->error); $hottestcoldest = array(); while($row=mysqli_fetch_assoc($result)) { $xml=simplexml_load_file("$link") or die("Error: Cannot create object"); $hottestcoldest[$row['Name']] = $xml->temperature[value]; } $new = array(); foreach ($hottestcoldest as $key => $item) { $new[] = $item; } asort($new); echo reset($new).' coldest <br />'; echo end($new. ' hottest'; ?> EDIT: I guess there is a much better way to try and do it!
  11. Hi all, I currently have an array that is shown like this when I use print_r(array_values($temperature)); Array ( [0] => SimpleXMLElement Object ( [0] => 9.29 ) [1] => SimpleXMLElement Object ( [0] => 11.37 ) [2] => SimpleXMLElement Object ( [0] => 13 ) [3] => SimpleXMLElement Object ( [0] => 14 ) [4] => SimpleXMLElement Object ( [0] => 8 ) [5] => SimpleXMLElement Object ( [0] => 13.81 ) [6] => SimpleXMLElement Object ( [0] => 19.84 ) [7] => SimpleXMLElement Object ( [0] => 22 ) ) I want to find the highest and lowest value from the above array such as here 8 is the lowest and 22 being the highest value. I am not sure how I can order the array inside an array to do this. Thanks
  12. sql_big_selects was OFF. You mean to set the big selects to 1 before my php query i am trying to get working?
  13. max_join_size - 33554432. There are now just over 50,000 rows in the table.
  14. I disabled the first query and still have the same error message. I am not yet sure how to put the two queries together but i do not think that is the problem.
×
×
  • 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.