vendredi 8 juillet 2016

Web Workers and Canvas


Are web workers allowed to access a canvas object?


Splitting the output of MySQL Group_Concat()


How do I split Group_Concat() result into different columns? I don't want to show it in the same cell separated by comma.

What is the equivalent Atom Indent Guides like in Brackets?


What is the equivalent Atom Indent Guides like the one Bracket has showing vertical lines connecting matching beginning/opening and ending/closing brackets or keywords?


How can enter more than 4000 data entry in mysql database.?


http://www.louisyen.com/product Plz Help how can create a search engine for this page and how can add more than 4000data entry in MySQL database.

Can Someone Decode Sha1 (user +password+salt)


const admin_user = 'nimda';
const admin_pass = 'df4044de3cf4f69e87974bc740f6a9b80554f51e'; // sha1(user + password + salt)
const admin_salt = 'avwbeebk';

How to create menu like this?


I want to create a menu like this picture. Please tell me howenter image description here


PhpMyadmin : Select value from any table in a database


How to search a value from any column of any table of a database? I've almost 200 tables in my db, so that its not possible to search one by one.


Use Ruby database on Rails


I created a mysql database with Ruby. I want to use it on my Rails app. How can I do it? How can I read data with Rails without any database?


Oracle alternative for mysql REPLACE INTO


In mysql we use

REPLACE INTO

to insert if row doesn't exist and to update if it exists.

Is there a corresponding command in Oracle?


jeudi 7 juillet 2016

Automatically importing products into Woocommerce


I am trying to find a way to automatically import products into Woocommerce. I was wondering if someone had any experience with this, whether using a CSV or directly writing to the database.


CSS Styling and write Jquery inside a CSS class


How to write a css style class with in a css style class,and how it work,and how to write a javascript or Jquery inside a css class in html and as well as php.

what is the true sql statement for show something like list of products


How can I show the products ( description , serial number, price ) purchased by the customer "Peacock cafe bar" in the picture I show 3 tables I have try with select from ... where( select from ... as ... where “” )

Can't access folder from subdomain?


So I thought that you could access a folder in public_html from a subdomain. Example: Folder name = "test", URL = "test.mydoma.in" Is this an actual thing? If so can I fix it? Im running cPanel from clovux.net

How to do MySQL update query in r


In MySQL, what I did is:

update table set group = 1 where log(id) < 0

I wanna do same thing in R but I have no idea

What should I do?


How to hide an external download link ?? [on hold]


I want to hide a download link as done by google in this url??

https://www.google.com/webdesigner/thankyou/

How to accomplish it ?


Formatting flask-wtf submit button using bootstrap


I'm using jinja to render a flask-wtf submit button as follows: {{ wtf.form_field(form.submit) }} This results in a button formatted in btn-default bootstrap format (white). I'd like to change this to btn-success bootstrap format (green). How can I achieve this?

pagespeed module goes back to default after EasyApache update on cPanel server


On cPanel server, after running update of EasyApache, pagespeed module goes back to default - meaning all changes in pagespeed.conf are been removed and looks like it overwritten with default pagespeed.conf file. Is it possible to prevent it somehow?


Do you have to include <link rel="icon" href="favicon.ico" type="image/x-icon" />?


I didn't include the following line of code in my head tag, however my favicon still appears in my browser:

<link rel="icon" href="favicon.ico" type="image/x-icon" />

What's the purpose of including it?


How to convert UTC timezone to getTimezoneoffset()?


Here is the UTC date/time: 2014-06-01 12:00

how can i convert the above date and time to a new timezone with this:

new Date().getTimezoneOffset(); or even this:

-(new Date().getTimezoneOffset() / 60);


Mute Video in Safari


Safari doesn't support the mute attribute in a video tag. So the following video will not be muted in Safari:

<video id="video" width="180" autoplay="true" muted="true"></video>

How can a video be muted in Safari?


sql caching disadvantage?


I have a web server with a lot of web sites with many database operations, and i am tryng sql caching as a way to improve the performance of my server.

In general, is there any disadvantage about sql caching in a common environment?

Thanks


How to see full query from SHOW PROCESSLIST


When I issue SHOW PROCESSLIST query, only first 100 characters of the running SQL query are returned in the info column.

Is it possible to change Mysql config or issue a different kind of request to see complete query (the queries I'm looking at are longer than 100 characters)


for input type="number" how to set default value to 0


For a textbox that accept numbers as shown below, how can the default value be set to 0? <input name="smtpPort" type="number" id="smtpPort" size="30" maxlength="50" class="input-full" tabindex="4" value="{{model.PortNumber}}"> Though the value in DB is null, it still shows 0 in textbox. Any help would be appreciated.

Form submit button embeded in gmail doesnt work


I want to embed a form in my mail content so that the reader can fill it and submit it. I see that it almost works except that in case of gmail, clicking on submit button does nothing. Is gmail deliberately doing this? Can I use javascript to overcome this?


How to use AJAX and servlets to display database values from a form?


I have a form with multiple buttons one for inserting into a MySQL table,other for viewing it,other for editing the table and final one for deleting the content. How can I implement this using a single servlet and Ajax for dynamically displaying the table after each operation. Please help :)


huge sql dump even after deleting large number of rows of data


The size of sql dump is same(30GB) even if I delete large number of rows from mysql (myisam) table

note: this variabe is innodb_file_per_table ON

mysql> delete from radacct where YEAR(acctstarttime)='2014';
Query OK, 1963534 rows affected (1 hour 30.58 sec)

How can I run a SQL text file on a MySQL database?


I am new to MySQL. I want to execute a text file containing SQL queries.

I tried to run source /Desktop/test.sql and received the error,

mysql> . homesivakumarDesktoptest.sql ERROR: Failed to open file 'homesivakumarDesktoptest.sql', error: 2

window.location to download file with large request data


We are using window.location() to download files from server. We are sending a JSON string along with request. As this being a GET request, I am forced to have restriction on the length of the JSON string. How can I send more data with window.location? sort of POST request to download the file.


mysql query to find price between size string attribute


In my table product size (width*hieght) will saving as below format

 ID    size      Price
    1   10*12     100 
    2   22*28     200 
    3   32*38     300 

When a User will search a product with width 20 & height 25 ,Then i need to get price of 200 second row of table . Please help me to write a mysql query for this.


(Non-remote) Chome Dev Tools ("Inspect element") equivalent on Android?


Is there any way to have the Chrome Developer Tools or Firebug or something similar on Android without using another computer?

I'd like to use my Android Tablet + Bluetooth keyboard as a notebook replacement, and inspecting and debugging HTML/CSS/JavaScript is the only major feature I'm missing.

Thanks in advance!


How do I clear the contents of a div without innerHTML = "";


I have a div that is filled by JS created DOM elements,

I want the div to be cleared upon the JS function repeating, however I have heard that using document.getElementById('elName').innerHTML = ""; is not a good idea,

What is a valid alternative to doing this to clear the div's contents?


error with the replace function in mysql


I have a problem with the replace function in mysql for example

set @str = "Category, CategoryName, CategoryID";
SELECT REPLACE (@str, "Category", "125");

I would replace only the first word "Category" and here's the result:

125,125Name, 125ID

how to fix the problem

thank you in advance


Best text editor for HTML, CSS, PHP [on hold]


I have been using Sublime Text for more than 2 years now, but I don't manage to get LiveReload to work. So, I gave up and started looking for other similar programs that offer a plugin to auto reload the browser when changes are made and saved.

Is there a similar programme like Sublime Text?

Cheers!


mercredi 6 juillet 2016

Convert Mysql group by to ORM


I have a MySQL query that I need help converting to use django's ORM

select * from TABLE where ID=10 group by LOCATION order by DATE DESC

Thus far I have TABLE.objects.filter(id='10').order_by('-date') but I am unsure how to do the group by in Django.


Php - How to make an efficient user online and offline determiner ?


I have 1000 users and they have people to a peer like a G+ circle but i want to know if a person is online to chat but I have tried to update a chat database with a timestamp and its not as efficient I want to know if there is another way even if complex but efficeint Ideas pleas


Wrap a text within only two lines inside div


I want to wrap a text within only two lines inside div of specific width. If text goes beyond the length of two lines then I want to show elipses. Is there a way to do that using CSS?

e.g.

Sample text showing wrapping
of text in only two line...

Thanks


MySQL - How to delete rows where column does not contain certain values?


I'm trying to delete all rows where a specific column does not contain certain strings. Like this:

DELETE * FROM table
WHERE Disease NOT LIKE (Malaria, HIV, E. coli O157);

I get this error: #1064 - You have an error in your SQL syntax; near '* FROM table WHERE Disease NOT LIKE (Malaria' at line 1


Center image in a link


I am having an affiliate link and in it also an image. It looks like this:

<a href="my/link"> <img src="my/image"> </a> <img src="my/image"/>

How can I center the whole thing? I am using it inside a wordpress table through tablepress.

Thanks!


keeping form values after POST as a paramter of python file


I have a form, which one submitted goes to a php file and inserts values into DB(MySql).After successfully inserting values into DB,I want to use the values of this parameter form as a python file in another php file when i submitted .

file register.php -> file description.php (button start) -> file exucuter.php( execute pythonfile)


How to get saved images in Elgg


I'm saving an entity object of type entity and subtype album. When saving the album, I also save it with image files who's $ownerGUID = $album-> GUID. They get uploaded OK. The problem I'm now having is when it comes to retrieving the images. How can I go about listing all the images that belong to a particular album? Thank you all in advance. Elgg 2.X

How much space does inserting 100GB data in 5 tables to SQL Server need?


There are 5 tables (files) which have about 100GB size, because of indexes the size increases in database. How much space do I need? I have not professional skill in Microsoft SQL Sever, is the importing needs any configuration for efficiency? I don't think MySQL can handle the data, is it right?

Could you tell me any advice or tip for this work?


NULL php variable inserting as blank into mysql db


I tried unsetting my $variable with unset($variable); and $variable = ($variable == '' ? NULL : $variable); (to set empty variables to NULL) and my var_dump is outputting NULL as intended, but my INSERT in the mysql database is showing up empty (blank). If I define $variable to foobar then it INSERTs foobar as intended. Any suggestions?


Make navbar collapse menu appear on all screen sizes


I have a question concerning bootstrap navbar. I want the collapse menu that appears on mobile, to also appear on larger devices. Since the code is rather large, I will have to share the codepen:

code link http://codepen.io/diazabdulm/pen/KMaREN 

http://codepen.io/diazabdulm/pen/KMaREN


Formatting code with <pre> tag in React and JSX


