Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Ingolme last won the day on September 16

Ingolme had the most liked content!


Previous Fields

  • Languages
    C++, Java, PHP, SQL, Javascript, CSS, HTML

Contact Methods

  • Website URL

Profile Information

  • Interests
    Software development, videogames

Recent Profile Visitors

192,387 profile views

Ingolme's Achievements

w3schools Guru

w3schools Guru (7/7)



  1. I don't know what intune is, but in terms of valid XML, the following tag is missing an opening angle bracket " < ". CustomTaskbarLayoutCollection PinlistPlacement="Replace">
  2. That line of code is equivalent to this line in your original code: # Adding Empty Cell's $HTMLOUT_week .= str_repeat('<td></td>', $STRING_1 - 1); // str_repeat == "Repeat a string" You can see the minus 1 there too. It creates empty cells for each weekday before the first day of the month. Since empty cells are only needed before the first day and not exactly on the first day, we subtract 1 from the weekday number of the first day of the month.
  3. I tested this in Firefox and it works as I expect. In order to prevent a link from being marked visited you have to delete the page from the browser's history, just clearing the cache wouldn't work. I'm not sure what you're referring to by "link's status" in your second question. The :active state of the link only appears briefly when the link is clicked before the browser loads another page, so its main purpose is to let the user know that the link was clicked successfully which may be good for user experience.
  4. It would be better to separate the HTML and the PHP to make the code much easier to maintain. The PHP should be all at the beginning of the document before anything, even before the <!DOCTYPE> declaration. Here's an example of how to separate HTML from PHP. CSS (goes in the <head>) <style> .highlight { background: rgba(0, 0, 0, 0.5); } </style> HTML template (goes in the <body>) <table class="table table-bordered calendar"> <tr> <td colspan="0">&nbsp;</td> <td align="right"><a href="?GET___year_AND_month=<?php echo $prev; ?>">&lt; PREV</a></td> <td colspan="0">&nbsp;</td> <td align="middle"><a href="?GET___year_AND_month=<?php echo $year_month; ?>">PRESENT</a></td> <td colspan="0">&nbsp;</td> <td align="left"><a href="?GET___year_AND_month=<?php echo $next; ?>">NEXT &gt;</a></td> <td colspan="0">&nbsp;</td> </tr> <tr> <th>Man</th> <th>Tir</th> <th>Ons</th> <th>Tor</th> <th>Fre</th> <th>Lør</th> <th>Søn</th> </tr> <?php foreach($table_content as $week) { ?> <tr> <?php foreach($week as $day) { ?> <?php if($today == "$year_month-$day") { ?> <td class="highlight"><?php echo $day; ?></td> <?php } else { ?> <td><?php echo $day; ?></td> <?php } ?> <?php } ?> </tr> <?php } ?> </table> PHP logic (goes at the beginning of the document): <?php /* Collect data */ // Create a timestamp from user input or, if user input is invalid, the current month $year_month = $_GET['GET___year_AND_month'] ?? date('Y-m'); $timestamp = strtotime($year_month . '-01'); if($timestamp === false ) { $year_month = date('Y-m'); $timestamp = strtotime($year_month . '-01'); } // Get current date $today = date('Y-m-j'); // Navigation links $prev = date('Y-m', strtotime('-1 month', $timestamp)); // Previous Month $next = date('Y-m', strtotime('+1 month', $timestamp)); // Next Month // Data information $month_days_count = date('t', $timestamp); // Days in the month $current_weekday = date('N', $timestamp); // Weekday number (0-6 -> Sun-Mon) /* Construct content for the table cells */ // Initialize variables $weekday_counter = $current_weekday; $table_content = []; // Add empty cells for weekdays preceding the beginning of the month $table_content[0] = array_fill(0, $weekday_counter - 1, ''); // Populate the array $week = 0; for($day = 1; $day <= $month_days_count; $day++, $weekday_counter++ ) { $table_content[$week][] = (string)$day; // Increment week counter if($weekday_counter % 7 == 0) { $week++; $table_content[$week] = []; } } // Add cells for weekdays following the end of the month while(count($table_content[$week]) < 7) { $table_content[$week][] = ''; } ?>
  5. Have you declared the upDate() function yet? In your onmouseout attribute, the unDo function needs parentheses () to run correctly. For now, add a <script> tag in your HTML document and try to declare those functions. Once you have written some code I can help correct any mistakes.
  6. The names of the weekdays each need to be added manually unless you can pull them from a database. Using a loop here would just make the code longer and less organized. If you really want to add another loop, you can create an array of weekday names and construct the HTML for a table row by looping through them. // Add weekdays header $weekday_names = ['Man','Tir','Ons','Tor','Fre','Lør','Søn']; $header = '<tr>'; foreach($weekday_names as $name) { $header .= "<td>$name</td>"; } $header .= '</tr>'; $HTMLOUT_weeks[] = $header;
  7. The way to solve it is to set the table headers outside of the loop, before the loop begins. In the case of your code it can be done near the line where $HTMLOUT_weeks is first initialized. # Array For Calendar // $weeks = []; // $week = ''; $HTMLOUT_weeks = []; // Creating an array. $HTMLOUT_week = ''; // Add weekdays header $HTMLOUT_weeks[] = '<tr><th>Man</th><th>Tir</th><th>Ons</th><th>Tor</th><th>Fre</th><th>Lør</th><th>Søn</th></tr>';
  8. You cannot return the data, you have to do something with it. Print it, manipulate it, store it into a variable or something else. In my previous example, I used console.log() to write the data to the Javascript console. Javascript is not allowed to write to files, neither on the server nor on the user's computer, but you can prompt the user to download a generated text file like this: <script> function file_get_contents(filename, callback) { fetch(filename).then((resp) => resp.text()).then(callback); } function handleResponse(data) { // This code generates a text file with the data and asks the user to download it var blob = new Blob([data], { type: "text/plain;charset=utf-8" }); var a = document.createElement("a"); a.href = URL.createObjectURL(blob); a.download = "file.txt"; document.body.appendChild(a); a.click(); setTimeout(function() { document.body.removeChild(a); window.URL.revokeObjectURL(url); }, 0); } file_get_contents('https://mediainfo.tf1.fr/mediainfocombo/L_LCI?context=MYTF1&pver=4014002', handleResponse); </script>
  9. The code will need to be updated so that you are handling the data in the callback function. It actually cannot work identical to PHP's function because it's asynchronous. This would work: <script> function file_get_contents(filename, callback) { fetch(filename).then((resp) => resp.text()).then(callback); } function handleResponse(data) { // Do something with the data here console.log(data); } file_get_contents('https://mediainfo.tf1.fr/mediainfocombo/L_LCI?context=MYTF1&pver=4014002', handleResponse); </script>
  10. As I mentioned before, it's complicated. You'll first have to find the highest timestamp for each name, then attach this timestamp to all rows which have the name. Finally, you would sort by this timestamp first, then the other timestamp second. It most likely involves nested queries which are very slow, but there might be a more efficient method I'm not thinking of right now. This query might work. I wasn't able to test this because it looks like W3Schools' SQL editor doesn't allow me to experiment with nested queries. It might have a syntax error or result in duplicate entries. SELECT t1.ID, t1.NAME, t1.TIMESTAMP AS main_timestamp, t2.TIMESTAMP AS sorting_timestamp FROM table AS t1 JOIN table AS t2 ON ( t1.NAME = t2.NAME AND t2.TIMESTAMP IN (SELECT MAX(TIMESTAMP) FROM table WHERE NAME = t1.NAME LIMIT 1) ) ORDER BY sorting_timestamp, main_timestamp DESC I usually handle complex problems of this sort with the aid of a server-side programming language. Either doing two independent queries and using the results of one query as inputs to the next, or by just sorting the results manually after retrieving them from the database.
  11. The simplest solution would be to order first by name and then by time. [ ORDER BY NAME, TIMESTAMP DESC ] For your example data set the result would be identical to your expected result. It would get vastly more complicated if you want to order the names based on the timestamps attached to them.
  12. The browser should only care about the domain name, I'm not aware of any IP restrictions.
  13. CSS background properties do not apply to HTML images, only to files specified by the CSS background-image property. The <source> element doesn't have a background-image attribute, you need to use the src attribute instead. I don't think CSS styles work on <source> elements because they merely are used to identify a resource on a server, it's the parent <picture> element that needs the CSS styles. There is no equivalent of the CSS background-size: cover for HTML elements. I don't see a reason to use HTML for this problem, it would be best to just use the CSS background image. If you want different images based on screen size then you can use media queries. For widths, you can either choose to expand to fit the container or set a fixed value like 2000px; it doesn't make sense to have both. A full CSS example would look like this: .bgimg { background-position: center; background-size: cover; background-repeat: no-repeat; background-image: url("img/small.jpg"); min-height: 75%; } @media screen and (min-width: 601px) { .bgimg { background-image: url("img/medium.jpg"); } } @media screen and (min-width: 1501px) { .bgimg { background-image: url("img/large.jpg"); } } If you want to set the size of the background image for each screen size then you can put a background-size declaration in each media query. It does not make sense to use background-size: cover in this scenario because it will be overridden. Here's an example with a fixed image size per screen size. .bgimg { background-position: center; background-size: 600px auto; background-repeat: no-repeat; background-image: url("img/small.jpg"); min-height: 75%; } @media screen and (min-width: 601px) { .bgimg { background-image: url("img/medium.jpg"); background-size: 1500px auto; } } @media screen and (min-width: 1501px) { .bgimg { background-image: url("img/large.jpg"); background-size: 2000px auto; } }
  14. I'm not sure how the Safari console works, but look for a "net" or "network" tab in the console and see if anything changes in it when you click on the button which activates the sound.
  15. The path looks correct. Does it work when you put the audio file in the same folder as the HTML file? Are there any Javascript errors shown in the error console?
  • Create New...