- Strength to Increase Rep
- +9
- Strength to Decrease Rep
- -2
- Upvotes Received
- 158
- Posts with Upvotes
- 139
- Upvoting Members
- 62
- Downvotes Received
- 2
- Posts with Downvotes
- 2
- Downvoting Members
- 2
330 Posted Topics
Re: Since Dani did the best standard-correct answer I will do the botch-job answer: $('table#list tfoot .grand-total').text('£'+parseFloat(grand_total).toLocaleString('en-gb', {style:'decimal',maximumFractionDigit:2})); $('[name="amount"]').val('£'+parseFloat(grand_total)); may also want to use £ to display in html, but you need £ to display in basic text elements like <input> Also a simple trick to format currency is times it … | |
Re: Emailing became more restrictive in the last year, so when you have a PHP server with no emailing setup the emails often fail completely now as there is so much wasted bandwidth on spam emails that these get turned down instantly. I solved it on my hosting with the [PHPmailer](https://github.com/PHPMailer/PHPMailer) … | |
Re: This is what i'm using for AJAX requests - it needs jQuery: var data = []; data.var = 'test'; $.ajax({ type: "POST", data: {data:data}, url: connectProtocol+"://"+currentHost+"/linkToAjaxFile.php", success: function(msg){ responseData = $.parseJSON(msg); console.log(responseData); if(responseData['status'] == 'success'){ //do something $('#someModalWindow').modal('hide'); }else{ alert(responseData['message']); } } }); I guess the direct answer would be … | |
Re: Normally you would use the value property as well, I have actually never seen the id attribute being used like that before. <select class="form-control select2" style="width: 100%;" id="managsel"> <option value="" SELECTED>Select Department</option> <option value="opa">Accountant</option> <option value="opb">Training</option> <option value="opc">Operations</option> <option value="opd">IT</option> </select> and then in vanilla JS just use something like … | |
Re: Here's the code I've been using for about 15 years now - but a bit more simplified: function dbConnect($type = ''){ $conn = mysqli_connect( DBHOST, DBUSER, DBPASS, DBDB); if (!$conn) { echo "Error: Unable to connect to MySQL." . PHP_EOL; echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL; echo "Debugging … | |
Re: You got a `GROUP_CONCAT()` in the SELECT statement so the query will group everything as one, since no GROUP BY was specified. You don't want GROUP_CONCAT anything in tblorders if you want to view all the orders for that Customer. Add to the bottom after the WHERE clause: `GROUP BY … | |
Re: Wheres the function! function checkLastChar(string){ return string.charAt(string.length-1); } console.log(checkLastChar('testing')); function removeTrailingDot(string){ if(string.charAt(string.length-1) == '.'){ return string.slice(0, -1); }else{ return string; } } console.log(removeTrailingDot('something.')); console.log(removeTrailingDot('something')); If you find yourself repeating the same code your doing it wrong. Probably not an absolute truth but it is a pretty workable rule. | |
Re: In your code where you write `mail($to,$subject,$message,$headers);` if you want to get error messages or "do something if it fails" you need to alter it a bit to something like: if(mail($to,$subject,$message,$headers)){ //if successful do something }else{ //if error do something else } //or var_dump(mail($to,$subject,$message,$headers)); //or $tmp = mail($to,$subject,$message,$headers); var_dump($tmp); I … | |
Re: logically, it would be because `WHERE variable_name = :variable_name` matches 1 row in your table maybe try a `var_dump(str_replace(':variable_name',"'some_value'",$sql));var_dump($records);`? run the sql on whichever way you use to access your DB directly I don't use PDO so i'm not too familiar on how it returns results, either way you will … | |
Re: I realise this has been marked as solved, but I wanted to make it known that the HAVING clause runs on the returned result set of your query, which as you say has no indexes on it as it is just a temporarily created result set - but has the … | |
Re: 1. Your Hosting server (CPU, RAM, HDD) 2. Your Hosting server's internet bandwidth 3. Your Client computer(CPU, RAM, GPU, HDD) 4. Your Client computer's internet bandwidth Check the size of the files in your browsers developer tools - Network - should tell you how long it takes to download and … | |
Re: if you use javascript, or any programming language, you can cut out a lot of processor time by being smart in the program logic. eg. if you do a loop, work out data you can before the loop eg. $.each(myArray, function(item){ var now = moment(myDate); //do something with now }) … | |
Re: You can use an anchor tag still just use href="javascript:" so it doesn't do anything on click. <a href="javascript:" onclick="loadMore(this, '.Memes', 'ex/more.memes.php');">Load More Content</a> It will get some default styles added to it, so you might want to add style="text-decoration:none;" and overwrite the other defaults for an anchor tag. I … | |
Re: Only ever heard of POST and GET. The others either have no use or is very specialised. a GET request puts the variables in the URL link - so the data is very visible. a POST request puts the data hidden in the headers of the request You use GET … | |
Re: How does this work for you? foreach($test as $v){ if (strpos($v, '_point') !== false) { echo $v; } } I didn't test it | |
Re: I use bcrypt passwords which look exactly like that. The first part of the string says how complex the hashing is, then followed by the salt then the hash. It generates completely different each time so you have to evaluate it with the verify function each time. Its designed to … | |
Re: > I have this number 1726.16723958045672098127. How Can I register in my db MySql. Why is the number truncated? should be a column type decimal, DECIMAL(24,20) would store the number you just mentioned without truncating. 24 - how many digits in the number 20 - how many digits are after … | |
Re: This should be what you are looking for: <div style='overflow-x:hidden;max-width:800px;'></div> Use bootstrap if it's not too complicated for you to get it set up. Bootstrap is very good [Bootstrap 5 Columns](https://getbootstrap.com/docs/5.0/layout/columns/) Bootstrap makes it responsive and is fully mobile compatible, so they stretch to fit the screen size and you … | |
Re: I just use curly brackets around the variables, and you don't need \` marks in the array reference later on. You also want to screen the GET input to make sure someone isn't going to drop your database. I also try not to use key words for table names, like … | |
Re: a bit messy but you could use a subquery to filter it out, something like: SELECT user_id, message_time, status, message, `etc` FROM `table` t LEFT JOIN (SELECT user_id, MAX(message_time) last_message FROM `table` GROUP BY user_id) `sub_table` st ON t.user_id = st.user_id AND t.message_time = st.last_message WHERE st.user_id IS NOT NULL … | |
Re: If I was doing it I would use Google Analytics but if you really need to do it manually for your project you basically have to set up a database with a programming language - like PHP - that writes into the database when a user does a specific action … | |
Re: Missing a `</div>` at the end Document.getElementById("item_variation_size").innerHTML += '<div class="custom-control custom-control-inline custom-control-size mb-2"><input type="radio" class="custom-control-input" name="sizeRadio" id="sizeRadio_' + itemData.item.v.variationData.sizes + '" value="' + itemData.item.v.variationData.sizes[i] + '" data-toggle="form-caption" data-target="#sizeCaption"><label class="custom-control-label" for="sizeRadio_' + itemData.item.v.variationData.sizes[i] + '">' + itemData.item.v.variationData.sizes[i] + "</label>"; | |
Re: PHP is a server side script. It is a module attached to a web server, it takes the code and "Pre-processes" it and outputs the result hence PHP (Pre- Hypertext Processing or Hypertext pre-processor). The code executes linear, from top to bottom. The script dies if it hits a fatal … | |
![]() | Re: This is a bit of a bootstrap question really, I hashed together a quick idea of what you could do. Keep in mind the concept behind bootstrap is RESPONSIVE - so you don't want to start defining exact sizes for the images etc as it scales with mobile devices and … |
Re: also could be `mysqli_fetch_assoc` instead of `mysqli_fetch_array`. `mysql_fetch_array` may not return the associative column names as the key values | |
Re: function newgame() { writeOutput("I'm thinking of a number between 1 and 100..."); var answer = Math.floor(Math.random() * 100 + 1); var guessCount = 0; // TODO: use the randomNumber function to pick an answer for this game. } You need to remove the "var", this makes the variables local inside … | |
Re: My guess on it saying "Your Password is Incorrect!" is that when you refresh a page that has been "post"ed to it will ask if you want to confirm resubmitting the form data, if you say yes it will send the post data again. Otherwise based on your code it … | |
Re: The way I would do that is to have an array that stores the ID's of played songs then shuffle through finding the songs that have not played yet. I added the concept in jQuery as that is what I used to do it in my projects. var played_songs = … | |
Re: Check out momentJS, I use [momentJS](https://momentjs.com/) for anything date & time related. You include the JS file in a script tag `<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment-with-locales.min.js">` you generally put this inside the `<head>` tag Then put the actual script AFTER the html divs where you want to do the conditional, as the … | |
Re: Not familiar with Siema, I did get the bug you have on your codepen though. When I commented out the first gallery-image on the first slider it started working for me. I also fixed the canonicalised PHP code in the javascript `<?php` and `?>` whatever it is for, I just … | |
Re: I would put some var_dump's in to help debug. My guess is the variable type is not what you expect on something. <?php var_dump($Row); if ($Row->logged_in == '0') { var_dump('condition 3 fired'); if ($Row->last_login != '0000-00-00 00:00:00') { var_dump('condition 1 fired'); ?>Last Login : <?php echo date('d M Y ,H:i … | |
Re: What I do is this: (you probably want the part inside `success: function(msg){` $.ajax({ type: "POST", data: {data:data}, url: connectProtocol+"://"+currentHost+"/analytics/ajaxProfileData.php", success: function(msg){ var responseData = $.parseJSON(msg); if(responseData['status'] == 'success'){ $('#div_dashboardContactsHomeProfileName').html(responseData['data']['first_name']+' '+responseData['data']['last_name']); if(responseData['data']['profImage'] == 'null'){ $('#div_dashboardContactsHomeProfileImg').attr('src',connectProtocol+"://"+currentHost+'/includes/images/profile_images/default.png'); }else{ $('#div_someidtoProfileImg').attr('src',connectProtocol+"://"+currentHost+'/fileUploads/images/'+responseData['data']['profImage']); } }else{ } } }); Then the PHP page has something like this: … | |
Re: $resultSet = $mysqli->query("SELECT `AIRCRAFTREGISTRATION`,`USEABLESEATS` FROM ACTIVE"); <?php while($rows = $resultSet->fetch_assoc()) { $acreg = $rows['AIRCRAFTREGISTRATION']; echo "<option value='$acreg'>$acreg - Seats:{$rows['USEABLESEATS']}</option>"; } ?> Looks like what you are asking. Is AIRCRAFTREGISTRATION the unique key for that table? You usually refer to unique ID refs in a drop down and use that programmatically. … | |
Re: Where it says `Firstname < 6` needs to be `Firstname.length < 6` Same goes for Lastname and Username. Those variables are strings so will error trying to evaluate them to a number | |
Re: You mean like popovers? [Bootstrap Popover](https://www.w3schools.com/bootstrap/bootstrap_popover.asp) Then you could play around doing something extra onclick with `visibility:hidden` or `display:none` or even modifying the html content on click `$(this).html('');` | |
Re: Hey Larry, This function is a javascript function and you can't run PHP code in javascript. (PHP is server-side & javascript is client-side) Here is a simple function in javascript I use to open a url: function openPopup(url,name,h,w){ var newWindow = window.open(url,name,'height='+h+',width='+w); if(window.focus){newWindow.focus();} } so you would do: <a href="#" … | |
Re: Not familiar with the language you are using but looking at the code my guess would be that it runs through one last time with an undefined input. ie. in your example you give it 5 values then you exit and it runs the "do" code one last time when … | |
Re: Missing a lot of data on what you are working on. However in HTML there is a CSS property called 'z-index' which is like the 3rd dimension on a web page, you know X for length, Y for height and Z is depth. So in theory if you get the … | |
Re: possibly because the 'href' property needs to be a full URL? This works for me in my browser console `window.location.href = 'https://www.google.co.uk';` | |
Re: Hey Larry, I'm not that familiar with the glob function but as Grant Baker said here: > Lastly, you really don't need to use foreach here. glob() will return an array of filepaths to the files that match the search paramaters. You also don't need download/ in the url, because … | |
I've been working on a project using Morris JS and since there was no solution out there for the Y axis scaling that I could find I wanted to posted where I got. Note you will need [morris JS](https://morrisjs.github.io/morris.js/) & [Moment JS](https://momentjs.com/) to run it. You just need a div … | |
Re: I haven't used this program myself, I would go through this guide on the Openelement Wiki: [Wiki Openelement Publishing Settings](https://wiki.openelement.com/en/index.php?title=Publishing_Settings) PHP code is a scripting language ran on the webserver(Pre-Hypertext Processing, IE it processes Hypertext(HTML) before it is sent to the browser), so you will have to upload it to … | |
Re: Where is the javascript code that is attached to `#starttour`? Put that in the window.onload function. | |
Re: You seem to be going about this the wrong way. An SQL query returns a result of COLUMNS & ROWS, you can't have 3 rows with different column names mixed with another 3 rows of different columns. The query result has to have the same columns for all the rows, … | |
Re: Your 2 queries look identical, can you do `var_dump($query);` after each of them so you can see the computed strings that are being sent. The only difference I can see is `$id_pictures = 1;` would be stored as a integer but PHP should add this into the string no problem. | |
Re: With the GDPR laws this became pretty strict, you want to contact a data providing company. This is one that I remember from way back, [Emailmovers](https://www.emailmovers.com/email-data) You have to keep very specific records for B2C emailing to prove they have opted in for what you are sending them. | |
Re: I have extracted the mysqli connection commands from my files here and done a quick query based on your tables, hopefully you can work out using the data in the `$data` array. (something like `<?php foreach($data as $key->$value){echo $value['Department'];}?>`) <?php $connection = mysqli_connect($host,$username,$pass,$database) or die(mysqli_connect_error()); $query = "SELECT dept.id `dept_id`, … | |
Re: I use config files to set the host name for the site as well as other site wide settings. To be specific, config.php which sets the hostname & database details then all web files refer to config.php for the host name & login details - hopefully he has these files … | |
Re: This looks like a mis-understanding of PHP, the code you want is a javascript solution: <script type='text/javascript'> var price = <?php echo $price;?>;//make it global outside the function function getval(sel){ var singleValues = sel.value; var thisPrice = price * singleValues; alert(thisPrice); document.getElementById('selectedItem').innerHTML = sel.val+' Selected. Price: '+thisPrice; } </script> <select … |
The End.