I am trying to use the pre tag inside of JSX.When you use the pre tag in JSX, it doesn't format at all. Why? In order to use the pre tag I need to do something like this:

const someCodeIWantToFormat = "var foo = 1"
const preBlock = { __html: "<pre>" + pythonCode + "</pre>" };
return(
  <div dangerouslySetInnerHTML={ preBlock } />;
)

Why?


mysql says database is corrupted but check says all tables are "OK"


Here is the error I get on startup: http://pastebin.com/1yM1wFMR

When I type mysqlcheck --all-databases -p it says all databases are "OK"

Also, mysql ONLY starts when innodb_force_recovery = is set to 2

How could I go about debugging this further?


how to sum of two coloumn of different tables where customer_name is same in both in php


I have two tables

  • order_tb
  • delivery_tb

I want to sum of their two column i.e paid amount from table order_tb and now_paid from table delivery_tb.

In both table the order_no is same.

Can anyone suggest me how to do that.


Ho to dispaly the three biggest numbers of one of the columns of a database table?


I have to write a php script to find the three biggest numbers of a column in a database table. This is my code so far, but it doesn't work .

<?php
$con=mysql_connect("localhost","root","");
$db=mysql_select_db("pool");

 $res1=mysql_query("SELECT * FROM buy ORDER BY value LIMIT 3 ");

 while($r1=mysql_fetch_array($res1)){
     echo $r1['value']; 
  }
?>

MySql server PID not found


I have CentOS 6.4 with NGINX.

When I try to start/stop/restart mysql server (/etc/init.d/mysqld restart) I get this error:

MySQL server PID file could not be found!                  [FAILED]
Starting MySQL..The server quit without updating PID file ([FAILED]/mysql/mysqld.pid).

What can I do to solve this problem?

Thanks!


Update the date in the database with +1 month


I have a date column in my users what I want to update with a SQL query

With the SQL query I want to add 1 month to date column in my database.

I now have:

UPDATE users SET date=(+ 1 month)

When I run this query it is not working. So my question is, how can I make this working?


Update error in postgres SQL


CREATE TRIGGER INSERT_salesorderdetail
before insert on salesorderdetail
for each row 
UPDATE customer
set number_of_items=IFNULL(number_of_items,0)+1
where new.customerid=customer.customerid;

I have 2 tables salesorderdetail and customer and i want each time i inserts a new item in salesorderdetail to update my columne in customer the number_of_items but for some reason i get a syntax error in update.


Google Search based Gif maker


I am required to create a gif maker which makes gif out of images(first 20) that we get while doing a Google Search on a keyword(User Input).

I am a beginner and I have an intermediate experience in Java, Html & Javascript I would like to know how to approach this problem statement. Will I be able to do this problem with my preferences(As said above)


Modifying WordPress Query --> Order By Custom Value In Another Table


I created a new additional table that ranks the posts similar to the one below: ------------------ | post_id | rank | | 6 | 3 | | 4 | 1 | | 5 | 2 | ------------------ I'd like to sort the posts in my site's search results so that they're ordered by the ranks from this custom table. I would like to leverage WP's built in functions but is there a way to do that using $query->set()? if ($query->is_search) { ... $query->set('orderby', ???); ... }

increse numbers from 00000


I want to increase numbers from 00000 to 99999. I tried, but its not working. Below is my code. I am trying from 10 hrs. but result is same. Please help. $result=mysql_query("select rid from regid") or die (mysql_error("No Record Found")); while($row=mysql_fetch_array($result)) { extract($row); $sub=substr("$rid",15); //It is substring 00000 coming from database. $n2 = str_pad($sub + 1, 5, 0, STR_PAD_LEFT); // It is code line. echo $n2; }

How to add links within a HTML banner?


I'm sort of new here and to HTML so would appreciate any help greatly :)

So what I'm trying to do is create a responsive site with a banner. I can't seem to add image map tags to the banner as I have made it responsive.

http://pastebin.com/H71PwqUA

Thank you for your help :)


Adding new row with a dropdown box with values from database using javascript?


in my page i am trying to add new row with a drop down which containing values from database for this i am using java script and ajax, but when i click add new row button it adding a first row perfectly, but when i am hitting same button for second row that time a row is added but the drop down menu is empty. Can you please help me out. Thank you.

No anchor link when refreshing page?


I have several anchor links on my webpage. I'd like to make it so that when the user refreshes/reloads the page, the page does not follow the anchor link in the URL, and goes to the top of the page. I have tried stripping everything after the # on the backend, but I can't imagine there isn't a more elegant solution. Is there a way to do this on the front-end, using HTML/JS?

mysql - Convert SQL query to Rails2 ActiveRecord query


i have following sql query, i want to convert it to rails 2 ActiveRecord query. SELECT sa.emp_id AS id,sa.emp_name AS Name, sa.emp_supv AS child_id, sa2.emp_name AS child_name FROM employees AS sa LEFT OUTER JOIN employees AS sa2 ON case when ifnull(sa.emp_supv,0)=0 then sa.emp_id else sa.emp_supv end= sa2.emp_id where sa2.emp_name LIKE '%Nancy%'

mardi 5 juillet 2016

Mutual friends sql with join (Mysql)


I have two tables

users table:

id|name

user_relationships

id | user_id | friend_id

and want to get names of mutual friends of 2 users. i.e:

user_relationships
1 | 1 | 3
2 | 2 | 3  

users
3| sammy

users 1 and 2 have mutual friend 3. I want to get his name 'sammy' in one query.

How do I do that?


Deleting files from pre installed python folder of mac


Is it safe to delete files/folders from the site-packages folder?

/Library/Python/2.7/site-packages/mysql

The read me file in this folder says :

This directory exists so that 3rd party packages can be installed here. Read the source for site.py for more details.

I want to delete the files and folders to get rid of the connector/python i had installed earlier.


How summing qty by name in the barn and Item Name If the data obtained like this ? SQL


select c.location_id as id_gudang, c.location_name as nama_gudang, a.item_code as id_barang, a.item_name as nama_barang, sum(b.item_qty) as qty from t_inventory as a join t_inventory_transaction as b on a.item_id = b.item_id join t_site_location as c on b.whse_id = c.location_id group by a.item_code and c.location_id order by which dark circles

Why when I download the file, Chrome always says Faild - Network error


I use Codeignter and the address link was not problem and the upload method is places the file to the place i want. So Basically there was no problem with my href. Heres the code. <?php if($ticket_detail->attachment != null) echo "<a href='".$ticket_detail->attachment."' download>Download</a>"; else echo '-'; ?> But when i always downloading it, the Chrome always says Failed - Network error

Connect to external database (MySQL) - Using Swift


I'm starting a new project, and so far, every time I connected to a MySQL DB, I used a PHP to retrieve the information and parsed it to JSON, however, I want to know if there are any other methods or resources to do so (like an API, for example). What I would love to do is a way to send a command, for example: select * from ????, directly from the app (as a String), or something alike.

How to close DOM Window jquery?


In example 3 on the below mentioned link http://swip.codylindley.com/DOMWindowDemo.html

Can you add a link within the window to close it?

Window.close(), self.close() and parent.window.removechid() aren't working

I think they have modified the functionality of close() in jQuery.DOMwindow.js

Plz help.


Storing sorting terms in URL so can be bookmarked


I am currently creating a simple single page application where you can sort entries by name and so on. What I am looking to accomplish is a way to store the current sort chosen (but not a different web page, something similar to a PHP Get). I am not very confident or familiar with Javascript, AJAX and so on because of this I do not know how to store and read from a URL in JS.


Antialiasing text on canvas


I have to create .pngs for a lot of clients that are printed by an industrial inkjet (ads on back of a children's magazines).

Unfortunately, all browsers seem to switch on antialiasing - no matter what I try. Neither CSS nor ctx.mozImageSmoothingEnabled=false; seem to work.

Does anyone have any idea to get text displayed on canvas WITHOUT any grey-scaled pixels trying to make the font sharper?


import sql file in php


I am trying to import a sql file throug php via shell_exec function. My code is as follows,

shell_exec("C:wampbinmysqlmysql5.6.12bin>mysql -h localhost -u root blank_db < C:wampwwwmy_websqlblank_db.sql")

My database name = "blank_db". and there is no password set for mysql.

The above command is running successfully in cmd. but not it in php


How do you handle optional parameters in PHP PDO?


I have a MYSQL table with 5 fields, 2 of which can be null. I have to write PHP PDO for insert and update commands so that users can edit the table. For insert I used a switch statement with 3 cases to account for optional fields. I started writing update when I realized I would need 16 cases for all combinations of fields since all but the primary key can be updated. Is there a more efficient way to accomplish this?


debugging with GDB throw "lost connection to mysql" errors


I tried to debug a program with gdb because it crashing randomly (after some days, after some hours..). But when I tried to debug it, my program throw these errors: "Lost connection to MySQL server" and "MySQL server has gone away"

I don't get these errors when I'm running my program without gdb, so what's the problem with the gdb?

I tried to incrase the max_allowed_packet to 256M in my.cnf, but not worked..


Connect to MAMP local server (MacBook) from Windows computer


I'm having trouble connecting to a local server hosted on a MacBook/MAMP. My .NET application (running on a Windows computer) smoothly connects to another Windows machine (MySQL server) with the same connection string "server=[computer's name]; user id=xxxx; password=xxxx; database=xxxx" but when I use this MacBook's name, I get the following error:

"Unable to connect to any of the specified MySQL hosts"

Note: File Sharing is turned on

Please help. Thanks!


Saving Html from Webpage and Prevent XSS


I am reading Html from webpage inside div content using jquery HTML Code <div id="content"> Html Code </div> Jquery Code var htmlContent = $("#content").html(); and saving it directly into database using Ajax Request. But if somebody inject the Html or Javascript code into the Html Content of the page, that is also getting saved into database. When next time html is loaded on page it is infected with XSS attack. Is there any way I can prevent XSS attack..

Form does not open in new tab


this is the code I am using, I have specified target="_blank" in the form however it doesn't open in a new tab.

<script>
function process()
{
var url="https://website.com/search/" + document.getElementById("url").value;
location.href=url;
return false;
}
</script>
<form action="https://website.com/search/" target="_blank" onSubmit="return process();">
Search: <input type="text" name="url" id="url"> <input type="submit" value="go">
</form>

Can't access my website hosted in godaddy from 2 devices in same wifi


When i try to access my web pages (hoasted in godaddy) in more than one device (uses php and mysql) from same wifi network, Only one device is giving the response at a time. (At the same time i can access any number of them from mobile network). I didn't understand the reason for this problem. I have searched a lot about it on web but didn't find anyone facing the same issue. So what you think about this problem? How can i fix it?

