imgrooot
-
Posts
383 -
Joined
-
Last visited
-
Days Won
1
Posts posted by imgrooot
-
-
Not with a proper ALTER TABLE statement.
ALTER TABLE records MODIFY price DECIMAL(10, 2);
Yes you're right. Thanks a bunch.
-
you would want to store the data in column defined as a decimal data type - http://dev.mysql.com/doc/refman/5.7/en/fixed-point-types.html
There is a problem with that though. It removes any number after the decimal and instead adds .00 to it.
-
I have a Mysql table where I store prices of a product. I have the values in "varchar" format because I needed to include "decimals" in the prices(for eg. 15.30) and "int" doesn't allow that.
Having done that, when ever I filter the products by prices in Ascending or Descending order, they don't show up in proper order. It seems like the decimal in the prices is messing up the order.
Is there a way to fix this so that the php query can filter the prices in proper order despite the decimals?
Here's the eg of the query.
$get_records = $db->prepare("SELECT * FROM records ORDER BY records.price DESC"); -
I have it working now. And yes it is a CSS problem. Here's the css code. Note that "Overflow-y" will only work if the position is defined. Without the "position:fixed", my nav-mobile dropdown didn't open when I clicked toggle.
.nav-mobile { display: none; *zoom: 1; position: fixed; width: 100%; overflow-y: scroll; -ms-overflow-y: scroll; -webkit-overflow-scrolling: touch; // mobile safari }One small edit. Add the height: 100%. It'll fix any y scrolling issue. Here's the updated code.
.nav-mobile { display: none; height: 100%; *zoom: 1; position: fixed; width: 100%; overflow-y: scroll; -ms-overflow-y: scroll; -webkit-overflow-scrolling: touch; // mobile safari } -
Care to provide a link to the a working application. Otherwise, we can only take shots in the dark. At least provide a screenshot and/or CSS, because this is probably more of a CSS problem than a JS problem.
I have it working now. And yes it is a CSS problem. Here's the css code. Note that "Overflow-y" will only work if the position is defined. Without the "position:fixed", my nav-mobile dropdown didn't open when I clicked toggle.
.nav-mobile { display: none; *zoom: 1; position: fixed; width: 100%; overflow-y: scroll; -ms-overflow-y: scroll; -webkit-overflow-scrolling: touch; // mobile safari } -
Right now I have a mobile dropdown that works fine. The only issue I have is that when viewing it on my smartphone, the dropdown gets cut off at the bottom and I am unable to scroll it down to rest of it. Is there a way to fix it so that It's scrollable?
Here's my js code of the dropdown.
$(document).ready(function() { $(".nav-mobile li a").each(function() { if ($(this).next().length > 0) { $(this).addClass("parent-arrow"); } }) $(".toggle-mobile-menu").click(function(e) { e.preventDefault(); $(this).toggleClass("active-mobile"); $(".nav-mobile").toggle(); }); adjustMenu(); }); $(window).bind('resize orientationchange', function() { ww = document.body.clientWidth; adjustMenu(); }); var adjustMenu = function() { var ww = document.body.clientWidth; if (ww <= 850) { $(".toggle-mobile-menu").css("display", "block"); if (!$(".toggle-mobile-menu").hasClass("active-mobile")) { $(".nav-mobile").hide(); } else { $(".nav-mobile").show(); } $(".nav-mobile li").unbind('mouseenter mouseleave'); $(".nav-mobile li a.parent-arrow").unbind('click').bind('click', function(e) { // must be attached to anchor element to prevent bubbling e.preventDefault(); $(this).parent("li").toggleClass("hover"); }); } else if (ww > 850) { $(".toggle-mobile-menu").css("display", "none"); $(".nav-mobile").hide(); $(".nav-mobile li").removeClass("hover"); $(".nav-mobile li a").unbind('click'); $(".nav-mobile li").unbind('mouseenter mouseleave').bind('mouseenter mouseleave', function() { // must be attached to li so that mouseleave is not triggered when hover over submenu $(this).toggleClass('hover'); }); } } -
So you're talking about a foreign key used to join the two tables?
Then the ID is better, because it's stable and efficient. Names change, which means the database has to keep the tables synchronized. And names are long, which means it's relatively expensive to compare them.
Numeric IDs, on the other hand, are unlikely to ever change, and they have a fixed length.
Got ya. Thanks.
-
Say I have 2 tables.
Table 1: Type(type_id, type_name)
Table 2: Records(record_id, record_name, record_type)
Under the "record_type" column, is it better to use type_id(eg. 10) or type_name(eg. Clothing & Watches)? If the answer is use the name, is it better to use the original name(Clothing & Watches) or a slug name(clothing-watches)?
-
Type something random and invalid into the file and see if your site starts returning 500 errors. If not then it means your .htaccess file isn't being interpreted anymore and you should talk to your host.
I do get 500 errors if I add invalid code in .htaccess. So it does work. It can't just be the live host server because I have the same issue on localhost. Weird thing is, I have another websites with the exact same .htaccess file on localhost and they seem to work fine.
-
This is so strange. I have this bit of code that removes the .php extension from pages so that I can visit any page without typing .php at the end.
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)$ $1.php [L]The above code has always worked for me before. But for some reason today it stopped working on localhost and the live server(ipage hosting). Do you know why that might be?
-
I think Groot is trying to say he wants to make the page on the other site do something, such as open a popup window upon arrival.
If that's the case then no, it is not possible. You cannot make someone else's site do something it wasn't designed to do.
Yes that's exactly what I was asking. I now understand that is not possible.
-
Question 1. I have a form and on submit it redirects to another site. Is it possible to open that site in a new tab instead of the same page? I have tried this js code and it doesn't seem to work.
if() { $get_url = 'https://www.google.ca/'; ?> <script> window.open('<?php echo $get_url; ?>','_blank'); </script> <?php }Question 2.
Is it possible to have a extend popup to another site using a unique link? Take the above google link for example. Is it possible to add new code at the end of that link url which will show a popup window or something on that google page if only visited through that link?
-
You are still well over a hundred releases behind. You need to be running 5.6x minimum.
I do see the option for 5.6x but it says it's currently in BETA stage. Is it wise to use it? Btw, I am using bluehost web hosting.
-
So what is line 19 in your password.php script? There's no opening brace on line 19 in any of the official versions.
Is it “namespace {”? Then you're appearently running an ancient, long-abandoned PHP version (something prior to 5.3).
Yes it's the “namespace {”.
And yes you're correct. The server was running older PHP version. I switched it to PHP 5.4 and i no longer get that error.
Thanks for clearing it up.
-
I am using this https://github.com/ircmaxell/password_compat
I have no problem using it on a local server. But as soon as I test it on a live server, it gives me an error like this.
Parse error: syntax error, unexpected '{' in /home/public_html/sub/snippets/password.php on line 19The error is on the same line as the beginning of the code in that library.
Why is this happening?
-
You'll have to target each 'show-details' class individually. Put that div inside the 'product' div and target it specifically. This is untested, but should theoretically work:
$(document).ready(function(){ $('.product').mouseover(function(){ $(this).find('.show-details').css({ display: 'block' }); }); $('.product').mouseout(function(){ $(this).find('.show-details').css({ display: 'none' }); }); });Yep the above works if I have the ".show-details" div as a child of parent div ".product" like this.
<div class="product"> <div class="product-title"> <?php echo $get_record_title; ?> </div> <div class="product-price"> <?php echo $get_record_price; ?> </div> <div class="show-details"> <?php echo $get_record_details; ?> </div> </div> -
You also need a mouseout to set the display back to "none"
So something like this?
<script> $(document).ready(function() { $(".product").mouseover(function(){ $(".show-details").css("display", "block"); }); $(".product").mouseout(function(){ $(".show-details").css("display", "none"); }); }); </script> -
The php loop will happen on the server so the mouse over effect is moot at that point. The script will do its thing and return whatever to the client. At that point your html/css can hide the div if you want and a little JS can 'show' it upon mouseover.
Two separate processes.
The thing is, if I have 10 records on a page and I use the above javascript code to show the hidden div, it will show the div for all 10 records at the same time. I don't want that. I just want it show a div for each unique record one at a time as I hover my mouse over them. So that is why I am asking what the javascript code will look like to make that work?
-
Here's what I'm trying to do.
I retrieve results using php foreach loop. Within that loop results, I want to show a div(.show-details) on mouse over only. How do I do that?
This is my code so far.
<style> .show-details { display: none; } </style> $get_records = $db->prepare("SELECT * FROM records WHERE record_id = :record_id"); $get_records->bindParam(':record_id', $record_id); $get_records->execute(); $result_records = $get_records->fetchAll(PDO::FETCH_ASSOC); if(count($result_records) > 0){ foreach($result_records as $row) { $get_record_title = $row['record_title']; $get_record_details = $row['record_details']; $get_record_price = $row['record_price']; ?> <div class="product"> <div class="product-title"> <?php echo $get_record_title; ?> </div> <div class="product-price"> <?php echo $get_record_price; ?> </div> </div> <div class="show-details"> <?php echo $get_record_details; ?> </div> <?php } } else { echo 'no results.'; } <script> $(document).ready(function() { $(".product").mouseover(function(){ $(".show-details").css("display", "block"); }); }); </script>

Rewriting pretty URLs. Too many examples out there don't show the entire process.
in Apache HTTP Server
Posted
Say below is my normal html href link. How would you turn this into a pretty URL using .htaccess? Also if I understand it correctly, this link will also have to be changed to match the pretty url. What would the new link look like?