Jump to content

Barand

Moderators
  • Posts

    24,573
  • Joined

  • Last visited

  • Days Won

    824

Everything posted by Barand

  1. Any chance of the full XML? That doesn't seem to match up with your processing.
  2. If, for other purposes, you require all records to be in the array then you can filter the records when you process them to gat those with a required status value EG $status_filter = function ($v) use ($required) { return in_array($v['job_status'], $required); }; foreach (array_filter($projects, $status_filter) as $proj) { // process $proj }
  3. Use an array to get the ones you want... $projects = array(); $required = ['Feasibility', 'Measure Up', 'Model Drawing', 'Concept Design', 'Developed Design', 'Resource Consent', 'Construction Documentation' ]; $xml=simplexml_load_string($response) or die("Error: Cannot create object"); foreach($xml->Jobs->Job as $item) { if (in_array((string)$item->State, $required)) { $projects[] = array( 'job_no' => (string)$item->ID, 'job_name' => (string)$item->Name, 'job_due' => (string)$item->DueDate, 'job_status' => (string)$item->State, 'job_staff' => (string)$item->Assigned->Staff->Name, ); } } usort($projects, function($a,$b) {return $b['job_due'] <=> $a['job_due']; } ); // reverse $a and $b for desc sort // $projects = array_reverse($projects); // no longer required This code is just plain wrong... while ($projects['job_status'] == ('Feasibility') && ('Measure Up') && ('Model Drawing') && ('Concept Design' ) && ('Developed Design' ) && ('Resource Consent' ) && ('Construction Documentation')) { and this is a waste of time and effort. Why just move a value from one variable to another and why put a single string variable inside quotes? $formatted = date('d/m/Y', strtotime($proj['job_due'])); $job_no ="{$proj['job_no']}"; $job_name ="{$proj['job_name']}"; $job_due ="$formatted"; $job_status ="{$proj['job_status']}"; $job_staff ="{$proj['job_staff']}";
  4. If your calc sheet looks like this then File/Save As... select CSV as the file type and save should give this Date,Title,Text 01/01/2019,Lukas:16:19,"Es war ein reicher Mann, der kleidete sich in Purpur und kostbares Leinen" 01/02/2019,Kolosser:3:13,Ertrage einer den andern und vergebt euch untereinander 01/03/2019,1.Petrus:5:10,"Der Gott aller Gnade, der euch berufen"
  5. If you are constrained to three columns, I'd go with Date | Book:chapter:verse | Text and I'd put the data into a conventional CSV format that can be opened directly by Excel - EG "01/01/19","Lukas:16:19","Es war ein reicher Mann, der kleidete sich in Purpur und kostbares Leinen" "01/02/19","Kolosser:3:13","Ertrage einer den andern und vergebt euch untereinander" "01/03/19","1.Petrus:5:10","Der Gott aller Gnade, der euch berufen"
  6. I see five distinct data items +----------+------------+-----------+---------+-----------------------------------------------------------------------------+ | Date | Book | Chapter | Verse | Text | +----------+------------+-----------+---------+-----------------------------------------------------------------------------+ | 01/01/19 | Lukas | 16 | 19 | Es war ein reicher Mann, der kleidete sich in Purpur und kostbares Leinen | | 01/02/19 | Kolosser | 3 | 13 | Ertrage einer den andern und vergebt euch untereinander` | | 01/03/19 | 1. Petrus | 5 | 10 | Der Gott aller Gnade, der euch berufen` | +----------+------------+-----------+---------+-----------------------------------------------------------------------------+
  7. If your connection fails then $link is not a valid connection value - so you cannot use mysqli_error($link) which requires a valid $link argument. I told you what to use instead some days ago. Read the replies if you can't read the manual.
  8. https://www.php.net/manual/en/mysqli.connect-error.php
  9. @Franz123 It would have been preferred, and a lot simpler, for you just to post a link to the HostPapa site article on Filezilla
  10. $rules does not exist prior to $rules = $resortPro->ssml_routes_for_search_results_pages(); so no point putting it before that line.
  11. The first thing to do is var_dump($rules); It should be an array. If it isn't then you need to invstigate why $resortPro->ssml_routes_for_search_results_pages() isn't returning an array.
  12. Even with unique constraints on username and on email, without restrictions on usernames you could potentially have this situation +------------+---------------+-----------------+------------------+ | Emp ID | Username | Email | Password | +------------+---------------+-----------------+------------------+ | 1 | [email protected] | [email protected] | s3cr3t | | 2 | [email protected]| [email protected] | s3cr3t | +------------+---------------+-----------------+------------------+ Your query would then find both employees Also, many companies use the convention that an employee's email address is <username> @ <domainname> The presence of @ in the username would render the address invalid.
  13. All you have so far is a string variable containing SQL code, so you are missing a few things. (You whould also be using a prepared query when using data from an external source such as GET or POST) You need to Connect to the mysql server (mysqli_connect) Prepare the query (mysqli_prepare) Bind the parameter (mysqli_stmt_bind_param) Execute the query. (mysqli_stmt_execute) [EDIT] Plus I think you may need some quotes in your ajax parameters data: { "itemid":itemID, "clear":1 },
  14. Post code we can read instead of redacted text and someone might look at it.
  15. Compare your $update->execute with mine.
  16. $attribute would be the key and $label would be the value $taxonomy_of_interest[$attribute] = $label;
  17. v5.6 equivalent would be $reset = isset($_POST['reset'][$id]) ? $_POST['reset'][$id] : 0;
  18. The script is using PDO, not mysqli "??" is a PHPv7 operator
  19. One way would be to use the $headings array. Provide a translation for all those you want to include and ignore those that are not in the array. You could also think about extending that array to provide the sequence for attribute output,
  20. Attribute which are arrays (like "image" are ignored, as are attributes with no values. Where no heading translation is provided the raw attribute name is output. <?php $headings = [ 'attribute_pa_pack-quantity' => 'Pack&nbsp;Qty', 'attribute_pa_variation' => 'Variation', 'sku' => 'SKU', 'variation_description' => 'Var&nbsp;Desc', 'variation_id' => 'Id', 'price_html' => 'Price' ]; $systems = []; foreach ($variations as $var) { $atts = array_values($var['attributes']); $key = $atts[0]; $kv = count($var); $ka = count($var['attributes']); if (!isset($systems[$key])) { $systems[$key] = []; } $systems[$key][] = array_merge(array_slice($var['attributes'], 1, $ka-1, 1), array_slice($var, 1, $kv-1, 1)); } echo '<pre>', print_r($systems, 1), '</pre>'; ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Example</title> <style type='text/css'> body { font-family: calibri, sans-serif; font-size: 10pt; } .system { width: 30%; float: left; margin-right: 30px; } .item { padding: 5px; margin-bottom: 15px; } .hdg { display: inline-block; width: 150px; font-weight: 600; } </style> </head> <body> <?php foreach ($systems as $sys => $sdata) { echo "<div class='system'><h3>$sys</h3>\n"; foreach ($sdata as $item) { echo "<div class='item'>\n"; foreach ($item as $h => $v) { if ($v && !is_array($v)) { $hd = $headings[$h] ?? $h; // use attribute key if no translation available echo "<div class='hdg'>{$hd}</div>$v<br>\n"; } } echo "</div>\n"; } echo "</div>\n"; } ?> </body> </html>
  21. No need to apologise. You are the one who is going to be adapting the sample code I gave you so it does what you really want to do.
  22. Looks like I missed mine from my code $headings = [ 'attribute_pa_pack-quantity' => 'Pack&nbsp;Qty', 'attribute_pa_variation' => 'Variation', 'sku' => 'SKU', 'variation_description' => 'Var&nbsp;Desc', 'variation_id' => 'Id', 'price_html' => 'Price' ];
  23. It seems to have $headings[$h] as an array. What does your $headings array look like?
  24. This should get you on your way <?php $systems = []; foreach ($variations as $var) { $atts = array_values($var['attributes']); $key = $atts[0]; $kv = count($var); $ka = count($var['attributes']); if (!isset($systems[$key])) { $systems[$key] = []; } $systems[$key][] = array_merge(array_slice($var['attributes'], 1, $ka-1, 1), array_slice($var, 1, $kv-1, 1)); } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Example</title> <style type='text/css'> body { font-family: calibri, sans-serif; font-size: 10pt; } .system { width: 25%; float: left; margin-right: 30px; } .item { padding: 5px; margin-bottom: 15px; } .hdg { display: inline-block; width: 80px; font-weight: 600; } </style> </head> <body> <?php foreach ($systems as $sys => $sdata) { echo "<div class='system'><h3>$sys</h3>\n"; foreach ($sdata as $item) { echo "<div class='item'>\n"; foreach ($item as $h => $v) { if ($v) { echo "<div class='hdg'>{$headings[$h]}</div>$v<br>\n"; } } echo "</div>\n"; } echo "</div>\n"; } ?> which gives
×
×
  • 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.