Is it best practice to define global JavaScript objects in HTML?


I have a web project that has the following lines of code in it <script>var obj = {...}</script> <script src='./app.js'></script> ./app.js loaded by the second script tag uses obj defined by the first script tag. You could say that obj is a global variable to ./app.js. I don't want to define obj inside ./app.js because it's a very large object but is this bad practice to define global variables like this?

mysql Group by in nested query


I have employee_id,status and payment field. I need to produce two different output ( sum(payment)) with two different condition. The problem is when i use group by, it produce the total sum of all rows, whilst I want it to group by the employee id. this is my query: select employee_id, (select sum(payment) from tblempay where status=1) AS 'Total 1', (select sum(payment) from tblempay where status=2) AS 'Total 2' from tblempay group by employee_id hope somebody can help me. Thank you.

Data too long for column 'descr' at row 2


When I try this sql statement to execute

update claim cl set search_field = (select  concat(cl.claim_description,' ', cl.legal_basis,' ',co.name) from contact co where cl.probable=1 and cl.search_field is null and co.id=cl.contact_id)

I get error above, and there is no column named descr. There is column named claim_description but it isn't descr

Does anyone have hint? Thank you


array unique not working in php


array unique not working in php? what am i doing wrong?

<?php
$selectquery=mysql_query("select menumanagement.*,usermanagment_permission.* from menumanagement,usermanagment_permission where usermanagment_permission.permission_menu_id=menumanagement.mn_id");
while($selectquery1=mysql_fetch_array($selectquery)) {
  $menunam=$selectquery1["mn_menuname"];
  $ddddd=array($menunam);
  print_r(array_unique($ddddd));
}
?>

output:

Array ( [0] => Applicant ) 
Array ( [0] => Skill Set )
Array ( [0] => Applicant )
Array ( [0] => Add Employee )
Array ( [0] => Applicant )
Array ( [0] => Add Employee )
Array ( [0] => Skill Set )

How to compare a query to a table in sql


I have queries that finds people that are subscribed, and inserts their emails into a table. To update this, it always truncates the table and inserts all records in it again. Now I want this to not truncate and insert all the data each time (takes a long time for very large records), but do the selection and check with the old table if there was a change, and only add/remove those few records to the table.

Any Idea how would I approach this solution?


Find No. of newest entries in MySQL?


I use this query to get the newest 1 entry:

SELECT * FROM Data ORDER BY ID DESC LIMIT 1

I am using node-mysql in nodeJS, I would like to use the

rows[0].Data 

So I can get the 4 newest entries in separate variables, how can I achieve this?

I am aware that I can up the DESC LIMIT to 4, to limit the results, but am still failing trying to get more than 1 result.


group_concat_max_len value gets changed to default on restart


I am changing the value of group_concat_max_len to 15000 using SET group_concat_max_len=15000; I achieve what I what but when I restart mysql server, it is set to default 1024. How can I make it static to 15000, I assume, I should be able to set this value in mysql config file. I added group_concat_max_len=15000 in my.cnf and restarted the server. The value remained same i.e 1024. Can I set it in a way so that the value remains same when mysql server is restarted?

MYSQL - Total registrations per day


I have the following structure in my user table id(INT) registered(DATETIME) 1 2016-04-01 23:23:01 2 2016-04-02 03:23:02 3 2016-04-02 05:23:03 4 2016-04-03 04:04:04 I want to get the total (accumulated) user count per day, for all days in DB So result should be something like day total 2016-04-01 1 2016-04-02 3 2016-04-02 4 I tried some sub querying, but somehow i have now idea how to acheive this with possibly 1 SQL statement. Of course if could group by per day count and add them programmatically, but i don't want to do that if possible

Hide menu when page loaded - in bootstrap with toggle colapse menu, left right @ mobile [on hold]


I found this menu template in bootsnipp which works fine, except on mobile, I mean when page is loaded, both menus are already in the screen, and I would like that they are hiding when the page is loaded. I'm having troubles in understand the javascript function, in other templates I've seen the "show/ hide .collapse" or the "hidden".

Could anyone be kind enough to help me fixing this feature?

Thanks a lot.


lundi 4 juillet 2016

Simplifying a drop down form input for date: day month year <html>


There are 29+ days in a month, I am creating a form using select and option. But this means I will need 31 options for day, 12 for month and a bunch more for the year. Is there a better way to do it? I'm not looking for plug-ins, I am trying to make some tidy code to replace some old and messy code. Can I use a PHP for loop? And how would I go about doing this? What would it look like (in terms of mixing up the PHP and HTML variables and functions)?

Play music dynamically in html


I am new to web technology , i am trying to play a music file dynamically using python django HTML. i have stored the file location in db and fetching it. <audio control><source src= {{track.songlocation}} type="audio/mpeg"></audio> i am getting following error Not Found: /home/tushar/Music/Tracks/shots.mp3 while, if i statically play the file, its playing <audio control><source src= "/home/tushar/Music/Tracks/shots.mp3" type="audio/mpeg"></audio> How do i solve this issue?

How can I download images in content?


I just want to download images in content with cURL.

For example: Visit any buzzfeed galleries and see content after title. you will see

  1. First content for image <img src="blabla.jpg">
  2. Second content for image <img src="blabla.jpg"> in content

Now I want to download that 1. bla bla with image to my server. I think its name "url to file" sorry for my english. Can you please help me? And also can it make with wordpress too?


Reference current element's height/width


Is there a way in CSS to refer to the width of the current element?

I would like to position an image to the left of another image using margin-left: -width but can't seem to find a way. The image is not a fixed size but it is half the paren't height, if that helps.

I found one other question asking something similar but that was 2+ years ago, before calc() was introduced, and I thought maybe there would now be a way to do it.


MySQL / MariaDB Strict Mode


I was developing some code using MySQL as a DB, with various indexes. I had MySQL running in strict mode.

As an experiment, I switched to MariaDB (also in strict mode) and found that many of indexes were failing because they were too long (above 767 bytes). If I remove Strict mode in MariaDB, the indexes seem to be created.

My question is: are those indexes actually being created, even though they are clearly too large?

If not, how do I deal with indexing VARCHAR strings?


Is there a variable for mysql that returns all?


I have a MySQL query using a WHERE clause based on a variable. I am trying to figure out if there is a way to set the variable to something like a wildcard that would return any value in that field?

WHERE c.call_state_id = $state
AND  (follow_emp_id = $user_id OR follow_emp_id = 117)
ORDER BY $sort 

Instead of limiting the results to 1 specific $user_id, I want to virtually eliminate the AND portion of the query.


input type=file show only button


Is there a way to style (or script) <input type=file /> element to have visible only "Browse" button without text field?

Thanks

Edit: Just to clarify why to I need this. I'm using multi file upload code from http://www.morningz.com/?p=5 and it doesn't need input text field because it never has value. Script just adds newly selected file to collection on page. It would look much better without text field, if it's possible.


Supplier-customer relationship in the same table


I'm no MySQL expert and I have to design a rather complex db for my level.

The problem I'm facing now consist in having a supplier-customer relationship within the same table (macro categories of companies):

Macro table

id    name          mega_id    macro_customer_id
------------------------------------------
1     Furniture     2          2,4,5,35

I want to represent the fact that macro entry with id 1 has other macro companies (which are their customers) described within the same table.

Which is the best way to represent this?

Thanks!


Select results from 2 tables if no matches found in the third one


I have three tables

t1
--------------
userID
userEmail
userName
userType

t2
--------------
businessID
businessUserID

t3
--------------
recordID
recordBusinessID

I need to retrieve records if no results are found in t3

SELECT
   t2.businessID,
   t1.userEmail,
   t1.userName
FROM t2
LEFT JOIN t1 ON (t1.userID = t2.businessUserID)
LEFT JOIN t3 ON (t3.recordBusinessID = t2.businessUserID)
WHERE userType = 'active'
AND t3.recordID IS NULL

It seems like I should be getting results, because my current t3 is empty, but I don't. What am I missing?


SQL Export all rows and Delete all rows


Hi this is my first post and I Was hoping someone could give me some helps and give me some ideas for solutions here. I am inserting entries into rows and i do not want the table becoming overwhelming and confusing. . . I would like to export the rows into a csv or excel using the export function and then delete all of the rows after x number of inserts. Currently I am on a windows computer doing the test server, but it will likely linux in the end. Any ideas for how this could happen would be great. . .

Does Statement.RETURN_GENERATED_KEYS generate any extra round trip to fetch the newly created identifier?


JDBC allows us to fetch the value of a primary key that is automatically generated by the database (e.g. IDENTITY, AUTO_INCREMENT) using the following syntax:

PreparedStatement ps= connection.prepareStatement(
    "INSERT INTO post (title) VALUES (?)",
     Statement.RETURN_GENERATED_KEYS
);

while (resultSet.next()) {
    LOGGER.info("Generated identifier: {}", resultSet.getLong(1));
}

I'm interested if the Oracle, SQL Server, postgresQL, or MySQL driver uses a separate round trip to fetch the identifier, or there is a single round trip which executes the insert and fetches the ResultSet automatically.


Incorrect Padding error while decoding base64 encoding


I have tried to decode a PDF I stored as BLOB and save it into a file with .pdf extension. results[0][1] has the BLOB data extracted from database query.

         blob_val=results[0][1]
         if len(blob_val) % 4 != 0:
            while len(blob_val) % 4 != 0:
              blob_val = blob_val + b"="
            decod_text = base64.b64decode(blob_val)
         else:
            decod_text = base64.b64decode(blob_val)

Eventhough i have added = at the end to correct padding errors, it is still showing incorrect padding error. why does it still shows this error even when we corrected it by "="?


Return boolean or 0/1 if rows in the columns are true


I have searched the net regarding this question but so far there are either no respone yet or it is not working

--------------------
formID | validation
2000   |   true
2000   |   false
2000   |   true

I want it to return true if all rows for that grouped (formID) are all true else it will return false. It can be both in literal or 0/1. I will be using the returned value in java

Similar to this question but for MYSQL

Return true if all column values are true


Like statements parameterized @query%


I would like to ask your help about parameterizing a like statement.I need to get the rows which starts with the variable code. I have a problem with my sql statement in c#.whenever i try to use this:

SqlCommand sql2= sql.SelectCommand = new SqlCommand(@"Select * 
             from book 
             where Date like @date+'%' 
             order by Category,Paticulars,Description,Amount", 
             this.connection);
sql.SelectCommand.Parameters.AddWithValue("@date", code);
SqlDataReader reader=sql2.ExecuteReader();

it does not return anything.but if i tried to add a '%' before the date it works properly.


How to resize iframe with real size


