Jump to content

Barand

Moderators
  • Posts

    24,566
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. You can't just echo $im to view the image, you need to send a type header then output it with imagejpeg() $im = imagecreatefromjpeg('my_image.jpg'); // output the image header("Content-type: image/jpeg"); imagejpeg($im);
  2. The format I produced was the same as the format in the link you posted, that is $('.table').footable({ "columns": [{"name":"col1", "title": "Col 1"}, {"name":"col2", "title": "Col 2"} ], "rows": [{"col1":"abc", "col2":"def"}, {"col1":"ghi", "col2":"jkl"}, {"col1":"ghi", "col2":"jkl"}, {"col1":"ghi", "col2":"jkl"}, {"col1":"ghi", "col2":"jkl"}] }); If that isn't what you need then you need to tell us what is - no more guessing.
  3. 1 ) the bit before the => is the key, the bit following the => is the value. 2 ) Yes, associative 2b) indexed, or numeric, arrays 2c) But they can be mixed, for example $arr = [ 'This is a key' => 'This is a value', 42 => 'second value', 'Third value' ]; echo $arr['This is a key'] . '<br>'; echo '<pre>', print_r($arr, 1), '</pre>'; which outputs This is a value Array ( [This is a key] => This is a value [42] => second value [43] => Third value ) 3 ) I think the above example answers that.
  4. You're in luck - it didn't time out on me this time <?php $text = file_get_contents('http://86.60.161.24'); echo "<pre>$text</pre>"; ?> Outout analog input 0 is 556 analog input 1 is 465 analog input 2 is 424 analog input 3 is 228 analog input 4 is 364 analog input 5 is 310
  5. I am not psychic. Only you currently know what sequence you want. Only you know which column you would need to sort on to get that desired sequence (and if such a column even exists). Here's a start... SELECT * -- DON'T use *, specify the columns you want. , news.id as nid FROM news LEFT JOIN category ON category.id=news.catid ORDER BY ??????????????????? LIMIT $lim OFFSET $offset;
  6. If I just get the records from my user table they appear in the order they are stored SELECT user_id , firstname , lastname , username , dob FROM user; +---------+-----------+----------+----------+------------+ | user_id | firstname | lastname | username | dob | +---------+-----------+----------+----------+------------+ | 1 | Peter | Dowt | peterd | 2009-12-21 | | 2 | Laura | Norder | lauran | 2010-10-22 | | 3 | Tom | DiCanari | tomd | 2007-10-24 | | 4 | Scott | Chegg | cheggs | 2008-03-08 | | 5 | Polly | Vinyl | pollyv | 2010-12-15 | | 6 | Polly | Styrene | pollys | 2005-08-20 | | 7 | Tom | Catt | tomc | 2011-02-17 | +---------+-----------+----------+----------+------------+ However, I want to list then in order of their dates of birth (dob column) so add an order by clause to the query SELECT user_id , firstname , lastname , username , dob FROM user ORDER BY dob; +---------+-----------+----------+----------+------------+ | user_id | firstname | lastname | username | dob | +---------+-----------+----------+----------+------------+ | 6 | Polly | Styrene | pollys | 2005-08-20 | | 3 | Tom | DiCanari | tomd | 2007-10-24 | | 4 | Scott | Chegg | cheggs | 2008-03-08 | | 1 | Peter | Dowt | peterd | 2009-12-21 | | 2 | Laura | Norder | lauran | 2010-10-22 | | 5 | Polly | Vinyl | pollyv | 2010-12-15 | | 7 | Tom | Catt | tomc | 2011-02-17 | +---------+-----------+----------+----------+------------+
  7. OK, I've done that. What next?
  8. Plan B, giving { "columns":[{"name":"id","title":"id"}, {"name":"firstname","title":"firstname"}, {"name":"lastname","title":"lastname"}], "rows":[{"id":1,"firstname":"Peter","lastname":"Dowt"}, {"id":2,"firstname":"Laura","lastname":"Norder"}, {"id":3,"firstname":"Tom","lastname":"DiCanari"}] } Code $mydata = []; $cols = []; $rows = []; $data = $pdo -> query('SELECT user_id as id , firstname , lastname FROM user LIMIT 3 '); $row = $data->fetch(PDO::FETCH_OBJ); $keys = array_keys((array)$row); foreach ($keys as $key) { $cols[] = (object)[ 'name'=>$key, 'title'=>$key ]; } do { $rows[] = $row; } while ($row = $data->fetch(PDO::FETCH_OBJ)); $mydata['columns'] = $cols; $mydata['rows'] = $rows; echo json_encode($mydata);
  9. I take it that's a "No".
  10. Your link times out when I try to access via my browser.
  11. Is this close to what you want? $mydata = []; $cols = []; $rows = []; $data = $pdo -> query('SELECT user_id as id , firstname , lastname FROM user '); $row = $data->fetch(); $cols = array_keys($row); do { $rows[] = array_values($row); } while ($row = $data->fetch()); $mydata['columns'] = $cols; $mydata['rows'] = $rows; echo json_encode($mydata); givng $mydata = Array ( [columns] => Array ( [0] => id [1] => firstname [2] => lastname ) [rows] => Array ( [0] => Array ( [0] => 1 [1] => Peter [2] => Dowt ) [1] => Array ( [0] => 2 [1] => Laura [2] => Norder ) [2] => Array ( [0] => 3 [1] => Tom [2] => DiCanari ) ) ) JSON... {"columns":["id","firstname","lastname"],"rows":[[1,"Peter","Dowt"],[2,"Laura","Norder"],[3,"Tom","DiCanari"]]}
  12. Have you the correct fopen wrappers enabled? see https://www.php.net/manual/en/function.fopen.php
  13. Or, as the OP is using mysqli print_r($conn->error_list); However a better way is to set mysql error reporting when you make the connection to the server EG mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $conn = mysqli_connect(HOST,USERNAME,PASSWORD,DATABASE); $conn->set_charset('utf8'); If using PDO (recommended) the equivalent is to set the errmode option on connecting $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  14. I can't see a single mention of date_format() in that link. It advocates the use of str_to_date(), which is what my solution used. That still leaves the question of your solution using date_format().
  15. Erm, You need to use mysql error reporting to see that error, not PHP error reporting.
  16. Set thumbnail to what?
  17. What error is it giving? Care to share? When I run your code it outputs
  18. To get the records you highlighted SELECT id , tablex FROM lovetree LIMIT 9, 11; i.e. LIMIT offset, num_recs However, you probably meant LIMIT 10, 10 but I can only guess.
  19. Maybe, but only if the first 10 don't exist ??? - who can tell?
  20. How can that situation even be possible? @DisplayError If you tell us what you are trying to do in a clear, logical manner then we can probably help. Otherwise you're on your own.
  21. It would be nice to see your solution using date_format(). Are you talking about PHP's date_format function or SQL's function?
  22. What are you expecting the code to do? Why do think there is an error?
  23. There's a clue in the manual. TIP: try reading it occasionally, such as when you use a function and you have no idea what it does.
  24. If your cUrl postfields are hard-coded with the username and password, why are you sending them from the ajax call in the POST data?
  25. If we do a slightly different query SELECT pd.id , pd.enterprise , pd.as400_ship_date , pd.hold_date , ps.order_id , ps.dept_code , ps.status_id FROM production_data pd LEFT JOIN production_status ps ON ps.order_id = pd.id AND ps.dept_code = 13 AND ps.status_id = 3 WHERE pd.enterprise = "EXXON" AND pd.as400_ship_date = '2021-03-02' AND pd.hold_date = "0000-00-00"; +-------+------------+-----------------+------------+----------+-----------+-----------+ | id | enterprise | as400_ship_date | hold_date | order_id | dept_code | status_id | +-------+------------+-----------------+------------+----------+-----------+-----------+ | 15298 | EXXON | 2021-03-02 | 0000-00-00 | 15298 | 13 | 3 | | 15154 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15156 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15157 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15158 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15290 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15291 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15292 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15293 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15294 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15296 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15297 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15299 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15300 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15301 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15302 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15303 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 15304 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16589 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16590 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16593 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16594 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16597 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16598 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16601 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16602 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16605 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16606 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16609 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16610 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16613 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | | 16614 | EXXON | 2021-03-02 | 0000-00-00 | NULL | NULL | NULL | +-------+------------+-----------------+------------+----------+-----------+-----------+ 32 rows in set (0.00 sec) Becasue it uses a LEFT JOIN, we get nulls where there was no matching record meeting the join criteria. These are the ones we want to count hence the ps.order_id IS NULL
×
×
  • 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.