Posts

Showing posts with the label select

Sorting MySQL data into limit sized pages, and onscreen option to change pages? How is it done? [on hold]

Image
Sorting MySQL data into limit sized pages, and onscreen option to change pages? How is it done? [on hold] I am new to HTML and CSS, however I have some basic knowledge of programming games in C# and Java (using frameworks like LibGDX, Unity etc). I've built a database in MySQL and the corresponding php code that displays a html article for each entry in the table. Everything is working great but the whole database loads onto one big webpage. I have been reading around a lot but cannot seem to find where to start on building it into pages. The only idea I can imagine right now is that I will need a field somewhere on my site to hold the current page number the user selected, and then in my SQL SELECT statement use that figure to somehow pull only say 20 pages starting from 'currentPage * 20' for example. I've found small parts of the info I need like I see there may be a LIMIT clause I can use. But how can the SELECT * FROM table ORDER BY id DESC LIMIT (currentPage*20); ...

SQL ont-to-may relationship - How to SELECT rows depending on multiple to-many properties?

SQL ont-to-may relationship - How to SELECT rows depending on multiple to-many properties? A MySQL database contains two tables with a one-to-many relationship: One user can have many settings: Users: id username password -------------------------- 1 Bob 123 2 Alice abc ... Settings: id user_id key value ----------------------------- 1 1 color blue // Bobs settings... 2 1 theme xy 3 1 size 5 4 2 size 6 // Alices settings... Problem: How to find all users with color == blue AND size == 5 ? color == blue AND size == 5 Using a LEFT JOIN it is no problem to find users with one property: LEFT JOIN SELECT users.id FROM users LEFT JOIN settings ON users.id = settings.user_id WHERE settings.key = 'color' AND settings.value = 'blue' However, this does not work when searching for two settings at a time? Is it possible to solve this with a single statement? What is the most efficient...

How can I preserve select default option

How can I preserve select default option I have a select html element for years, I want it's default value to be only "年", but my js code is rewriting it. What should I do? <select id="f_year" name="f_year"> <option disabled selected value>年</option> </select> var start = 1900; var end = new Date().getFullYear(); var options = ""; for(var year = start ; year "+ year + "年" + ""; } document.getElementById("f_year").innerHTML = options; 2 Answers 2 When you are recreating the Select options. Instead of keepin var options = ""; keep it as var options = "<option disabled selected value>年</option>"; var options = ""; var options = "<option disabled selected value>年</option>"; <select id="f_year" name=...