-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Help with getting Search Form to search within...
Barand replied to Chrisj's topic in PHP Coding Help
Getta better checker. When using wildcard (%) characters in a search, you need to use LIKE (not = ) Also, I would have thought the subcategory value in your search would be the same one that was selected to get you to that page, not the same as the other search values. Although not an error, you should be using prepared queries and not put variables in the query string. -
CSS <h1> & <p> class problem. Line changing/spacing
Barand replied to PeterBubresko's topic in CSS Help
Sorry about that poor advice. I didn't spot the warning in my IDE about improperly nested tags until after after I'd posted. <style type='text/css'> span.headline { font-size: 20pt; font-weight: 400; } </style> <body> <p><span class='headline'>Hello</span> World</p> </body> -
Help with getting Search Form to search within...
Barand replied to Chrisj's topic in PHP Coding Help
Getting your query syntax correct would be a good start. -
Little function like If $variable == 0 then echo "--"
Barand replied to paulmagm's topic in PHP Coding Help
if it is zero do this else do this endif Perhaps you should check if it's 0 then output according to the result of that check. -
CSS <h1> & <p> class problem. Line changing/spacing
Barand replied to PeterBubresko's topic in CSS Help
try <style type='text/css'> h1.headline { display: inline; } </style> <body> <p><h1 class='headline'>Hello</h1>World</p> </body> -
Can't you just let the users set their own system locale settings so they appear as they want. So in UK I would see 123.456 whereas someone in say, Germany, would see 123,456
-
get windows username onto a live server using php,or ajax
Barand replied to Sidhu's topic in PHP Coding Help
Don't post the same question every 30 minutes - once is enough. Closing this one. -
Or use LDAP. There's an excellent ADLDAP class available to assist.
-
Try these links https://www.php.net/substr https://www.php.net/strlen https://www.php.net/str_replace https://www.php.net/isset https://www.php.net/intval
-
You want us to help you to pass off a piece of code that you found as your work so you can submit it as your homework assignment?
-
That was not stated in your question. Deal with it. I've given you the basics - work on it. If you know which pets are in there, you stand a chance. If you don't, you are going to need another way to identify the text portions you want.
-
No loop required $text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus cat lectus malesuada libero, sit amet commodo magna eros quis urna. "; $srch = 'cat'; $p1 = strpos($text, $srch, 0); // find position of 'cat' if ($p1===false) die("'$srch' not found"); echo "$srch found at pos $p1<br>"; $p2 = strpos($text, '.', $p1); // find position of '.' following 'cat' echo substr($text, $p1, $p2-$p1+1); // get text beteen those points.
-
If you can use fixed value range offsets for gmp and ewt (in this example they are gmp ± 0.4, ewt ± 9 ) then extra tables not required mysql> SELECT gpm, ewt -> FROM uniluxmodel -> WHERE gpm BETWEEN 1.75 - 0.4 AND 1.75 + 0.4 -> AND ewt BETWEEN 35 - 9 AND 35 + 9; +------+------+ | gpm | ewt | +------+------+ | 1.50 | 30 | | 1.50 | 40 | | 2.00 | 30 | | 2.00 | 40 | +------+------+
-
As you have told us nothing about the file or the portion you want from it, how do you expect us to help you? Why is your data stored in a php file, especially as you apparently need to use it elsewhere?
-
Plan D, staying with ranges but setting the lo/hi of range to extend from the value below to the value above gpm_range ewt_range; +------+--------+--------+ +-----+--------+--------+ | gpm | gpm_lo | gpm_hi | | ewt | ewt_lo | ewt_hi | +------+--------+--------+ +-----+--------+--------+ | 1.00 | 0.00 | 1.25 | | 30 | 0 | 40 | | 1.25 | 1.00 | 1.50 | | 40 | 30 | 50 | | 1.50 | 1.25 | 2.00 | | 50 | 40 | 60 | | 2.00 | 1.50 | 3.00 | | 60 | 50 | 70 | +------+--------+--------+ | 70 | 60 | 80 | | 80 | 70 | 90 | +-----+--------+--------+ then SELECT DISTINCT gpm.gpm , ewt.ewt FROM ( SELECT u.gpm FROM uniluxmodel u JOIN ( SELECT gpm FROM gpm_range WHERE 1.75 BETWEEN gpm_lo AND gpm_hi ) g USING (gpm) ) gpm JOIN ( SELECT u.ewt FROM uniluxmodel u JOIN ( SELECT ewt FROM ewt_range WHERE 35 BETWEEN ewt_lo AND ewt_hi ) e USING (ewt) ) ewt; +------+------+ | gpm | ewt | +------+------+ | 1.50 | 30 | | 2.00 | 30 | | 1.50 | 40 | | 2.00 | 40 | +------+------+
-
Perhaps if you referenced the manual occasionally you would know exactly what it returns and why it's the wrong function. readfile() file_get_contents() file()
-
-
If the user enters a gpm value between 1.37 and 1.74, then the record with a gpm of 1.5 is selected. If the user didn't enter 1.5 it is flagged with an * as not being an exact match. gpm_range +------+--------+--------+ | gpm | gpm_lo | gpm_hi | +------+--------+--------+ | 1.00 | 0.01 | 1.11 | | 1.25 | 1.12 | 1.36 | | 1.50 | 1.37 | 1.74 | | 2.00 | 1.75 | 2.99 | +------+--------+--------+ Same with other values, the record with closest matches being returned.
-
No, you really don't. That is path to disaster in a relational database where entities are related by their ids. As a rule, don't change, delete or re-use ids.
-
It looks like your $AFC/$NFC array keys are not 0-based, as they need to be, so $AFC[0] and $NFC[0] do not exist. (It should be throwing out messages to that effect - are you reporting your errors?) Try $AFC = array_values($AFC); $NFC = array_values($NFC); just before the loop to update the matrix table.
-
I used your "create table" this time then ran exactly the same code again $AFC = [3,6,5,9,7,8,4,2,0,1]; $NFC = [3,8,5,7,6,4,9,1,2,0]; $query = $db->prepare("UPDATE VNSB21_squares_matrix SET nfc = ? , afc = ? WHERE square = ? "); $query->bind_param('iii', $n, $a, $i); for ($i=0; $i<100; $i++) { $a = $AFC[intdiv($i, 10)]; $n = $NFC[$i%10]; $query->execute(); } mysql> select * from vnsb21_squares_matrix; +--------+------+------+------+ +--------+------+------+------+ +--------+------+------+------+ | SQUARE | NAME | NFC | AFC | | SQUARE | NAME | NFC | AFC | | SQUARE | NAME | NFC | AFC | +--------+------+------+------+ +--------+------+------+------+ +--------+------+------+------+ | 00 | A | 3 | 3 | | 34 | AI | 6 | 9 | | 68 | BQ | 2 | 4 | | 01 | B | 8 | 3 | | 35 | AJ | 4 | 9 | | 69 | BR | 0 | 4 | | 02 | C | 5 | 3 | | 36 | AK | 9 | 9 | | 70 | BS | 3 | 2 | | 03 | D | 7 | 3 | | 37 | AL | 1 | 9 | | 71 | BT | 8 | 2 | | 04 | E | 6 | 3 | | 38 | AM | 2 | 9 | | 72 | BU | 5 | 2 | | 05 | F | 4 | 3 | | 39 | AN | 0 | 9 | | 73 | BV | 7 | 2 | | 06 | G | 9 | 3 | | 40 | AO | 3 | 7 | | 74 | BW | 6 | 2 | | 07 | H | 1 | 3 | | 41 | AP | 8 | 7 | | 75 | BX | 4 | 2 | | 08 | I | 2 | 3 | | 42 | AQ | 5 | 7 | | 76 | BY | 9 | 2 | | 09 | J | 0 | 3 | | 43 | AR | 7 | 7 | | 77 | BZ | 1 | 2 | | 10 | K | 3 | 6 | | 44 | AS | 6 | 7 | | 78 | CA | 2 | 2 | | 11 | L | 8 | 6 | | 45 | AT | 4 | 7 | | 79 | CB | 0 | 2 | | 12 | M | 5 | 6 | | 46 | AU | 9 | 7 | | 80 | CC | 3 | 0 | | 13 | N | 7 | 6 | | 47 | AV | 1 | 7 | | 81 | CD | 8 | 0 | | 14 | O | 6 | 6 | | 48 | AW | 2 | 7 | | 82 | CE | 5 | 0 | | 15 | P | 4 | 6 | | 49 | AX | 0 | 7 | | 83 | CF | 7 | 0 | | 16 | Q | 9 | 6 | | 50 | AY | 3 | 8 | | 84 | CG | 6 | 0 | | 17 | R | 1 | 6 | | 51 | AZ | 8 | 8 | | 85 | CH | 4 | 0 | | 18 | S | 2 | 6 | | 52 | BA | 5 | 8 | | 86 | CI | 9 | 0 | | 19 | T | 0 | 6 | | 53 | BB | 7 | 8 | | 87 | CJ | 1 | 0 | | 20 | U | 3 | 5 | | 54 | BC | 6 | 8 | | 88 | CK | 2 | 0 | | 21 | V | 8 | 5 | | 55 | BD | 4 | 8 | | 89 | CL | 0 | 0 | | 22 | W | 5 | 5 | | 56 | BE | 9 | 8 | | 90 | CM | 3 | 1 | | 23 | X | 7 | 5 | | 57 | BF | 1 | 8 | | 91 | CN | 8 | 1 | | 24 | Y | 6 | 5 | | 58 | BG | 2 | 8 | | 92 | CO | 5 | 1 | | 25 | Z | 4 | 5 | | 59 | BH | 0 | 8 | | 93 | CP | 7 | 1 | | 26 | AA | 9 | 5 | | 60 | BI | 3 | 4 | | 94 | CQ | 6 | 1 | | 27 | AB | 1 | 5 | | 61 | BJ | 8 | 4 | | 95 | CR | 4 | 1 | | 28 | AC | 2 | 5 | | 62 | BK | 5 | 4 | | 96 | CS | 9 | 1 | | 29 | AD | 0 | 5 | | 63 | BL | 7 | 4 | | 97 | CT | 1 | 1 | | 30 | AE | 3 | 9 | | 64 | BM | 6 | 4 | | 98 | CU | 2 | 1 | | 31 | AF | 8 | 9 | | 65 | BN | 4 | 4 | | 99 | CV | 0 | 1 | | 32 | AG | 5 | 9 | | 66 | BO | 9 | 4 | +--------+------+------+------+ | 33 | AH | 7 | 9 | | 67 | BP | 1 | 4 | +--------+------+------+------+ +--------+------+------+------+ and I still couldn't get your messed up results. However, just in case your local set up isn't as tolerant as mine when it comes to matching "00" with 0, then try $AFC = [3,6,5,9,7,8,4,2,0,1]; $NFC = [3,8,5,7,6,4,9,1,2,0]; $query = $db->prepare("UPDATE VNSB21_squares_matrix SET nfc = ? , afc = ? WHERE square = ? "); $query->bind_param('iis', $n, $a, $s); for ($i=0; $i<100; $i++) { $a = $AFC[intdiv($i, 10)]; $n = $NFC[$i%10]; $s = sprintf('%02d', $i); $query->execute(); } PS - What is in your $AFC and $NFC arrays?
-
I don't know what your matrix table looks like but when I create one CREATE TABLE `squares_matrix` ( `square` int(11) NOT NULL, `name` varchar(20) DEFAULT NULL, `nfc` int(11) DEFAULT NULL, `afc` int(11) DEFAULT NULL, PRIMARY KEY (`square`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ... generate 100 rows, then run that same code I get mysql> select * from squares_matrix; +--------+------+------+------+ +--------+------+------+------+ +--------+------+------+------+ | square | name | nfc | afc | | square | name | nfc | afc | | square | name | nfc | afc | +--------+------+------+------+ +--------+------+------+------+ +--------+------+------+------+ | 0 | A | 3 | 3 | | 35 | AJ | 4 | 9 | | 69 | BR | 0 | 4 | | 1 | B | 8 | 3 | | 36 | AK | 9 | 9 | | 70 | BS | 3 | 2 | | 2 | C | 5 | 3 | | 37 | AL | 1 | 9 | | 71 | BT | 8 | 2 | | 3 | D | 7 | 3 | | 38 | AM | 2 | 9 | | 72 | BU | 5 | 2 | | 4 | E | 6 | 3 | | 39 | AN | 0 | 9 | | 73 | BV | 7 | 2 | | 5 | F | 4 | 3 | | 40 | AO | 3 | 7 | | 74 | BW | 6 | 2 | | 6 | G | 9 | 3 | | 41 | AP | 8 | 7 | | 75 | BX | 4 | 2 | | 7 | H | 1 | 3 | | 42 | AQ | 5 | 7 | | 76 | BY | 9 | 2 | | 8 | I | 2 | 3 | | 43 | AR | 7 | 7 | | 77 | BZ | 1 | 2 | | 9 | J | 0 | 3 | | 44 | AS | 6 | 7 | | 78 | CA | 2 | 2 | | 10 | K | 3 | 6 | | 45 | AT | 4 | 7 | | 79 | CB | 0 | 2 | | 11 | L | 8 | 6 | | 46 | AU | 9 | 7 | | 80 | CC | 3 | 0 | | 12 | M | 5 | 6 | | 47 | AV | 1 | 7 | | 81 | CD | 8 | 0 | | 13 | N | 7 | 6 | | 48 | AW | 2 | 7 | | 82 | CE | 5 | 0 | | 14 | O | 6 | 6 | | 49 | AX | 0 | 7 | | 83 | CF | 7 | 0 | | 15 | P | 4 | 6 | | 50 | AY | 3 | 8 | | 84 | CG | 6 | 0 | | 16 | Q | 9 | 6 | | 51 | AZ | 8 | 8 | | 85 | CH | 4 | 0 | | 17 | R | 1 | 6 | | 52 | BA | 5 | 8 | | 86 | CI | 9 | 0 | | 18 | S | 2 | 6 | | 53 | BB | 7 | 8 | | 87 | CJ | 1 | 0 | | 19 | T | 0 | 6 | | 54 | BC | 6 | 8 | | 88 | CK | 2 | 0 | | 20 | U | 3 | 5 | | 55 | BD | 4 | 8 | | 89 | CL | 0 | 0 | | 21 | V | 8 | 5 | | 56 | BE | 9 | 8 | | 90 | CM | 3 | 1 | | 22 | W | 5 | 5 | | 57 | BF | 1 | 8 | | 91 | CN | 8 | 1 | | 23 | X | 7 | 5 | | 58 | BG | 2 | 8 | | 92 | CO | 5 | 1 | | 24 | Y | 6 | 5 | | 59 | BH | 0 | 8 | | 93 | CP | 7 | 1 | | 25 | Z | 4 | 5 | | 60 | BI | 3 | 4 | | 94 | CQ | 6 | 1 | | 26 | AA | 9 | 5 | | 61 | BJ | 8 | 4 | | 95 | CR | 4 | 1 | | 27 | AB | 1 | 5 | | 62 | BK | 5 | 4 | | 96 | CS | 9 | 1 | | 28 | AC | 2 | 5 | | 63 | BL | 7 | 4 | | 97 | CT | 1 | 1 | | 29 | AD | 0 | 5 | | 64 | BM | 6 | 4 | | 98 | CU | 2 | 1 | | 30 | AE | 3 | 9 | | 65 | BN | 4 | 4 | | 99 | CV | 0 | 1 | | 31 | AF | 8 | 9 | | 66 | BO | 9 | 4 | +--------+------+------+------+ | 32 | AG | 5 | 9 | | 67 | BP | 1 | 4 | | 33 | AH | 7 | 9 | | 68 | BQ | 2 | 4 | | 34 | AI | 6 | 9 | +--------+------+------+------+ +--------+------+------+------+