Jump to content

smus

Members
  • Posts

    177
  • Joined

  • Last visited

Posts 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. 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.

  4. 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.

  5. 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?

  6. 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.

  7. 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)}
  8. 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.

  9. 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

  10. 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!

  11. 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?

  12. 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>

     

     

  13. 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?

  14. 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.

  15. 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...