I've visited lots of posts but none of them gived me an answer that works. I want to resize an iframe to the parent, for example a div. The iframe tag resizes dynamically the width, but not the height. How can I dynamically resize both? If I write: <iframe src="http..." width="100%" height="400"></iframe> it always is 400 px of height. But if I put a % there too it doesn't resize properly.

And if I want to have the iframe width and height of the page it is referencing in src, how can I do it?


Stop Onclick Execution when middle click is pressed - javascript / jquery


This is something like my code:

<li class="dropdown" id="dropdown1"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown<b class="caret"></b></a>
  <ul class="dropdown-menu">
       <li id="li-1"><a href="#" onclick="Alert("li-1")">List1</a></li>
       <li id="li-2"><a href="#" onclick="Alert("li-2")">List</a></li>
  </ul>
</li>

but when middle click is pressed i want to stop execution of my onclick event


TypeError: not all arguments converted during string formatting. What am I not doing right


I have tried:

sql = "INSERT INTO "+ tablenane + " ("+ ",".join(headers) +") VALUES (" + ",".join(["%s"] * len(headers)) + ")"

and:

sql = "INSERT INTO "+ tablenane + " ("+ ",".join(headers) +") VALUES (" + ",".join(["?"] * len(headers)) + ")"

but still get the same error when I run cursor.executemany(sql, dataset)

dataset = [(a,b,c),(d,e,f)] - A list of tuples

Both columns and values are dynamic, because there 40 columns. All table columns are of type VARCHAR and I ensure the data is converted to string before insertion

Using python 2.7 and mysql


Validating an Email in JavaScript [duplicate]


This question already has an answer here:

I'm using the pattern:

var pattern = /^[^s@]+@[^s@]+.[^s@]+$/;

So when I submit/send an email to myself from my contact form to test out a bunch of different email combinations, everything has worked except for:

whatever@yahoo.com && whatever@google.com

I'm not entirely sure why those two aren't being included, but I'd appreciate any assistance.


Insert at specific 'ID' into my table.


I need to write a PHP script using a database for school. Since my MySQL skills are currently dying, I would like to ask following question: Following problem: I need to insert 'upload' at a specific 'ID' into my table. It should make something like this: insert into PHP_Project() where ID = ;

$pdo = new PDO($this->dsn, $this->username, $this->password, $this->pdoAttributes);
$statement = $pdo->prepare('insert into PHP_Project(upload) where ID = ? values (?,?)');

            $statement->bindParam(1, $filename);
            $statement->bindParam(2, $projectID);

            $statement->execute();

I hope somebody can help me. Thanks in advance!!


HTML PHP: Preventing an iframe from remembering session state on page refresh


Is there a way to declare an iframe in a page so that each time you refresh the page, it clears any session variables within it?

Right now i have a web application written in .NET MVC and on one of its pages it loads an iframe that points to another application written in PHP. basically what is happening is that the iframe is remembering session state when i refresh the whole page but would ideally like to re-start it each time. Are there any ways to do this? or would i need to call a logout script within the iframe on page refresh?


Android move footer up when keyboard is open


I'm designing a login html page which is loaded into an Android WebView. There are two text areas and a "Login" button fixed to the bottom of the page. My problem is that when the person types into the text area; the keyboard pops up and hides the login button.

How can I keep the "Login" button fixed to the bottom of the page but to the top of the keyboard?

I've tried :

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

And

android:windowSoftInputMode="adjustPan|adjustResize"

Neither makes a difference.


join three table in php


I have three table mainaccount, admitcard,result. mainaccount has 40 columns. I want to join all three column. So I can fetch easly all data from table by one query. I have a code. Is it true. Can any one check please. Because code is not running.

