Jump to content

smus

Members
  • Posts

    177
  • Joined

  • Last visited

Everything posted by smus

  1. I would be glad if there were integers or decimals, but this is not my code. I was given the task just to add sorting without adding changes to the table. And I've just found the solution. That space was a hex 'C2' symbol and the ORDER BY section have to look like this: ORDER BY CAST(REPLACE(price, X'C2A0', '') as signed)
  2. The table contains goods and their prices. The type of price field is TEXT, but I need it to be showed from the smallest price to the highest (as INT). CAST takes thousands and literally "stops" sorting before spaces. The output of the query is: price CAST (price AS signed) 8 791 8 8 791 8 8 082 8 9 374 9 9 823 9 10 186 10 12 698 12 12 257 12 13 959 13 14 920 14 14 463 14 15 132 15 16 117 16 16 023 16 16 606 16
  3. I was also trying to replace spaces: SELECT REPLACE (column, ' ', '') AS P FROM table WHERE ORDER BY CAST(column AS signed) SELECT REPLACE (column, ' ', '') AS P FROM table WHERE ORDER BY column*1 Result is the same
  4. Something with the DB field itself, because I've checked the same SQL queries SELECT * FROM 'table' WHERE ORDER BY CAST(column AS signed) SELECT * FROM 'table' WHERE ORDER BY ABS(column) SELECT * FROM 'table' WHERE ORDER BY column*1 in phpmyadmin and they sort the field this way: 8 791 8 791 8 082 9 374 9 823 10 186 12 698 12 257 13 959 14 920 14 463 15 132 16 117 16 023 16 606 The type of the field is TEXT and it seems to me the second element of each new thousand starts to be sorted from right side, not the left.
  5. I've tried to modify this query, but it's no good: SELECT * FROM column... ORDER BY CAST(column as signed) ORDER BY ABS(column) ORDER BY column*1 I wonder if there are other ways to sort text values as numbers?
  6. Here's the file run.php
  7. The code is too long to paste here, but I've already found a place where the error might be, by taking away headers (header: location) and adding echo $_POST['send']. This is the file that process (update query) data from HTML form. The code was not completed and, as I suppose, taken from adding information (insert query) file, because there were these lines of code: if ($_POST['password'] == $_POST['confirm_password']) { [there is a code with processing information and mysql queries] } else { echo $_POST['send']."2"; // header("Location: ".SITE_PATH."&result=3"); exit; } This testing echo was reflected after I commented header (location) I've decided to delete the if clause, the code works, but the queries are still not sending. I will attach the whole file here, if it helps to solve the issue.
  8. MySQL queries are not working only inside this block: ... if (isset($_POST['send'])) { } ... The variable itself is set and transferred from the form. What could be the reasons of this and how is better to check?
  9. array_search function! Yes, thanks very much, guys! Very helpful!
  10. How to get an array index by its value (key)? Is there a special function for that in PHP? For example, I have an array $a ["zero","one","two"] and a variable $b = "two", I know the value is in the array, but I don't know its index.
  11. Yes, perfectly! No, I've changed that code. I was actually changing it several times while trying to make it work
  12. Seems that you have to simply use the same function for menu items (onclick) <li><a class="active" href="#home" onclick="myFunction()">Home</a></li>
  13. I've already done it! Here is what I've added to the plug-in js-file: $(document).click(function(event) { $(".mfp-title").append(event.target.parentElement.getAttribute("title")); }); This is jQuery code for enabling a title each time a popup image is loaded. And there's also a function on JS for generating titles when user clicks on right or left arrows (navigate between images): function arrowclick (i) { currentthumb = "thumb_" + i + ""; document.getElementsByClassName("mfp-title")[0].innerHTML = document.getElementById(currentthumb).getAttribute('title'); } The function is called, in this case, on prev and next events of the Magnific Popup plug-in: prev: function {arrowclick(b.index+1)} next: function {arrowclick(b.index+1)}
  14. Almost done! I've added this function to the navigation events (previous and next) and it works normally: function arrowclick (i) { currentthumb = "thumb_" + i + ""; document.getElementsByClassName("mfp-title")[0].innerHTML = document.getElementById(currentthumb).getAttribute('title')//+currentthumbid; } But now the first function (that is triggered after popup is initialized) refused to work: document.onclick = myClickHandler; function myClickHandler (e) { document.getElementsByClassName("mfp-title")[0].innerHTML = e.target.parentElement.getAttribute('title'); } So they are working well separately, but don't work when I uses them both. I wonder why this contradiction happens? I also tried: document.getElementsByClassName("overlay")[0].onclick = myClickHandler; instead of: document.onclick = myClickHandler; but it's also not working at all.
  15. I just can add the string statically or onclick applying to a parent element. I've found the place to insert a code (an event) when navigating between pictures inside the lightbox, but don't know how to take a title from there, from the next or previous image. The right and left arrow buttons are outside that block of code containing the images, so they are not their ancestors or predecessors. Here's how the page looks like: page
  16. I have gallery that generates dynamically from CMS (ModX). There is a 'title' property for each picture. And there is also a lightbox plugin (Magnific Popup) for the gallery that is written in JS which works normally, but I cannot display those titles as captions for each popup image. ('titlesrc' property of the plugin does not take captions from titles of images) Here's what I've added to the plugin file, but it works only after an image is increased (just once), but does not work when I click on the arrow buttons to slide through the images: document.onclick = myClickHandler; function myClickHandler (e) { document.getElementsByClassName("mfp-title")[0].innerHTML = e.target.parentElement.getAttribute('title'); } So I need either to add an event listener for arrow buttons inside the lightbox to change the particular title each time a picture is changed or initially to make the 'titleSrc' property work normally so to display a caption from the 'title' of an image. Would be very glad if someone could help me with the task!
  17. smus

    W3 colors

    Thanks! I've already found the answer!
  18. smus

    W3 colors

    Is it possible to use colors in w3 library other than that usually declared by words (main)? For example, in this case <ul class="w3-navbar w3-card-8 w3-light-grey"> how to change from grey color to a custom one, that defined by RGB digits?
  19. smus

    W3 buttons

    The styles of the button are not working when I call full width button: <button class="w3-btn-block">Button</button>, but they are normal when calling usual ones: <button class="w3-btn">Button</button>
  20. OK. I guess, it is very much like in MySQL. *mdb and *mdf are both Microsoft's format, so the convertion wouldn't be difficult I hope. Thank you for information!
  21. Right. Then just one more question: in which file format does SQL Server store the data? What is its native DB file format?
  22. The SQL Server is really powerful (the more powerful might be only Oracle DB), but, of course, more complicated! I've got not so much data (just one table with approximately less than 200 records) and not sure I should place it in SQL Server database. The thing is that the Access, in spite of its modest possibilities, attracts due to its simplicity of approach and visibility of the data storage. However, the idea of converting the data is reasonable and I will think it through, if I can't find the way to deal with non-latin symbols. Is that hard to convert from Access to SQL server?
  23. Yes. You're right, it is definitely better to place the data than to convert it, but I inserted it manually in MS Access 2013. I couldn't find how to encode it there and tried to do so by exporting to Excel, then saving to *.csv, then converting it in AkelPad from Cyrillic-DOS866 (This one happened to be in MS Access by default, I don't know why), then back to Excel and again back to Access, but it's still the same. There has to be the same feature as in MySQL's PHPMyAdmin to switch an encoding for the fields in the tables, but I cannot find one.
  24. You can check the folders through the cycle. It's gonna look like this: @echo off set allfolders = 'dir /b /s /a:d D:' set usersfolder = 'D:\users\' for /f "delims=" %%I in %%allfolders do ( [here's the exception] ) [here is the deletion]
  25. The data is originally in *.mdb file and used to be displayed as non-latin characters through question marks (??????). They have been changed to a usual abrakadabra (Вокруг Ñвета) after I've added the string to the top of the page: "<%@ CODEPAGE = 65001 %>"
×
×
  • Create New...