-
Posts
24,584 -
Joined
-
Last visited
-
Days Won
826
Everything posted by Barand
-
Then you should have mentioned that at the start instead of wasting our time on a different problem. Try experimenting.
-
My code... <!DOCTYPE html> <html lang='en'> <meta charset='utf-8'> <head> <title>Example</title> <style type="text/css"> body { font-family: verdana, sans-serif; font-size: 12pt; padding: 20px; } h2 { font-variant: small-caps; text-align: center; } .chapter { width: 100%; margin-top: 20px; margin-bottom: 20px; border-bottom: 5px solid blue; text-align: center; } .head-text { display: inline; padding: 0 10px; background-color: white; font-family: gabriola, cursive; font-size: 20pt; font-style: italic; font-weight: 600; position: relative; top: +26px; } p { text-align: justify; line-height: 22px; } </style> </head> <body> <h2>Book 3</h2> <div> <div class='chapter'> <div class='head-text'> Caput vigesimum septimum </div> </div> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. </p> <p>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy. Fusce aliquet pede non pede. Suspendisse dapibus lorem pellentesque magna. Integer nulla. Donec blandit feugiat ligula. Donec hendrerit, felis et imperdiet euismod, purus ipsum pretium metus, in lacinia nulla nisl eget sapien. Donec ut est in lectus consequat. </p> <div class='chapter'> <div class='head-text'> Epilogus </div> </div> <p>Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. Aenean nec lorem. In porttitor. Donec laoreet nonummy augue. </p> </div> </body> </html>
-
If I still have the code, I'll post it. However, as you are well aware, it can sometimes take weeks to complete the labour-intensive task of answering a post.
-
Give us a clue! We need more than that if we're to help. Perhaps give examples of what you have now, and what you want
-
Why explode on comma when they too are delimited by '|||' ? If that is the case (although your example says otherwise) then you can use array_combine() to store the related values EG $p_id = "1.1.51|||1.1.51.2|||1.1.51.3|||1.1.51.4|||1.1.51.5|||1.1.51.6|||1.1.51.7|||1.1.51.8|||1.1.51.9"; $theme = 'b|||c|||d|||e|||f|||g|||h|||i|||j'; $i = explode('|||', $p_id); $t = explode('|||', $theme); $result = array_combine($i, $t); foreach ($result as $id => $theme) { echo "$id : $theme <br>"; } giviing 1.1.51 : b 1.1.51.2 : c 1.1.51.3 : d 1.1.51.4 : e 1.1.51.5 : f 1.1.51.6 : g 1.1.51.7 : h 1.1.51.8 : i 1.1.51.9 : j
-
Perhaps... $a = explode(',', '1.1.51,1.1.51.10,1.1.51.2,1.1.51.3,1.1.51.4,A,1.1.52'); echo 'original <pre> ' . print_r($a, 1) . '</pre>'; sort($a); echo 'after sort() <pre> ' . print_r($a, 1) . '</pre>'; natsort($a); echo 'after natsort() <pre> ' . print_r($a, 1) . '</pre>'; giving... original Array ( [0] => 1.1.51 [1] => 1.1.51.10 [2] => 1.1.51.2 [3] => 1.1.51.3 [4] => 1.1.51.4 [5] => A [6] => 1.1.52 ) after sort() Array ( [0] => 1.1.51 [1] => 1.1.51.10 [2] => 1.1.51.2 [3] => 1.1.51.3 [4] => 1.1.51.4 [5] => 1.1.52 [6] => A ) after natsort() Array ( [0] => 1.1.51 [2] => 1.1.51.2 [3] => 1.1.51.3 [4] => 1.1.51.4 [1] => 1.1.51.10 [5] => 1.1.52 [6] => A )
-
Php escape string with GET function issue with apostrophe
Barand replied to PNewCode's topic in PHP Coding Help
Does it work with $DB_ENCODING = 'utf8'; -
Try a ... <html> <head> </head> <body> </body> </html> ... structure instead of your pick'n'mix approach to the documant sections. (And why was this posted in PHP Coding Help forum?)
-
how to get first letter of a string in ajax response
Barand replied to shadd's topic in Javascript Help
I'd start by checking what data contains with console.log(data) -
To add a listener to an element, the element must exist. Make sure you add the listeners after the elements have been created.
-
That's the thing about programming - it does what you tell it to do. You told it to respond to clicks inside the div. Try document.getElementByTagName("input").addEventListener("click", displayDate); function displayDate() { alert('Hurray'); }
-
As you have it now but make the <select> required (to force a values other than "") <select name="cars" id="cars" required> <option value="" >Car choices</option> <option value="volvo">Volvo</option> <option value="saab">Saab</option> </select>
-
Judicious application of array key names can greatly increase the efficiency and simplicity of your code. Consider this simplified version of the questions/options form code <form method='post' > <?php for ($qno=1; $qno<=2; $qno++) { echo <<<HTML <label> Sub Question $qno <span class="req">*</span> <textarea cols="46" rows="3" name="Q[$qno][question]" placeholder="Enter Sub question here.."></textarea> </label> <ul> HTML; for ($opt='A'; $opt<='D'; $opt++) { echo <<<HTML <li>Choice $qno$opt (text) <input type='text' name="Q[$qno][opts][$opt]" placeholder="Enter Choice A here.." size='40'> </li><br><br>\n HTML; } echo "</ul><hr>\n"; } ?> <input type='submit'> </form> producing... When the form is submitted, the POST array is like this... Array ( [Q] => Array ( [1] => Array ( [question] => aaaaaaaaaaaaaaaaaaaaaaaaaaa [opts] => Array ( [A] => aa [B] => bb [C] => cc [D] => dd ) ) [2] => Array ( [question] => bbbbbbbbbbbbbbbbbbbbbbbbb [opts] => Array ( [A] => ww [B] => xx [C] => yy [D] => zz ) ) ) ) Now you can easily iterate through the array to write the questions/options to you database foreach ( $_POST['Q'] as $qno => $qdata ) { write $qno and $qdata['question'] to question table save last insert id as $qid foreach ( $qdata['opts'] as $ono => $choice ) { write $qid, $ono, $choice to choice table } } Job Done.
-
Almost 5,000 chars of unformatted html! TLDR
-
Use join() instead of the foreach loop. echo join(':', $numbers);
-
Let me introduce you to the reference manual. See https://www.php.net/mysqli_fetch_array
-
mysqli_fetch_array() does not return the number of rows To do that you would need to remove and authorized ='1' and add "authorized" to the selected columns. Then check if $num['authorized'] == 1 (or not).
-
-
You were asked...
-
Fatal error: Uncaught Error: Class "mysqli" not found in C
Barand replied to hamzi's topic in PHP Coding Help
Check phpinfo() output to ensure you are editing the php.ini file that is actually being used. If it is the right one, check you really have the extension file and in the right folder. edit... PS Check you have PDO available - you'll be better off using that than mysqli. -
Example: My customer table contains these columns Columnss ------------- syncroid State Postcode id CompanyName City Address and I want to exclude id and syncroid from the dropdown list. <?php $res = $pdo->query("SELECT column_name FROM information_schema.Columns WHERE table_schema = 'db1' AND table_name = 'customer' ORDER BY column_name DESC"); $result = $res->fetchAll(PDO::FETCH_COLUMN); // define unwanted column names $exclude = ['id', 'syncroid']; // remove them $columns = array_diff($result, $exclude); ?> <select name='up_column' id='up_column'> <?php foreach ($columns as $col) { echo "<option>$col</option>\n"; } ?> </select> DROPDOWN...
-
Once your page hits the browser there is nothing php can do. Any further client-side processing will require javascript. When page has loaded, set a timer ( see setTimeout() ) to initiate a process which hides your loading bar.
-
You have already left it too long, but the longer you put it off the worse it will get. There are definite advantages to upgrading with new features having been added (both in PHP 8 and MySQL 8). The downside is your database processing will need to change. I'd also strongly recommend you use PDO rather than switching to mysqli (There is more involved than just adding an "I" to the function calls). How much extra coding will need changing will depend on how you coded in the past. For example, PHP8 is stricter on variable typing. EG <?php $a = ''; $b = 5; echo $a + $b; You probably get away with that at the moment , the '' being silently converted to '0', but with v8 you get PHP Fatal error: Uncaught TypeError: Unsupported operand types: string + int in C:\inetpub\wwwroot\test.php:4 Note that $a = '0' will work as it is convertible to int 0.