-
Posts
24,566 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
or there is simple_html_dom EG include 'simple_html_dom.php'; $str = ' <body> <ul> <li> <div class="med-width-25">59 seconds ago</div> <div class="med-width-35"> <a href="/community/character/Ayarith">Ayarith</a> </div> <div class="med-width-15">Druid</div> <div class="med-width-25 med-text-right med-pr-40">32</div> </li> <li> <div class="med-width-25">54 seconds ago</div> <div class="med-width-35"> <a href="/community/character/Indirarc">Indirarc</a> </div> <div class="med-width-15">Druid</div> <div class="med-width-25 med-text-right med-pr-40">20</div> </li> </ul> </body> '; $html = new simple_html_dom(); $html->load($str); foreach ($html->find('li div a') as $a) { // find link elements that are nested inside a div inside a listitem $name = $a->plaintext; $time = $a->parent()->parent()->children(0)->plaintext; // navigate to the enclosing listitem's first div echo "<b>$name</b> - $time<br>"; } outputs Ayarith - 59 seconds ago Indirarc - 54 seconds ago
-
Soundex may not be that usefule EG mysql> SELECT SOUNDEX('meise'), SOUNDEX('meisen'); +------------------+-------------------+ | SOUNDEX('meise') | SOUNDEX('meisen') | +------------------+-------------------+ | M200 | M250 | +------------------+-------------------+ According to the MySQL manual, this could be a problem in your case Your queries won't be able to use any indexes on the table, so be prepared to start the query before you go to bed and hope it's fininshed by breakfast. title LIKE 'meise%' - this will use an index title LIKE '%meise%' - will not use index and therefor search every record. If your keywords are a list of words in a single column, they cannot be indexed.
-
Your $verrors is a string variable, not an array. I did tell you to check that! Mine is an array... $errors[] = '"field1" must have a value'; ^^ See the difference? You first defined it as an empty array but then overwrote it by assigning string variables to it instead of appending to the array (as I did)
-
Perhaps the datepicker script is looking for an input with id="cut_date"
-
I recommend you read https://www.php.net/manual/en/language.types.array.php
-
Your primary problem is that variables created in page 2 are no longer available when you go back to page 1. You need to send the values to the page and the values need to urlencode()d. Also, put your errors in an array so you notify the user of all errors once instead of continually going to and fro betwen the pages. Happily there is an http_build_query() function that is of great help here. Example <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { // was data sent from the form? $post = array_map('trim', $_POST); // remove unwanted whitespace $errors = []; if ($post['field1'] == '') { $errors[] = '"field1" must have a value'; } if ($post['field2'] == '') { $errors[] = '"field2" must have a value'; } if ($post['field3'] == '') { $errors[] = '"field3" must have a value'; } if ($errors) { // if there were errors, return to the form to inform user $post['errors'] = $errors; // also send the form values back so user doesn't have re-enter all data (sticky form) $qstr = http_build_query($post); header("Location: myform.html?$qstr"); // redirect to form with data and error messages exit; // prevent further processing of this page } // // No errors // so we can // process the // data here // header("Location: myform.html"); // return to a new form } ?> edit: PS Alternatively, do the POST processing at the top of the same page as the form.
-
https://www.php.net/manual/en/features.file-upload.multiple.php
-
getting info from api response - looping through array
Barand replied to dkmarsh99's topic in PHP Coding Help
Not the most straightforward XML structure that I have seen. Try $xml = simplexml_load_file('mydata.xml'); $data = $xml->xpath('//Row[Title="Income"]/Rows/Row[RowType="Row"]'); echo "<pre>"; foreach ($data as $row) { $type = $row->Cells->Cell[0]->Value ; $account = $row->Cells->Cell[0]->Attributes->Attribute->Value; $income = $row->Cells->Cell[1]->Value; printf('%-20s | %-40s | %10.2f<br>', $type, $account, $income); } echo "</pre>"; giving Consulting Income | 98e83040-fa3a-4185-9b9b-a49241e2bb76 | 150.32 Contract Income | 7d05a53d-613d-4eb2-a2fc-dcb6adb80b80 | 11748.96 Engineering Income | 225d8c93-251d-4a0b-9093-201acf69fe50 | 7217.29 Equipment Income | 43f518a6-558f-402a-b22d-317bd64b1566 | 7377.17 Licence Income | 1ff30343-7bb2-4402-bb8f-a0813a7fb59e | 3047.68 Other Income | b447935a-4b37-4f38-a841-fb3ae3b491e0 | 331.06 -
WHERE MATCH(title) AGAINST ("Meise*" IN BOOLEAN MODE); Using the wildcard character "*" finds both meise and meisen in the above example. Alternatively WHERE MATCH(title) AGAINST ("meise meisen");
-
Any min/max limits on hours/day/hours per week?
-
I have been following this topic (I say "following" but that is an exaggeration) and I admit I totally clueless about what the inputs to this process are what the goal of the process is what the rules are to achieve the goal and what the constraints are what T1, T2, shift3, shift4 are Apart from that...
-
it is a link to the PHP reference manual's section on arrays. Read it.
-
https://www.php.net/manual/en/language.types.array.php
-
How many topics do you intend creating for this problem? (there is already one too many).
-
Sounds a simple problem involving a couple of arrays and a loop. What have you tried so far?
-
Notice: Undefined index: driving me insane
Barand replied to Beauford2016's topic in PHP Coding Help
"In general", don't write code which relies on a variable having been previously defined without first defining that variable or checking if the variable has been defined before you attempt to reference it. -
Notice: Undefined index: driving me insane
Barand replied to Beauford2016's topic in PHP Coding Help
I assume this post is just so you can have a rant. If it were a serious request for help then you should have provided some information about the problem, the error message you are receiving and the code that is giving error Then, perhaps, someone can help. BTW, coincidentally, I used the same syntax myself earlier today (though not to that extreme without any regard for where and how the variable are to be used, and I am not happy about that $row[] in there) when setting default input values for a form -
Why so much wasted space in topic headings in default theme/grid view ? and, in same grid view using dark theme, grid columns are 100% wide insted of 25%
-
If I am understanding the question correctly, the query to populate Box 1 is SELECT DISTINCT title FROM xmas ORDER BY title; On your page, use an onchange handler to send an AJAX request which sends the title then receives the results of this second query to populate Box 2 SELECT artist FROM xmas WHERE title = ?
-
I take it that the user->asset relationship is 1 to many, but an asset can only be assigned to one user? Hence two tables. You need somethng like this $q = "SELECT t1.hid , t1.description , t2.name FROM assets t1 LEFT JOIN users t2 ON t1.uid = t2.uid WHERE t1.hid = ? "; (I'll move this to the MySQL forum)