require"connection.php";
$result=mysql_query("select mainaccount.*,admitcard.*,result.* from mainaccount,
                    admitcard,
                    result 
                    where mainaccount.email=admitcard.email 
                    AND admitcard.email=result.email 
                    AND mainaccount.email=result.email 
                    AND mainaccount.email='$username'");
while($row=mysql_fetch_array($result))
{
    extract($row);
    if(mainaccount.payment=='done' && mainaccount.formfill=='done')
    {   
          echo"hello";
    }

Canvas - how to fill all circles at once, not one by one


I have while loop drawing circles one by one:

actx.shadowColor = 'rgba(0, 0, 0, 1)';
while (len--) {
   var point = data[len];

   actx.beginPath();
   actx.arc(point[0] - 15000, point[1] - 15000, 10, 0, Math.PI * 2);
   actx.closePath();
   actx.fill();
}

It seems a little bit slow for me, so I am thinking how it could be optimized. I have found that the fill() function takes the longest, so I have tried put it after the loop, but it draws only the last circle.

  1. Is there any way how to fill all the circles at once?
  2. Or is there any other, faster method?

storing iframe current URL in sessionstorage not consist


I am storing to current url of an iframe in sessionstorage and then refreshing after a set time then reloading the iframe with the current url. But it will work for about 2-3 refreshes then it fails and goes to the iframe src URL. Can someone tell me how to optimize this script so it will work everytime.

<script>
if (sessionStorage.getItem('url') == null) {
 window.location;
 } else{
document.getElementById("iframe").src = sessionStorage.getItem('url');
};
sessionStorage.removeItem('url');
setTimeout(refresh, 500000);

function refresh () {
document.domain = 'company.com';
var myURL = document.getElementById("iframe").contentWindow.location.href;
sessionStorage.setItem('url', myURL);
window.location = window.location;
 };

</script>    

dimanche 3 juillet 2016

Should I use form to submit JSON data to REST api


Is it approved to use a html form to build interface to collect user data, convert it to domain model in front end and POST it to server using JSON?

I like to think the user input part as a logical form, event though the server expects JSON. For user it is all the same, so why not just to use a form to collect the data and implement a custom onSubmit method? Another option would be use detached input fields and buttons.

Is this considered a good practice to use forms for JSON POST and what are the good and bad consequences of this practice?


Securing MySQL over SSL [on hold]


During the last couple of months we built a small business environment. We're running a MySQL database on a provider who's not offering MySQL over SSL. As it turns out, it's quite difficult to find a provider. Here come my two questions:

  1. Can you recommend a good provider to host our database with SSL support?
  2. Do you have any hardware recommendations for hosting it ourselves? As mentioned, we're a small business, basically 3 people using the database to work on orders (~20 a day) with minor commits to the database. I thought about something Raspberry style but I'm concerned about performance. I'd appreciate any input on that matter.

laravel 4.2 storing/uploading profilce picture and retrieving from database


i m new to laravel 4.2 i'm am developing a web application ..now i want to store a profile picture into database.

this is my controller file code

public function profilepicture(){


 $data = Input::hasfile('file');

 DB::table('company')->insert(array('data'=>$data));
 return Redirect::to('/companyreg');
}

this is from route file

Route::any('/company_profile','CompanyController@profilepicture');

this is form view

<form method="post"  action="{{url('/company_profile')}}">
<input type="file" name="file" />
<input type="submit" name="submitfile" value="upload" />
</form>

Send POST request data to Mysql Database using Node.js


So I have created a POST route in Express.js and I am trying to create a signup page. I am able to get the form data using req.body but I am unable to send the data to mysql database. I already have functions in the database but I am not sure how to send the data there. Can someone help me here? This is my POST route that I have:

router.post('/register', function(req, res) {


            var firstName = req.body.firstName;
            var lastName = req.body.lastName;
            var email = req.body.email;
            var confirmEmail = req.body.confirmEmail;
            var password = req.body.password;
            var confirmPassword = req.body.confirmPassword; });

Better way to get 15 tables results at a time in MySql


I have some 20 tables. These tables have only id(primary key) and description(varchar). But the data is a lot. Almost 400 rows for one table. Right now I have to get data of at least 15 tables at a time. Right now giving call one by one. Means in on session I am giving 15 calls. This is making my process slow. Can any one suggest any better way to get the results from the database. I am using MySQL database and using Java Springs on server side. Will making view for all combine help me ? Need a solution that will fasten my process. The application is becoming slow because of this issue.

Thankyou.


How to make Bootstrap dropdown-item as hyperlink


I tried the following example from Bootstrap official website with alpha version Bootstrap 4. But the dropdown-item are not like hyperlinks: <div class="dropdown open"> <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Dropdown </button> <div class="dropdown-menu" aria-labelledby="dropdownMenu1"> <a class="dropdown-item" href="#">Action</a> <a class="dropdown-item" href="#">Another action</a> <a class="dropdown-item" href="#">Something else here</a> </div> </div> I tried adding the classes disabled or btn-link into the dropdown-item but items still don't appear as links. I'm looking for a solution without JavaScript

How do I get a non-input element to send with the form?


I have an HTML form. All of the inputs are standard except for the slider. I made the slider out of divs instead of using <input type="range">, so I could add extra functionality and style it easier. How do I get the custom input to be part of the form?

I could've put together a query string and redirected the browser with JavaScript:

window.location.assign("/post?author=" + $("#name").val() + "&rating=" + document.elementFromPoint($("#slider-grabber").position().top + 20, $("#slider-grabber").position().left + 5).innerHTML + "&content=" + $("#content").val());

But that only works for a GET request, and my form sends a POST request.


Laravel: Display query with 10 random rows from mysql with paginate


I want to get from database 10 random rows and then display it on paginate. One page should display only 1 row and next button should display next row etc. Also i have column that contains category id so for the first page i want to display row with cat_id = 1 for third page i want to display row that have cat_id = 3. Please tell me is it possible? I have no idea how to do it.

For now i have controller:

$rows=Row::all()->random(10)->paginate(1);

And it says that there is no paginate method :(


Limit for FOUND_ROWS()?


I'm trying to speed up some SQL queries. My SQL query on pagination is like this (3rd page):

SELECT 
    SQL_CALC_FOUND_ROWS book_id, book_title
FROM
    books
LIMIT 40, 60

And then getting all result count:

SELECT FOUND_ROWS();

But if the result count is huge (milions of books) then FOUND_ROWS() can took very long time.

The fact is that there is no need to count milions of rows (books) and the answer "10000+" is enough for usual user.

Is possible something like this? Pseudocode:

SELECT FOUND_ROWS(LIMIT 10000)

Yesterday and today date in mysql


My date column in my database is in this format: date('Y-M-j H:i:s');. A am trying to run a query to get all transactions done today and another one for all transactions done yesterday. Please help on best way to do this.

I tried the below but it wasn't working

 $yesterday = date("Y-M-j 00:00:01", strtotime("-1 day"));
$yesterday2 = date("Y-M-j 23:59:59", strtotime("-1 day"));

$query_syesterday = "SELECT sum(amount), sum(amtnaira) FROM transactions WHERE transtype = 'buy' AND batch !='' AND date BETWEEN '$yesterday' AND '$yesterday2'";
$syesterday = mysql_query($query_syesterday, $egold1) or die(mysql_error());
$row_syesterday = mysql_fetch_assoc($syesterday);
$totalRows_syesterday = mysql_num_rows($syesterday);

Generate HTML pages from CSV data


I have a .csv file with some data.

The .csv file

I want to make one HTML page for each row. Like for the first row, a page which has all the info.

When user enters the page like for the first row, he should see the details like this :

enter image description here

The champions skins and runes are the additional data i want to display on individual pages but not the main table.

Please someone help me out.

Thanks.


how to assign and set foreign keys from primary key in MVC5


i have two tables tbl_Dues and tbl_Violator. tbl_violator's primary key VID is auto seeded and is treated as a foreign key in tbl_dues I would like to create violator table then in the dues table also create on same index and VID of Violator table must store in VID(foreignkey) of Dues table and when i click create then it must save the record to both tbl_Dues and tbl_Violator

Here is my model i want both VID in tbl_Dues and tbl_Violator to be the same:

[![enter image description here][1]][1]


How to print object values correctly to a DIV using innerHTML?


I'm doing a course at Codecademy and many of their beginner courses use the console.log() command to print to the console. I however would like to try using document.GetElementById() and innerHTML but it instead of printing out the details of the chosen object, it just prints "[object Object]", whereas console.log() prints the details of the key? Here is my code: <div id="myfrndDetails"></div> <script> var frnds = new Object(); frnds.bill = { firstName: "Bill", lastName: "Gates", phoneNumber: "8778787" } frnds.steve = { firstName: "Bill", lastName: "Gates", phoneNumber: "8778787" } var frndCard = function(frndName,frndLst) { for (var onefrnd in frndLst) { if (frndLst[onefrnd].firstName === frndName) { document.getElementById("myfrndDetails").innerHTML = frndLst[onefrnd]; return frndLst[onefrnd]; } } }; frndCard("Bill",frnds); </script>

mysql get all intervals of datetime based on interval hour


I have the following table with datetime type as follows

Id            interval_time                      processed_time
1             2016-07-22 08:00:00                 2016-07-22 09:25:00
2            2016-07-22 09:00:00                   2016-07-22 10:30:00
3            2016-07-22 14:00:00                   2016-07-22 15:23:00
4            2016-07-22 15:00:00                   2016-07-22 14:27:00
5            2016-07-22 16:00:00                   2016-07-22 15:24:00
6            2016-07-22 17:00:00                   2016-07-22 16:40:00

I need to get the all missed interval_time for last 24 hours with the given input time.

I need to get all missed intervals which doesn't exists in table as follows.

2016-07-22 10:00:00
2016-07-22 11:00:00
2016-07-22 12:00:00
2016-07-22 13:00:00

here i can join the table with the list of all intervals of last 24 hours , but how can i get the last 24 hours list with hour as interval.


Positioning titles and img


How do I position "mean design" to be on top of the logo and the description below the logo? the whole thing should be center vertically and horizontally It looks like this now Heres the code now .title { text-align: center; position: absolute; color: white; top: 50%; left: 50%; transform: translate(-50%, -50%); } #logo { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 350px; } <div class="cover-wrapper"> <div class="title"> <h1 id="mean">Mean Design.</h1> <img class="img-responsive" id="logo" src="MeanDesignLogo.png"> <h6 id="des">ui/ux • web design • graphic design • illustration</h6> </div> </div> <!-- cover wrapper -->

pivot rows to columns based on condition


I have a table like so

id  student_id  score
1   1           45
2   2           55
3   2           75
4   3           80
5   1           90
6   2           78
7   3           55
8   1           45
9   1           65

I want to arrange it like this

student_id s1   s2   s3   s4
1          45   90   45   65
2          55   75   78   -
3          80   55   -    -

the concept of pivot is

SELECT
  item_id,
  MAX(IF(property_name = 'property_value1', value, NULL)) AS alias1,
  MAX(IF(property_name = 'property_value2', value, NULL)) AS alias2,
  ...
  ...
  ...
FROM
  table
GROUP BY
  item_id;

which i cannot really figure out in my case, as i am creating the columns s1 - s4 by occurrence, i.e the first score for each student becomes s1, second becomes s2 etc.

how do i solve this


MySql - Create a table and select from it in the same procedure


I’m trying to execute this simple code as a procedure in MySql using the PHPMyAdmin

CREATE TEMPORARY TABLE IF NOT EXISTS jobs AS (SELECT
    *
FROM
    all_jobs
WHERE
        job_object_type LIKE 'jobName'
        OR
        job_object_type LIKE 'jobStatus');

SELECT
    *
FROM
    jobs

But I’m getting an error (#1064) because of my second SELECT query. I’m coming from MS-SQL and there the SELECT would be executed without any problems. How can I execute the CREATE TABLE X query and direct after that the SELECT * FROM X query in the same procedure?

EDIT: forgot to mention that I’m using the MariaDB


Convert SnakeCase DDL to PascalCase for table and columns


Convert SnakeCase Db sql to PascalCase for Table and Columns. IS there a best way to do it ? Example of snakeCase below is in MYSQL and converted to MSSQL.

DROP TABLE IF EXISTS `addresses`;
CREATE TABLE `addresses` (
  `id` int(11) NOT NULL default '0',
  `line1` varchar(255) default NULL,
  `line2` varchar(255) default NULL,
  `city` varchar(255) default NULL,
  `state` varchar(35) default NULL,
  `zip` varchar(10) default NULL,
  `plus_four` varchar(4) default NULL,
  `country` varchar(255) default NULL,
  `foreign_id` int(11) default NULL,
  PRIMARY KEY  (`id`),
  KEY `foreign_id` (`foreign_id`)
) ENGINE=InnoDB;

Want to Convert it to

CREATE TABLE [dbo].[Company](
    [CompanyKey] [nvarchar](15) NOT NULL,
    [Name] [nvarchar](50) NULL,
 CONSTRAINT [PK_Company] PRIMARY KEY CLUSTERED 
(
    [CompanyKey] ASC
)

MySQL #1243 Unknown prepared statement handler (stmt) given to EXECUTE


I am following this tutorial on my installed version of MySQL, but it's throwing me an error: SET @sql = NULL; SELECT GROUP_CONCAT(DISTINCT CONCAT( 'MAX(IF(property_name = ''', property_name, ''', value, NULL)) AS ', property_name ) ) INTO @sql FROM properties; SET @sql = CONCAT('SELECT item_id, ', @sql, ' FROM properties GROUP BY item_id'); PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt; I am pasting it on SQL editor in MyPHPadmin. UPDATE: I followed the suggestion ... no errors shown but here's the result: SELECT item_id ,MAX(IF(property_name = 'color', value, NULL)) AS color ,MAX(IF(property_name = 'size', value, NULL)) AS size ,MAX(IF(property_name = 'weight', value, NULL)) AS weight FROM properties GROUP BY item_id

Webpage image sequencer begins to lag after time


http://www.henryneilson.com/HyBird3/Test.html

I have this image sequencing landing page, that I'm working on^

The sequencer pre-loads about 186 images and shows them sequentially when the document is scrolled.

After all the images are loaded, everything runs smoothly,however after perhaps 10-20 seconds the whole thing starts to lag. It seems that the script is keeping up with changing the image number, but the image won't visually update in the fine increments it should. I just skips frames horribly.

I know I should compress the images more but if it works initially I don't see how it "develops" this lag?


Selecting certain columns from a single row that contain @


I am attempting to extract a single row from a MySQL database table, but with certain parameters specified. The username of the row has to match what was used to login, and the variable $groupname must match as well. I only want to pull out data from the columns whose data contains the @ symbol (so that I know it's an email). What is the best way to do this?

EDIT: The table has the following rows: id, timestamp, username, groupname, and group emails labelled ge1-ge10. I want to pull out only the ge columns from a single row that have content.


Passing a JavaScript variable to a html <select> attribute


I am trying to pass a variable from JavaScript to value attribute of the select tag. Here is my code:

<script>

 if (window.location.href.substring(0, 9) === "http://ww") {
     var home_var = "bing.com";
     var home_var = "poem.com";
 } else if (window.location.href.substring(0, 9) === "https://p") {
     var home_var = "https://px.multiscreensite.com/index.php?url=bing.com";
     var poem_var = "https://px.multiscreensite.com/index.php?url=poem.com";
 } else {
     var home_var = "1";
     var_poem_var = "2";
 }
 console.log(home_var);

</script>

<select OnChange="window.location.href=this.value">
   <option>Tagged Stuff and Navigation</option>
   <option value=HOME_VAR>Home Page</option>
</select>

How to get a border around this polygon?


I have created a shape with 5 corners using polygon as shown below.

enter image description here

This is the css needed to make it:

div {
    width: 280px;
    height: 280px;
    background: #1e90ff;
    -webkit-clip-path: polygon(75% 0%, 100% 50%, 75% 100%, 0% 100%, 0 48%, 0% 0%);
    clip-path: polygon(75% 0%, 100% 50%, 75% 100%, 0% 100%, 0 48%, 0% 0%);
    border: 3px solid black;
    border-bottom-left-radius: 15px;
    border-top-left-radius: 15px;
}

Unfortunately I cannot get it to add a black border all around the shape (it is missing on the right side). How would I do that?

I have created a fiddle here.


how to combine two columns in mysql


its a doubt. I have two tables one table contains student name,roll number,subject id for example

JOHN  22  1,2  
SAM   33  2,1  
ROY   32  1,2

here 1,2 is my subject id. where one belongs to subject1 & 2 belongs to subject2 both are optional for a particular student.

And the second table contain subject1 and subject2 mark.

i want to combine both subjects mark into one column for corresponding students. pls help me

SELECT table1.roll_num,table1.student_name, 
    CASE 
        WHEN FIND_IN_SET(8, 'table1.subject_id') THEN sub1 
        ELSE sub2 
    END AS subject_mark
FROM table2 
JOIN table1 ON table1.student_id = table2.student_id 
WHERE division = 'A 
ORDER BY table1.roll_num asc

samedi 2 juillet 2016

How to detect user input as "zero" and force user to give valid reason in text box given


html code is given as below : <tr> <td>i</td> <td colspan="3">Temperature Of Warming Bin/Chute(140F -150F/60C - 65C)</td> <td>1</td> <td> class="col-sm-12"> <input required type="number" class="form-control" name="b_1_1" id="b_1_1" min="0" max="1"> </div> </td> </tr> And my comment box in html is : <div class="form-group"> <textarea class="form-control" placeholder="Comments" name="Comments" id="Comments" rows="6"></textarea></div> How to force a user to give valid reason if the user input is "0" instead "1" in a textarea below before proceeding to next form. I have a total of 5 forms.

Is it posible to use CSS in this way in PHP?


I'm trying to use CSS within PHP code but it seems that I can't use CSS in the way that I'm trying. why?

<?php 

     $username = "Daved";
$password = "hello!";

 ?>

<html>
<head>
</head>

<body>

<?php

echo "<div style="font-size: 32px; background-color:#f00; color:#fff; width:200px;">And Operation</div>";
if($username == "Daved" && $password == "hello!"){

    echo "<p>The Password and UserName are correct!</p>";
}

else {
    echo "<p>You are not a member!</p>";
}

?>
</body>

</html>

Ok, It's a true way to use CSS like this, or I must to try using style in another way?


000webhost mysql connection error


I am trying to connect to my database using the following code:

<?php
            $mysql_host = "mysql*.000webhost.com";
            $mysql_database = "a******_account";
            $mysql_user = "a******_admin";
            $mysql_password = "******";

            // Create connection 
            $con=mysqli_connect($mysql_host, $mysql_user, $mysql_password, $mysql_database);

            // Check connection 
            if (mysqli_connect_errno($con)) 
            { 
              echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
            };
        ?>

Does anyone know what is going on? The error messages are:

Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'a******_admin'@'0.0.0.0' (using password: YES) in /home/a3996154/public_html/index.php on line 18

and

Failed to connect to MySQL: Access denied for user 'a******_admin'@'0.0.0.0' (using password: YES)


how to add image inside canvas arc


I want to add image inside arc but image should be moved with arc. Currently I have some code and it's working for repeat but when it put no-repeat argument then it gets blank inside arc.

Here is what I am looking for but the image is not centered properly: Image is a wheel.

Here is the code

canvas = document.createElement('canvas');
ctx = canvas.getContext("2d");
var img = new Image();
img.src = (window.location.origin + window.location.pathname) + 'assets/files/' + (wheel.logoURL);
            img.onload = function() {
                var pattern = ctx.createPattern(img, 'repeat');
                ctx.beginPath();
                ctx.arc(centerX, centerY, 50, 0, PI2, false);
                ctx.closePath();
                ctx.fillStyle = pattern;
                ctx.fill();
                ctx.stroke();
}

How to place an "inline image" in form before upload?


I want to allow users to write a post and upload images inline through out it (like a CMS blog post).

Writing the file upload script is easy. But allowing a "place inline" button / functionality is proving to be tricky.
Is there a tutorial on how to do this?

I'm messing around with some JavaScript to allow it. Also, I'm not sure if I should display the inline tmp image or actually upload the file (with a separate upload button than the full form upload button) and show the actual image loc before the form is submitted? I'm all over the place on this right now.

How should I go about this?

Thank you.


Rails can't connect to external mysql server despite Privileges


I run rails on my local dev environment but the mysql instance is on a separate server.

When trying to open a page in the app I get this error:

Access denied for user 'username'@'myhostname.lan' (using password: YES)

When I ssh into the server running mysql and run this command SELECT Host from mysql.user WHERE User='username'; I get the following:

+---------------------+
| Host                |
+---------------------+
| %                   |
| myhostname.lan      |
| localhost           |
+---------------------+

All of these entries were created with GRANT ALL PRIVIELEGES ON dbname.* TO ...

So why can I not connect given that both the any-host wildcard % is in the list as well as the hostname I try to connect from specifically?


Calling addEventListener hundreds of times


Let's assume that I have hundreds of submit buttons on a HTML page. When a submit button is clicked, it calls a JavaScript function called TiedotNettiin which uses jQuery.post() for sending some information to the webserver.

Would it be a good idea to use JavaScript and its addEventListener hundreds of times on a HTML page? Does this require much system resources?

Or would it be better to set interval and run my JavaScript function TiedotNettiin, let's say, every 10 seconds? It would wait 10 seconds, collect all clicks within 10 seconds, make an array, and finally send that array with all new information to the server. This would happen in every 10 seconds instead of every submit button click.

Is there better alternatives?

Thanks for opinions and ideas.


Can't drop table after creating table with wrong engine


I'm trying to drop a table containing several hundred thousand column-based records. Normally when creating the database I use a column-based engine (infinidb) but in this case I forgot to include the ENGINE statement. So the database is pretty much unusable for my needs. Now I have a database full of tables that are taking forever to drop (it's been two hours and nothing has happened). I tried the ALTER TABLE table ENGINE=INFINIDB command but again, it's taking forever (see above re: two hours).

Is there another way to get rid of this database? E.g. manually going into the /mysql/ directory and deleting the database? I guess I could just rename it and leave it, but I'd rather get rid of it entirely so it's not taking up space.


MariaDB error 1064 on UPDATE statement


I need some help here:

I run 2 queries separately on the same table and one yields an error, the other is ok. The only difference is the SET value. take a look:

UPDATE `CRM_Masterlist` SET `contact_status`=1 WHERE `contact`=8888

Result:

SQL query: UPDATE CRM_Masterlist SET contact_status=1 WHERE contact=8888 Matched rows: 0

Anyone has any idea?

UPDATE `CRM_Masterlist` SET `contact_status`=0 WHERE `contact`=8888

Result:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM CRM_Masterlist WHERE contact=8888' at line 1


Bootstrap scrollspy is not working on appearing text


I have a checkbox and when that specific checkbox is checked it shows some text above:

 $('#pck-94').click(function() {
     $('#pico-info').toggle(this.checked);
  });

this wil toggle the text which works and than I wanted to set a scrollspy which scrolls to the text which appears when checkbox is checked here is the html:

<span id="pico-info">(het verjaardagsfeestje Pico Patat is voor kinderen vanaf 4 jaar en maximale lengte 1.30m)</span>

and this is the scrollspy code where the checked is never logged:

   if($('input#pck-94').prop('checked')){
        console.log('check');
        $('body').scrollspy({ target: '#pico-info' });
    }

Here a fiddle : LINK


How can I use variables with "LineString"


I keep getting this error message every time I run this code:

DELIMITER $$

CREATE PROCEDURE BBOX(IN X FLOAT, IN Y FLOAT, IN E FLOAT)

BEGIN

DECLARE A, B, C, D , R FLOAT;

SET R = E/69;

SET A = X - R;

SET B = Y + R;

SET C = X + R;

SET D = Y - R;

SELECT NAME, ASTEXT(LOCATION) FROM POINTS WHERE MBRContains(GeomFromText('LINESTRING(A B,C D)'),LOCATION);

END $$

DELIMITER ;

ERROR 3037 (22023): Invalid GIS data provided to function st_geometryfromtext.

I'm trying to create a Bounding Box procedure that searches for points in my database that are an entered number of miles apart from an starting point.


How to get value of key from properties file javaScript


I have some javascripts in my html code, I want to get the strings form my language.properties file; Here is my language.properties file:

not_yet= you cant do this.
key=key

This is my javascript code:

var not= you cant do this.

How can I do it?

For example in my html I did somthing like this:

<fmt:setBundle basename="language"  />
    <th><label style="float:right;"><fmt:message key="key" /></label></th>

I saw some sulotion to do that in javaScript code but it's not working for me:

var someJSValue = '${language.key}';    

Thank you!


Invalid token #end - Struts Velocity


I placed the following code in enter-protein.vm

 <html>
      <head>
         <meta http-equiv="CONTENT-TYPE" content="text/html; charset=ISO-8859-1">
         <title>Insert title here</title>
      </head>
      <body>
         <h1> Enter Protein VELOCITY </h1>

         #sform ("action = enter-protein")
         #stextfield ("name=enteredProtein")
         #ssubmit("value=Enter")
         #end
         <div>Amount entered: #sproperty ("value = enteredProtein")</div>
         <div> Total for the day : 100 grms  </div>
         <div> #sproperty ("value=goalText")</div>
      </body>
   </head>
</html> 

I get an error at #end as

Invalid token #end

I also included additional directories like commons-collections-3.2.jar, velocity-1.6.2.jar, velocity-tools-view.2.0.jar


Generating line graphs with MySQL+PHP+Morris.js


I'm using MySQL+PHP+Morris.js to generate some line graphs. I want the result graph to look like this: morris.js line graph I understand the data should look like below for morris.js to generate the graph: {"period": "2014 Q3", "A": 75, "B": 77, "C": 79}, {"period": "2014 Q2", "A": 85, "B": 87, "C": 89}, {"period": "2014 Q1", "A": 93, "B": 95, "C": 97} However I'm having trouble getting to this format using PHP+MySQL. My database structure looks like this. table1: numbers ID | name | time | number ------+------+------+--- 1 | A | 1 | 75 2 | A | 2 | 77 3 | A | 3 | 79 4 | B | 1 | 85 5 | B | 2 | 87 6 | B | 3 | 89 7 | C | 1 | 93 8 | C | 2 | 95 9 | C | 3 | 97 table2: times ID | time ----+------ 1 | 2014 Q1 2 | 2014 Q2 3 | 2014 Q3 Is there a way to get the format morris.js wanted? Or is there any other way to generate the graph using some other kind of format? Hopefully I won't have to change the structure of my database :( Thanks much!

Html table filled using php echo and css?


How do I make a empty 5x5 table styled with borders so it looks like a grid, then fill it with the numbers 1-25 using a php loop. This is what I have been able to accomplish so far.

html:

 <table>
  <tr>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</table> 

Php

for($i=1; $i<=25; ++$i) {
        echo $i "<td>";
}

Css

table {
    border-collapse: collapse;
}

table, td {
    border: 1px solid black;
}

Is An Empty Tag Such As <a href="#"> Valid For Accessibility Purposes?


I have a question that I have been struggling to find the answer to and maybe someone here can shed some light on this. I manage several websites that use a featured article scroller on their homepages, which allows the user to click a forward or back arrow in order to see the next article headline and blurb while remaining on the same page. I use WAVE's accessibility checker and any sites that have this particular plugin throw an error back because within the code there is an empty link, written as <a href="#">. Is there any way around this? I've defined a title tag but the # is causing the empty link error to still come up. Some places I've seen that this is perfectly acceptable and others claim this is a problem. What's the actual answer and potential workaround?

Fifo sorting a sql table


I have a table called Transactions which looks like this: Id | date | type | price | quantity | buysell 1 | 0001 | 1 | 1.00 | 3 | buy 2 | 0002 | 2 | 5.00 | 1 | buy 3 | 0003 | 3 | 0.30 | 2 | buy 4 | 0006 | 1 | 1.50 | 1 | sell 5 | 0007 | 4 | 7.00 | 12 | buy 6 | 0011 | 2 | 6.00 | 1 | sell 7 | 0015 | 3 | 0.50 | 2 | sell 8 | 0016 | 1 | 1.50 | 2 | sell 9 | 0017 | .... I need to find a way how to match all sell transactions to related buy transactions. This should be done in the fifo principle: In the example above, transaction 4 should match to 1, 6 to 2, 7 to 3 and 8 to 1 (depending on the type). Also the quantity field has to be considered - transaction 1 for example has two fulfilling sell transactions which sum up to the buy quantity of 3. Is there a way to achieve this with mysql or any other database system? Edit The desired resulset could for example be a table of all sell transactions and their related buy transactions: Id | sellid | buyid 1 | 4 | 1 2 | 6 | 2 3 | 7 | 3 4 | 8 | 1 Based on this table, I can calculate margins or the time it takes to sell something (for example).

Image fade to new image on hover


I am trying to change the background image of a div when a user hovers on an item on the page. I know there has to be a better way to do this.... This is what I have now. '#11' is the div that will be hovered over. '#treeBG' is the div whose background image should change Current image is bg.jpg and I want that to fade out and blur.jpeg to fade in, in its place. $(function() { $('#11').hover(function() { $('#treeBG').css('background-image', 'url("blur.jpeg")'); $('#treeBG').css('width', '100%'); $('#treeBG').css('background-size', 'cover'); $('#treeBG').css('background-repeat', 'no-repeat'); }, function() { // on mouseout, reset the background image $('#treeBG').css('background-image', 'url("blur.jpeg")'); }); }); I have the image changing no problem, I just want it to have a fade transition to look nicer. Any ideas?

MySQL - Querying for records created "today", but date is in UTC


I currently store my datetimes in UTC, and for all purposes, it's worked fine so far. But now I want to query for records created on a particular day, like today, in my own timezone, which is Eastern.

Due to the difference in hours, records I'm creating at the moment will have tomorrow's date. For instance, the date portion would currently be 2016-06-20 in my timezone, but UTC is 2016-06-21.

How could I accurately get records for a particular day in my own timezone when the records are stored as UTC? I was thinking that I could use the convert_tz function to convert the stored value to Eastern, and use that as part of my where clause. That way the dates match up. Is that a reliable solution?


How to exclude a column during fitering in JavaScript



I have a JavaScript (jquery) to filter output of my query. But wen try to filter output table, filter finds hidden column values.

I need to exclude this hidden column during filtering.

Here is the code:

var $rowsActiveUser = $('#ku_list tr');
$('#search_ku').keyup(function() {
 var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
  $rowsActiveUser.show().filter(function() {
  var text = $(this).text().replace(/s+/g, ' ').toLowerCase();
   return !~text.indexOf(val);
 }).hide();
});

and fiddle is here fiddle is here

If you filter "9c" u will see 2 output. One of is in hidden column, other is in MAC address column. I want to exclue hidden one in my filter process. How can I modify my script?


Check a radio button with javascript


For some reason, I can't seem to figure this out. I have some radio buttons in my html which toggles categories: <input type="radio" name="main-categories" id="_1234" value="1234" /> // All <input type="radio" name="main-categories" id="_2345" value="2345" /> // Certain category <input type="radio" name="main-categories" id="_3456" value="3456" /> // Certain category <input type="radio" name="main-categories" id="_4567" value="4567" /> // Certain category The user can select whichever he/she wants, but when an certain event triggers, I want to set 1234 to be set checked radio button, because this is the default checked radio button. I have tried versions of this (with and without jQuery): document.getElementById('#_1234').checked = true; But it doesn't seem to update. I need it to visibly update so the user can see it. Can anybody help? EDIT: I'm just tired and overlooked the #, thanks for pointing it out, that and $.prop().

HTML form variable for execution


i have a HTML form which takes any linux command as an input and I want to execute that command on the server and provide output back to the user. My issue is I am not able to pass the command entered in the textbox to Linux using execCode function. Following is my code.

Please advise how can i get this thing working. Thanks.

<form name="runCommand" method="GET">
  iDirect Command Name:<br>
  <input type="text" name="command" >
  <!--input type="text" -->
  <br><br>
  var = document.getElementById("command").value
  <!--input type="submit" value="Run Command" onclick="execCode('echo document.getElementById("command").value');return false"-->
  <input type="submit" value="Run Command" onclick="execCode('echo var');return false">
</form>

Thanks in advance.


How do I get the element being edited?


I have an HTML div element that has contenteditable set to "true." The div contains a div inside it that has contenteditable set to "inherit." That div also has a child div with contenteditable set to "inherit." Here's what the HTML code looks like:

<div contenteditable="true">
    text
    <div contenteditable="inherit">
        text
        <div contenteditable="inherit">
            text
        </div>
        text
    </div>
    text
</div>

The problem is, I can't find a way to get the selected element in JavaScript, because document.activeElement always returns the root div no matter which child is in focus.

How do I get the most specific element that's being edited, not just the uppermost ancestor?


What is a MYSQL Table (Prefix)? How do I use this with OSTICKETS


I'm trying to install a contact ticketing system osTickets

I don't have much knowledge at all of SQL, I've created a database and a username (linked them together).

I'm getting an error message:

Unable to connect to MySQL server: Access denied for user 'part-box_ost'@'localhost' (using password: YES)

Maybe this is because of the MySQL Table Prefix?

See below osTickets Info

cPanel SQL

What can I do? Do I need to create a Table? if so what do I add?


vendredi 1 juillet 2016

Propel Code for Join over Columns from mulitple table


I have the below query that i am trying to convert to propel in php

select destinationdir.* from destinationdir
left join sourcedir on sourcedir.path = destinationdir.path 
where destinationdir.pullrequestid = '421603579'
and destinationdir.checksum <> sourcedir.checksum

I managed to write upto below code(not sure if its right)

$c = new Criteria(); $c->addJoin(DestinationdirTableMap::COL_PATH,SourcedirTableMap::COL_PATH,Criteria::LEFT_JOIN); $c->add(DestinationdirTableMap::COL_PULLREQUESTID,$pullrequestid,Criteria::EQUAL); $result = SourcedirQuery::create('Test', $c)->toString();

For the above i get

SELECT  FROM destinationdir LEFT JOIN sourcedir ON
(destinationdir.path=sourcedir.path) WHERE destinationdir.pullrequestid=:p1
Params: destinationdir.pullrequestid => 621440992

I dont understand how to add "destinationdir.checksum <> sourcedir.checksum" into the propel code.

Any help would be appreciated.


How to circumvent the infamous "unterminated string literal" error?


I attempted to load a simple HTML file into a canvas (browser = ff 3.66).

var canvas= document.getElementById('oneElement');
var ctx= canvas.getContext('2d');

var img= new Image();
ctx.drawImage(img, 0, 0, img.width, img.height);
img.src = 'data:text/html,&lt;table&gt;&lt;tr&gt;&lt;td&gt;data 1&lt;td&gt;data 2&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;data 3&gt;&lt;td&gt;data 4&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;data 5&gt;&lt;td&gt;data 6&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
'; 

How can I get around this problem?


simple form using bootstrap and php script completely not working


This is a html code for a simple contact form using bootstrap styling and the action linked in form tag to form_check.php I have been hitting my head hard as clicking the submit button doesnt perform any action and gives no output for even the simplest php script.

Heres the html part:

enter image description here

and heres the php script part in its simplest form still it is not working

enter image description here

Please help me out as even clicking the submit button performs no action at all. thanku in advance


Why does an I inside a span inside a button show up as IJ in Safari


I wrote the following code

<button>
<span style="font-weight:500;">I</span>
</button>

but when I run it on Safari I get a button with IJ instead of I written on it. It works just fine on Chrome.

Safari

Safari

Chrome

Chrome

I've noticed this only happens when I have a span inside a button and the font-weight is exactly 500. This issue happens whenever there's an I, for example, if the button read TRY IT NOW it would show up in my Safari as TRY IJT NOW.

I'm running Safari 9.1 (10601.5.8.3).


How to get php site output in html in android webview?


Iam new to android.Iam trying to build an app which uses webview.when webview opens a php url is opening in webview,it contains input field of number ,when user gives input and hit the submit button data is appearing(the data page is also in php)how to get the data page in html? this is my code public class MainActivity extends AppCompatActivity { private WebView webview;

/**
 * ATTENTION: This was auto-generated to implement the App Indexing API.
 * See https://g.co/AppIndexing/AndroidStudio for more information.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final WebView webview = (WebView) findViewById(R.id.webView);
    webview.setWebViewClient(new WebViewClient());
    webview.getSettings().setJavaScriptEnabled(true);

    webview.loadUrl("https://somesite.etc/index.php?service=something");

}

public class myWebClient extends WebViewClient
{
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String Url) {

        view.getUrl();
        view.loadUrl(toString());
        return false;
    }

}}


JavaScript inserting images using string variable as their URL


I'm using JavaScript to parse a XML file. One of the XML's attribute is an URL which links to an image. eg. http://localhost/pic.jpg

As the parsing goes on, I use an variable to hold each URL(which is a string variable) and hoping that I can show these images in a table.

The following is part of my code:

for(i = 0; i < row.length; i++)
{
   // looping through the XML file
   var Logo1 = row[i].getElementsByTagName("Logo")[0].childNodes[0].nodeValue;
   //Logo1 is the string which is a URL
   document.write("<img src= 'Logo1' width='256' height='128'>");
}

I use Chrome, but the images won't load.... enter image description here

Can someone help?


Loop through database record to generate table


I want to construct an html table based on the returned results from the database. Assuming I have a table called constraints in my database and a column called riskName and it has these values: Security, Financial, Legal and Technical as shown in the image below. How do i loop through my database and come up with this table. I have tried different approach but no has worked. Here is my code so far:

<?php
error_reporting(0);
$optioner = 12;
$getObs = $db->prepare("SELECT * FROM constraints WHERE constraintsID = ?");
$riski->bindParam(1, $optioner);
$riski->execute();
$result = $riski->fetch(PDO::FETCH_ASSOC);
while($getObs->fetch(PDO::FETCH_ASSOC)){
echo "<tr><td>".($result['riskName'])."<td><tr>";
//...other code
}
?>
</tbody>
<?php };
?>

enter image description here


Inline CSS being stripped on <td> in Gmail (Internet Explorer) and Yahoo (Windows)


I am building HMTL emails and I use nested tables to layout the email. To change text I apply the styles directly to the < td > tags and this works for the most part across the board. I am noticing though on SOME heavily nested tabled (Greater then 5) the style is being removed completely on Gmail in Internet Explorer, and on Yahoo in various browsers (on a PC). Below is my code:

(This code is ~5 tables deep)

        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td style="padding-bottom:10px;font-family:'Century Gothic',Arial, Helvetica, sans-serif; font-size:26px; color:#202020;">The Latest</td>
          </tr>
        </table>

Has anyone ran into this before or know why they might be stripping the style? It's not only text styles but the padding is also removed on these < td > tags.


Strange issue with mysql php pdo


Well, when i open pdo connection and close setting variable of connection as NULL it close the connection, but if i run some query then try to close and make the script sleep a bit, in show full processlist show as connection opened NULL, part of code: conexao::OpenCon(); $output = self::$link->query('select count(id) from tb01')->fetchColumn(); conexao::CloseCon(); sleep(50); echo $output; These methods: public static function CloseCon() { self::$link = NULL; } protected static function OpenCon() { try { self::$link = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8', DB_USER, DB_PASS); self::$link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); self::$link->exec('SET NAMES utf8'); } catch (PDOException $e) { die($e->getMessage()); } } Very strange cuz it only happens in my CentOs Linux Server, in Ubuntu it works fine, could it be some mysql configs? Please someone help me, thanks.

form model binding in laravel 5.2


I have been reading about form model binding https://laravelcollective.com/docs/5.0/html#form-model-binding It's very cool to populate DB values in html form. I tried like this and this works fantastic. {{ Form::model($university,array('url' => admin_path('universities/edit'),'id' => 'add_university','name' =>'add_university','data-validate'=>"parsley")) }} {{ Form::label('university_name', 'University name',array('class'=>'control-label')) }} {{ Form::text('university_name')}} {{Form::close()}} But the problem is here, Cause i want to add more attributes in input like class SO i am using {{ Form::label('university_name', 'University name',array('class'=>'control-label')) }} {{ Form::text('university_name','',array('class' => 'form-control'))}} If i leave blank valuecolumn then nothing populate in textbox and if i using like this {{ Form::label('university_name', 'University name',array('class'=>'control-label')) }} {{ Form::text('university_name',$university->university_name,array('class' => 'form-control'))}} Then what is use of model binding. Please explain. Thanks

VBA: handling data in Document Object Model


I am currently trying to scrap data from a website using VBA. I am following this tutorial and hence my code is the following one:

Sub Foo()

    Dim appIE As Object
    Set appIE = CreateObject("internetexplorer.application")

    With appIE
        .Navigate "https://www.ishares.com/it/investitore-privato/it/prodotti/251843/ishares-euro-high-yield-corporate-bond-ucits-etf"
        .Visible = True
    End With

    Do While appIE.Busy
        DoEvents
    Loop

    Set allRowOfData = appIE.document.getElementsByClassName("visible-data totalNetAssets")
    Dim myValue As String
    myValue = allRowOfData.Cells(1).innerHTML
    MsgBox myValue

End Sub

Unfortunately there are some differences between data I want to scrap and those ones used in the example: this line

myValue = allRowOfData.Cells(1).innerHTML

is wrong according to VBA debug.

Anyone could provide me with some explanations about why that doesn't work and how am I supposed to pick the right method to scrap HTML pages?


Email signature zoom on iOS Mail


I'm running into some bizarre formatting issues with iOS Mail. I've made a fairly simple HTML email signature 500px wide which renders fine in browsers, desktop clients, Android and iOS Gmail, but when receiving it on native iOS mail it overflows the screen and the user has to scroll horizontally to see the whole thing, rather than the viewport scaling down to fit (which is what all the other clients do). Now this is where it gets weirder. If I put a jpg underneath that's 200px high, it scales down and fits everything in. Halve the jpg height, and it goes off-screen again. So it appears the viewport width is directly proportionate to the like, height of the signature... I don't suppose anyone's come across this before and knows if there's anything I can do, short of sticking a huge jpg underneath? I've included a jsFiddle of my HTML (cheers arkascha) - hope it helps? jsfiddle.net/nn56d3wr

How to set form value dynamically?


I have following code in Node.js:

<% var count = JSON.parse(data).Count;
var countInAPage = 10;
for(i = 0; i < count[0].count / countInAPage; i++) { %>
<form method="get" id="button-form" hidden>
<input type="text" name="from" value=
<% i * countInAPage; %>
>
<input type="text" name="to" value=
<% (i + 1 ) * countInAPage; %>
>
</form>
<button type="submit" form="button-form" value="Submit"><%- i + 1; %></button>
<% } %>

In above code count is coming from back end. Now i want to loop the HTML content, for doing so i need to assign the value for those above input type dynamically (as i tried above <% i * countInAPage; %>); but i am unable to do so.

So what would be the appropriate method or solution for such scenario, where i need to call get method on clicking the submit button?


Responsive image with description


I have an image gallery in my website. All images have description. I want to know if there is any way to make this images responsive and when screen is in mobile size description move to the left of the image. As you see in normal mode description, 1 List item is under the image. <!DOCTYPE html> <html> <head> <style> div.img { margin: 5px; border: 1px solid #ccc; float: left; width: 180px; } div.img:hover { border: 1px solid #777; } div.img img { width: 100%; height: auto; } div.desc { padding: 15px; text-align: center; } </style> </head> <body> <div class="img"> <a target="_blank" href="img_fjords.jpg"> <img src="img_fjords.jpg" alt="Trolltunga Norway" width="300" height="200"> </a> <div class="desc">Add a description of the image here</div> </div> </body> </html> Any Idea?

How to stroke from top-center of rounded rectangle


I want to make a button out of SVG and replicate the YouTube's autoplay circle. I have been trying to get the stroke to start and end at the top-center, but it will start best at the top-left corner, because when I start changing stroke-dasharry and stroke-dashoffset numbers around it starts to go off at the start or end. I know this would be a lot easier with a circle, but I want to see if this is at all possible. It is starting to seem that it is not. svg:hover { stroke-dasharray: 1000; stroke-dashoffset: 1000; animation: dash 5s linear forwards; } @keyframes dash { to { stroke-dashoffset: 0; } } <svg width="160" height="80"> <a xlink:href="/next_video" target="_self"> <rect class="path" height="70" width="130" y="5" x="5" rx="35" stroke="#eee" stroke-width="8px" /> <rect height="60" width="120" y="10" x="10" rx="30" fill="#00a6bc" /> <text fill="#eee" text-anchor="middle" y="45" x="70">Next video</text> </a> </svg>

summarize counts from multiple columns in a single table


I want to display count of data of two category on single display

my table like below :

table : funding
area        client      Donatur
-----------------------------------------
A        Ox      Mr.X
A        Pr      Mr.Y
A        Qs      Mr.Z
A        Ts      Mr.Z   
B        Rt      Mr.X
C        Ss      Mr.X   
C        Sa      Mr.Z   

I want to display data to count based on area and donatur in on table like bellow

Donatur     Count of Area   Count of Client
--------------------------------------------------------
Mr.X          3             3
Mr.Y          1             1
Mr.Z          2             3

I have try to create query like below :

select count(client),count(area) from funding group by area,donatur

But i don't get any right number on one side, the result like below , same on both of them. It' should be like above

Donatur     Count of Area       Count of Client
--------------------------------------------------------
Mr.X          3             3
Mr.Y          1             1
Mr.Z          2             2

How to stop lines of code from automatically shifting to the next line whenever I resize the window of the editor?


I am using Sublime Text 2. When I am on an HTML file. If I resize the window. The code at the very end shifts down to the next line. How do I stop this from happening? I want the code to continue onward, so I will have to scroll side to side to see the rest of the code and not have the shift to the next line.

I have taken screenshots to better illustrate what I am referring to.

Full window of code

After window has been resized. Notice the number lines? How do I stop that? I'd rather scroll right to see the rest of the code instead of having the code jump to the next line.

Resized window

I noticed this only happens in an HTML file.


Add event listener to DOM elements based on class,


I have a table, where each tr and td have only classes, I have a problem with selection of td element having the class I need. HTML:

<table>
 <tr class="data">
  <td class="cell">1</td>
  <td class="cell2"></td>
 </tr>
 <tr class="data">
  <td class="cell">2</td>
  <td class="cell2"></td>
 </tr>
</table>

When mouseover td with class="cell" I have to get text between td on which my mouse and do something with this. This should be done with pure JavaScript, without frameworks. I tried:

var cell = document.querySelector('.cell');

function callback(){ //do something }
cell.addEventListener('mouseover',callback(),false);

It doesn't work, or maybe I did mistakes?


Easy way to do mysql "INSERT INTO" to Mysqllite


Hi I have the following Mysql code (Which i export from Mysql DB before I delete my tables from it). Now I have a MySQLlite DB, and I have the corresponding tables in this database. But when I run the INSERT INTO command exported from MySQL database is not seems to be working in MySQLlite. When I research I see that I need to manually add each row as one single INSERT INTO command. I have 100 of rows. It's almost impossible to do that. Any Idea guys how to do this insertion? Thanks in advance..

MYSQL INSERT INTO Command:

INSERT INTO `DEPT` (`id`, `dept_name`, `bp_name`, `standard`, `created_by_id`, `modified_by_id`, `date_created`, `date_modified`) VALUES
(23,    'DEQP', 'Kaizen',   'IEC 60812',    286,    286,    '2016-05-16 14:32:30',  '2016-05-19 14:25:06'),
(31,    'DEQP', 'test', 'IEC 60812',    286,    286,    '2016-05-22 10:50:06',  '2016-05-22 10:55:55'),
(32,    'IT',   'Design',   'IEC 60812',    286,    286,    '2016-05-22 11:13:06',  '2016-05-22 11:13:06');

Waterline ORM does not populate related data


I can't get the Waterline ORM to hydrate my join. https://github.com/balderdashy/waterline-docs

I have the following two models:

// primary model

identity: 'document',
tableName: 'document',
attributes: {
    id: {
        type: 'integer',
        columnName: 'id',
        primaryKey: true,
        autoIncrement: true
    },

    // reference other models
    data: {
        model: 'document_data',
        columnName: 'id',
    },
},

// related model

identity: 'document_data',
tableName: 'document_data',
attributes: {
    documentId: {
        type: 'integer',
        columnName: 'document_id',
        primaryKey: true,
    },
    body: {
        type: 'text',
        columnName: 'body',
    },
},

I can see the following logged:

MySQL.processChildren: (SELECT * FROM document_data AS document_data WHERE document_id = 2 ORDER BY document_data.document_id ASC)

This is the correct query and I can confirm in the database. But the data key is not populated in the document model. It's just an empty object data: {}