Jump to content

Leaderboard


Popular Content

Showing most liked content since 11/21/2016 in Posts

  1. 2 points
    There's nothing formal to tell you things like that. People do it themselves, and it tends to illustrate the Dunning-Kruger effect. People who just recently started tend to rate themselves highly, and only when you get more into something do you realize how much you don't know. I wouldn't put any weight on things like that. If you want to evaluate someone's capabilities look for a portfolio or things they've actually finished.
  2. 2 points
    I don't know where there's a list. Generally you should never develop for specific devices, you should just make your layout flexible enough (with help of media queries) to wotk on any screen regardless of size. This is usually achieved by testing your page in the responsive mode of your browser and resizing the viewport until it breaks, then you add a media query to correct the layout. But for reference, I start off with a design for the following devices, then make extra adjustments later: Small mobile (iPhone 4):Up to 374px (I usually use this just for specific elements that didn't fit) Mobile or small mobile in landscape): Up to 767px Tablet portrait: 768px Tablet landscape: 1024px (breakpoint usually between 800px and 900px) Desktop: 1025px and above Some people make designs for large desktop computers (1440px and above), but that's up to you. In general, there isn't one specific strategy for responsive design, this is just the approach from the companies I work with.
  3. 2 points
    Like astralaaron said using closest class and the index class in jquery you can get the index of the tr, have a look at the fiddle. https://jsfiddle.net/8hL46ftj/ hope this helps $('img').click(function(){ alert($(this).closest('tr').index()) })
  4. 1 point
    Yes, you need the same number and type of columns returned. You don't need to use the same table aliases necessarily, but it makes sense to use the same column names. That's not a correct assumption, if you remove the table aliases but keep them in the list of columns you'll get an error indicating that it doesn't know what p or c is. In that specific example, I don't think so, I think those aliases only apply to the select query where they are used. I could be wrong about that though, you might be able to use one in the other select query, but I don't think that would work. Yes. It won't, it's just being explicit about what you're asking for. If you wanted each ID from the two tables separately, for example, you should give each one a unique alias instead of returning 2 columns with the same name. If you change the data type of a column and there is existing data, MySQL will attempt to convert the data to the new data type. There are various rules for converting data between types. This is also called casting. You can also explicitly convert data during a SQL query, there are functions to do that. Those are the same functions that MySQL would use if you change the data type of a column.
  5. 1 point
    It looks like you're missing the FROM keyword here: SELECT * parent_table
  6. 1 point
    I always use a single numeric ID as the primary key unless I have a really good reason to do anything else, like if it is only a lookup table with 2 columns and then I make both columns primary. The ID is used internally by the database only and would never need to be changed, I do not use it as an identifier that anyone else would need to know. If you want to give your podcasts a number for people to identify them, make that another database field other than the ID. If you want a revision number, make that another database field. That way the ID will refer to a specific episode and revision. For as long as I've been doing this I haven't found a great use case for not just using an auto-increment primary key. No, it's one of storage. A char field always stores the maximum number of characters that the field allows. A varchar only stores what is necessary but has a maximum length. See here for storage requirements. Note also that an int field always uses 4 bytes regardless of the length you gave it. If a number has a smaller range than use one of the smaller int types. I agree, and that is what char fields do, they always store the maximum number of characters. You would only use a char field if the values will always be the same length, like for a GUID. So why not utf8_unicode_ci? Do you want to allow people to have the same username with different capitalization or characters that look the same but are different unicode code points? That's what using utf8_bin would allow, it looks at binary data only and does not take into account case or whether two characters have the same meaning but are different code points. It's just a question about data normalization. Databases have been around for decades, we have this figured out now. If there is a one-to-one relationship, that goes in a single table. If there is a one-to-many relationship, that's a parent and child table. If there is a many-to-many relationship, that's 2 tables with a third lookup table. The database is specifically designed to work with this kind of data, let it do its job. Don't increase the time required to insert, update, or select data because it's less complex for you. Data storage should be optimized for a computer, not a person. You can display it however you want it to show up, but make it easy for the database to do its job. That should be an auto-increment primary key. There's no reason to store a counter like that in a table, you can use SQL to get the count and then it's always going to be correct and you don't have to worry about updating it when things change. The way that's set up now, if you select the rows and order them by ID then it makes the count redundant, you don't need to store that data. I do use columns like that for display order if I want to allow the display order to be specified (as opposed to ordering by date or some other field), where it will be a sequential series, but if you're only storing the count there's no reason to do that.
  7. 1 point
    VARCHAR almost always takes less space than CHAR, because it allows fewer characters than the limit while CHAR requires the full space to be occupied. If you put a smaller string in a CHAR field, it pads the rest with null bytes. If you put the string "Hello" in a CHAR(150) field, what you essentially have in the table is "Hello\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
  8. 1 point
    If you're showing multiple boards and forms on the page then yeah, you need to add the board ID to each form to make them unique. You can make it a hidden input, or add it to the form action URL.
  9. 1 point
    Some text editors replace standard quotes ("") with curly quotes (“”) which messes up the code. Check your text editor settings to make sure it's not doing that to your quotation marks. If there isn't a setting for that in your text editor then try looking for another one, there are plenty of free ones out there.
  10. 1 point
    It doesn't really matter where you define those functions since there's going to be a delay before they get used (e.g., some action will send an ajax request, the page will get updated, then the functions will be used based on user interaction). You should probably just put them in a Javascript file that gets included on the page in the head with other things that can go in the head. But you'll need to make sure that the functions will get executed when the user does whatever you're checking for. If you're checking for a click event, then you can use jQuery to attach the event handlers so that the elements don't need to be on the page yet, you can do that by delegating the event handlers. You do that by specifying a selector when you attach an event handler using the on method: http://api.jquery.com/on/ So, for example, you would attach the event handler to a div that is eventually going to contain the dynamic content, but use a child selector to say that only buttons with the class "click-1" inside that div should receive the click events. As long as the container element exists you can attach those event handlers before the dynamic content is loaded, you would attach them in the ready handler.
  11. 1 point
    The reason why your code isn't working is because $con is not defined in those functions (and $pass and $conf_pass are not defined in newUser either). You can use global variables inside the function, but it's better to avoid globals and pass in any variables you want the functions to use. So you should pass $con to the functions. You should add this to the top of your code: ini_set('display_errors', 1); error_reporting(E_ALL); You should switch your database code to use prepared statements instead of trying to manually escape everything. Prepared statements offer better security. You can use prepared statements with mysqli, but it's better to use PDO. The PDO code is shorter and easier to understand, and PDO works with databases other than only MySQL. e.g.: $stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?"); if ($stmt->execute(array($username))) { if ($row = $stmt->fetch()) { // it found a user } } http://php.net/manual/en/book.pdo.php For the code I posted above, I was saying that each function should only do one thing. Your newUser function should only validate and add the user if necessary, it should not also output anything or redirect. Your main code should do that based on what the function returned. If you want to return multiple values you can use an array like I did above to return a "success" value for whether the user was added, and a message to show them. So your main code would call that function and then decide what to do. Those header redirects wouldn't work though, because you sent output to the browser first. $result = newUser(...); if ($result['success']) { // maybe redirect to a thank-you page or something } else { // show the error in $result['message'] }
  12. 1 point
    .w3-cell-row { margin: auto; margin-top: 0; width: 79%; border-collapse: collapse; /* margin-bottom: -10px;*/ } .w3-cell { background-color: #fff; border: 5px solid #00c; /* margin-bottom: -10px;*/ border-bottom: none; } .w3-cell-row:before, .w3-cell-row:after { content: none; } .w3-cell-row:last-child {border-bottom: 5px solid #00c;}
  13. 1 point
    Yes, you would use an array of objects as shown. As far as file types, it's not very common to have a static file only containing JSON that you read from, they just do that because it's an easy example. It's more likely that you'll be sending ajax requests to PHP or another language on the backend which would dynamically generate the JSON (from a database, as in your example). You can use PHP or whatever language to set the content-type for JSON though, rather than saying it's HTML.
  14. 1 point
    Thank you Gabrielphp, that worked perfectly. I tested for the negative. if(!is_numeric($phonenum1)){ $phonenum1Err="Only numbers0-9"}
  15. 1 point
    You're telling to find an element with the ID "podType". If you want to use the value of the variable, you need to specify that. $('#' + podType)
  16. 1 point
    1) Anything using below class will use pointing finger cursor .style1 { font-family: Verdana; font-size: 10pt; text-align:justify; cursor:pointer; } 2) You said Which means you would have to apply this styling class name to container element, which would either be a Paragraph, or Anchor, or Strong element that surround the text ' Click to Read More'. BUT! you have applied class name to This is outside the scope of what you are trying to target, its scope starts from opening span <span class="style1"> and finishes at </span>, all the text "W3Schools is a popular web site for learning web technologies online.[2] Content includes tutorials and references relating to..." will have the pointer cursor, but anything outside this will work as default styling, which is what is happening to anchor text you are attempting to target, because its outside '<span class="style1">....</span>' scope.
  17. 1 point
    The issue isn't the location of the files relative to each other, it's how you're accessing them. If the URL bar in your browser starts with http:// or https:// then your browser uses one security model, if it starts with file:// or anything like that it uses another. I don't know if ajax even really works for non-HTTP requests, because part of that process is communication with a web server. It might work, but I wouldn't count on it. If you want to download a server for testing, the easiest are packages like XAMPP. That includes the Apache web server, and also PHP and MySQL and some other tools pre-configured. After you install that and start Apache, you'll be able to access it at http://localhost/ There will be a specific folder on your computer that Apache uses as the document root, that's where the root level of your website is. So if you create a file and save it in that folder as index.html, you can access it at http://localhost/index.html, or if you put a folder called images in the document root then that will be at http://localhost/images/ etc
  18. 1 point
    The page is reloaded because you are clicking a link which will call itself because no other url is requested, but! the current page url will have the querystring attached to it as well. When the page reloads if this page has php code that will check and read the name and value transferred with the querystring using $_GET[], this value can be passed onto a php variable. Yes! you should sanitize, as it is a querystring viewable and editable from address bar. You could prevent page reloading by using JavaScript, then by using AJAX, process the data from external php page and return result.
  19. 1 point
    Thank you so much - I understand it now after finally putting all the pieces together. I also figured out (from the link you provided) that the pattern string has to be enclosed by a delimiter, thus the two "/". Then the ending "i" mean case-insensitive alpha match. Just for anyone else that reads this post... It looks to me like someone could specialize just in regex coding! Thanks again.
  20. 1 point
    It should be, it's kind of lazy to leave it out. It should be listed along with the visibility. They don't need to give it a value in that list, they can just specify the visibility.
  21. 1 point
    It doesn't have a plain reading. You use that question mark because it is a query string. From https://www.freeformatter.com/url-parser-query-string-splitter.html What's the 'query string' in a URL? The query contains extra information that is usually in the key-pair format. Each pair is usually separated by an ampersand & character. It follows the ? character. Examples: http://www.foo.bar/image.jpg?height=150&width=100 https://www.secured.com:443/resource.html?id=6e8bc430-9c3a-11d9-9669-0800200c9a66#some-heade
  22. 1 point
    Echo or escaping and entering by opening/closing php, are both valid, but i think separating php from html is much cleaner as you have it.
  23. 1 point
    That's because you set it to false right before you alert it. Go back and look at the code I posted, notice how the variable definitions are outside the load handler. They first get defined with those default values, maybe at some point later down the page PHP will redefine them, and then once the page finishes loading the rest of the Javascript runs, using either the default values or the values that were set by PHP.
  24. 1 point
    The act of adding the new HTML content (it does not matter that the content came from somewhere on the page) causes the browser to execute whatever Javascript is in there. The Javascript that is in there tells it to replace the HTML content again, and that keeps happening until the browser gives up. The position of the PHP code is not relevant as far as the browser is concerned, the position of the Javascript code is relevant. Don't put the Javascript code to do the replacement inside the HTML that gets added, it needs to go outside of the element that you're copying. Now, if you need to change the PHP code to get the Javascript code to show up somewhere else, then do what you need to do. I would expect that you only have to change something inside the template though. It's always better to produce the final version the first time, instead of spending time to produce an intermediate version which then needs to spend more time to produce the final version. Redrawing the page in the browser is a fairly expensive process (relatively speaking), it's best to limit how many times you're telling the browser to draw the page. Browsers have gotten a lot better at that over the last decade, but it's still a good practice to try to just produce the final page the first time. That's just how the browser handles it. The HTML on that page is not valid, there's not much point trying to figure out how or why the browser is going to handle invalid HTML when you should just produce valid markup. The first link causes the Javascript loop and error in the console. That link only shows up when clicking from the other page, right? Why do you use a hash, what's the point? If you have the podcast ID shouldn't that be enough to uniquely identify it?
  25. 1 point
    Use string to time function strtotime(), you can multitude textual expression to get the result you want, then loop through each day by increasing by 1 in a loop // set initial start date to next sunday from current date $date = date("Y-m-d", strtotime("next Sunday")); //set from $date value to 1 week ahead for end date $end_date = date("Y-m-d", strtotime("+1 week", strtotime($date))); //'2020-12-31'; while (strtotime($date) <= strtotime($end_date)) { echo $date . "<br>"; //increment to next day $date = date("Y-m-d", strtotime("+1 day", strtotime($date))); }
  26. 1 point
    When a get form is submitted it would produce an querystring also You are not adding querystring to form action, example echo '<td><form method="get" action="findorder.php?order_num='.$order_num.'"><input type="submit" name="testing" value="Edit" /></form></td>'; In findorder.php $this_order = $_GET['order_num']; //would retrieve value of $order_num same as $this_test = $_GET['testing'] // would retrieve value of 'Edit'. OR add to hidden input, like I said there are several ways to do this echo '<td><form method="get" action="findorder.php"><input type="hidden" name="order_num" value="'$order_num.'" ><input type="submit" name="testing" value="Edit" /></form></td>';
  27. 1 point
    dsonesuk is referring to using <a> tag. Like: <a href="edituser.php?cust_id=n">Edit User</a>
  28. 1 point
    They can only read your code if they have FTP or shell access to the server. Otherwise, they see the same thing that you see when you open the PHP file in your browser.
  29. 1 point
    My mistake, used for testing forgot to remove. change slideIndex = parseInt(z[j].getAttribute("data-currentslide")[0]); to slideIndex = parseInt(z[j].getAttribute("data-currentslide")); //lose the [0]
  30. 1 point
    Its shorthand, but your PHP has to be permitted to allow it through PHP settings file under "short open tag" , else problems will occur.
  31. 1 point
    var a = ["123", 123, "1a2b3c", 122.222, "A"]; for(var i=0 ; i<a.length ; i++){ if(isNaN(a[i])){ alert('a['+i+'] is not a number (nan)'); } }
  32. 1 point
    IF the values in the array are taken from text type input, the numbers in array will be a string/text, it is precautionary to make sure when used in math operations that 16 + "4" don't equal "164", but 20.
  33. 1 point
    Have you tried this? <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title> HTML5 page </title> </head> <body> <div class="form-group"> <label class="col-sm-4 control-label">Checkbox inputs</label> <div class="col-sm-8"> <div class="checkbox check-transparent"> <label for="opt01">Option 1</label> <input type="checkbox" value="1" id="opt01" checked> </div> <div class="checkbox check-transparent"> <label for="opt02">Option 2</label> <input type="checkbox" value="1" id="opt02"> </div> <div class="checkbox check-transparent"> <label for="opt03">Option 3</label> <input type="checkbox" value="1" id="opt03"> </div> </div> <div> </body> </html>
  34. 1 point
    Are you making an app, like those? If it was me, I would test for a connection to the app's servers and, if there is not one, then I would probably start by using a buffer to keep messages that are pending to be sent. If the app gets closed then I would write the buffer to permanent storage which I would check the next time it starts up.
  35. 1 point
    https://www.w3schools.com/tags/tag_track.asp
  36. 1 point
    It only shows the source of files in the same local filesystem, regardless of domain name. If, for some reason, it did load a file from a URL it would only be able to show what was returned by that URL through HTTP.
  37. 1 point
    Try using w3css modal, with w3-animate-left class with w3-modal-content class https://www.w3schools.com/code/tryit.asp?filename=FHE8DTJR3F2P working solution https://www.w3schools.com/code/tryit.asp?filename=FHE95QEVR6BC
  38. 1 point
    I'm not sure what code you're using to get the mouse offset, but once you have it you can calculate the correct position by dividing the canvas real size by its visible size. // Assuming we already have a reference to canvas and the mouse's position // relative to it is in visibleX and visibleY var horizontalRatio = canvas.width / canvas.offsetWidth; var verticalRatio = canvas.height / canvas.offserHeight; var realX = horizontalRatio * visibleX; var realY = verticalRatio * visibleY; // Do something with realX and realY
  39. 1 point
    OK. The advantage of using AJAX is to prevent having to reload the page each time the form is submitted, and the advantage of using PHP is to insure that the submitted data is sanitized and validated. Are implying with this that it is not possible to use Javascript for the purpose of sanitization and validation? If I have understood correctly, AJAX serves only as an intermediary between the form page and the PHP page. In other words, the PHP page should be written, as if the AJAX did not exist, and the AJAX should always refer to the PHP page via the following piece of code $.ajax({ url: 'ajax_comment.php', What is more, the PHP code should only be included in the page, if the following condition is satisfied. !isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) Thus, it was wrong for Loois to have included the following code at the bottom of his form page include ("jquery.js"); Under the assumption that all of the above is correct, why is the following code not entered at the top of the form page? include ("jquery.js"); My very best, Roddy
  40. 1 point
    You should always provide a pure php script, to sanitize and validate, BECAUSE JavaScript CAN be disabled, You can use AJAX to update content, make database requests/update/insert etc without the need to reload the page constantly, which is required for pure php code to do the same thing. Usually you would not include the php script in the form page, only the AJAX JavaScript code would access it externally, to process the form data and return results to a specific location, it makes more sense this way checking with $_SERVER['HTTP_X_REQUESTED_WITH'] that it is a AJAX request. Without this it could be included in the form page, it would retrieve default information or content on loading of page, a AJAX request could be made using form using the same php script externally, the new AJAX returned results can be use to update/overwrite the default content without reloading the page.
  41. 1 point
    So, why use AJAX at all? Since AJAX depends on Javascript being turned on or off, and since this decision is made by the user-client, why not use PHP whose functioning is determined solely by the host-server?
  42. 1 point
    The RSS file can go anywhere you want, you just have to tell people where to find it. As I mentioned earlier, you can tell browsers where to find a feed by putting a <link> tag in your HTML page. There's no real best practice as to where to place your RSS feed files. I think RSS feeds have to use absolute URLs in the <link> tags including protocol and domain name to point to the location of the files. If you want a URL like "/feed" for your RSS feed you would have to use URL rewriting on the server, a regular URL would look like this instead: "/feed.xml" or "/feed.rss".
  43. 1 point
    These Email = $Post('email'}; $Password = $Post('Password'}; are supposed to be $_POST['email']; AND $_POST['Password']; and the coloured names are suppose to match the values of name attributes of inputs you are trying to read <input type="text" value="username"><br> Password:<br> <input type="text" name="lastname" value="password"><br><br> AS you can see, they match neither, and one does not even have a name attribute which is required for ALL inputs, AND name values must match exactly as 'password' is treated differently to 'Password'.
  44. 1 point
    PHP extension is required if you need to process data sent from form whose method is post or get using $_POST, $_GET, or $_REQUEST. IF its action is a link to another php page, then the form page can remain html, if it is sent to itself then the form page should be php.
  45. 1 point
    You can use scandir() to list files in a directory and generate the HTML for the images. The line breaks exist, but HTML doesn't render line breaks unless you specifically put a <br> element. You can use nl2br() to show line breaks in the text provided by users. You can't choose the size of a file, but you can give a size limit in the file uploader. There are plenty of PHP file upload tutorials, you should look at some of them. The W3Schools tutorial has sections explaining how to limit the file size and file type. You can use str_replace() to change substrings into something else, such as in the following example: <?php $string = str_replace(':)', '<img src="smiley.gif">', $string); ?>
  46. 1 point
  47. 1 point
    var SelOrderArray=[]; $.each($selected,function(i){ //loop through selected possible multiple selected options if(SelOrderArray.indexOf($selected[i]) === -1){ //if current looped through $selected value not in array then add to array SelOrderArray.push($selected[i]); } }); // loop through ordered array of slected options $.each(SelOrderArray,function(i){ //clone element with specific id to temp storage variable var TmpDivClone = $("#"+SelOrderArray[i]).clone(); //remove current existing element with specific id $("#"+SelOrderArray[i]).remove(); // prepend temp cloned element to div #result wrapping mydiv1 elements so prepending remains below dropdown and show TmpDivClone.prependTo('#result').show(); }); Not tested, written on tablet
  48. 1 point
    A lot of questions asked here in this forum can be answered simply by reading the tutorials, and most often what people are asking are actually examples in the w3school main website. Some questions are even extremely similar, but yet people ask the same questions all over again.That "please-read-the-tutorial-first" message pinned at every forum apparently DOES NOT work.I firmly believe that this forum is created to answer questions that the w3schools main website does not answer.I do not have a solution for this. But this would just serve as a precaution. Because basically when this forum grows. Then a lot new topics will be started.Then probably, we will be reading a bunch of repetitive questions being asked all over and over and over again.And please forum members, please dont post for the sake of increasing your post count. Post for the sake of answering questions being asked.And if you wish to promote your website here, we cant/wont stop you with it, but please do it in an ETHICAL way. There is no excuse for not having any manners/ethics.And lastly, this forum, in my humble opinion, is used for answering questions (or some code snippets) not for asking for full/complete scripts.This is just my opinion. You might think i'm wrong, but really i think i am right with this one. You just have to agree with me here.
  49. 1 point
    It is a nice way to interact with GitHub, but it isnt a GUI for just using Git. Still, very useful since sometimes its hard to remember the commands for pushing to GitHub like "git push origin master"
  50. 1 point
    Please don't rot your mind with an editor!!!! :)You learn so much more by using notepad and hand coding. You develope much stronger coding skills. Even with .Net I use Notepad at home...I only us VS.net at work because I have to.Just my opinion though.
×