Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I wanted to get a radar chart using the following query. But the graph is not displayed. What is the problem?
str= "{type:'column',showInLegend: true,name:'"+userdet.getCompname()+"'"
+ ",dataPoints:[{y:"+aa+",label:'self'},{y:"+r+",label:'average'},{y:"+bb+",label:'superior'}]},";
sb.append(str);
I am getting data from the the following table. "aa" is self marks, "bb" is superior marks and "r" representing the average marks. "userdet.getCompname()" will retrieve the competency name from the table report. table report
The LIMIT keyword isn't allowed in an INSERT statement. It limits the number of rows returned by a query.
Your insert query is only ever going to insert 1 or 0 rows (since you only have one set of values but might hit an error if you duplicate a unique key).
If you want to limit the number of rows then you can do two queries:
Count the number of rows (with a SELECT)
Insert the new row (if the count isn't too high)
You should wrap the two queries in a transaction to avoid race conditions.
A cursory Google suggests that there might be database specific approaches to doing an insert if with a row count, but they will depend on whatever database server you are using (and didn't mention in the question).
The Limit 5 is for retrieving the data i.e. it will return 5 rows. I think you dont want to add any rows where there is already 5 rows inserted. You can check first the count of rows in table and after that you can add when count is less than 5.
SELECT count(*) from question;
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
Let's say I have 72 products and each page can have up to 24 items. We know that we will have 3 pages thanks to this, but how can I calculate this mathematically? Let's say the input is 5 how do I calculate that product 5 is on page 1, and product 48 on page 2? Keep in mind that I have thousands of products and while the number of pages are irrelevant, each page may only have 24 items.
It's just maths. How many times the number of products per page can fit into the total product count.
I've assumed some variables with obvious names are around, but some JS code could look something like this:
let totalProductCount = 1234;
let productsPerPage = 24;
let wantedProduct=48;
//Total page count would be the number of times the products per page
//can fit into the total, rounded UP if not a whole number.
let totalPossiblePageCount =Math.ceil(totalProductCount/productsPerPage);
//so same calculation can give the page NUMBER for a given product number.
let pageForThisProduct = Math.ceil(wantedProduct/productsPerPage);
alert (`product ${wantedProduct} will be on page ${pageForThisProduct}/${totalPossiblePageCount}`);
This will say "product 48 will be on page 2/52", and changing the value of wantedProduct will change appropriately
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have three select lists that are filled with table names, column names and attribute names. I push them to a variable like this:
data.forEach(function(field){
fieldList.push(field);
But if I change a select list it adds all the column names of the second table to the array like this:
Here u you can find an exmample of what I want.
If you simply want data of the last selected table, clear array on your event.
fieldList = [];
data.forEach(function(field){
fieldList.push(field);
}
I fixed the problem. Just needed to add this line infront of the code:
fieldList.length = 0; . This line empty's the array before it gets filled again.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have a situation where I get 4, 5 or 6 images/tiles.
Depending on the number of tiles, I need to format the images on the webpage.
Like this http://prntscr.com/9y75dw
If it's five images, I have to format it in such a way that two images in the first row and three images in the second row. Can you help me with the logic?
Well I don't see a technique, maybe I am missing to do that more appropriately or in a generic way but since the description in less and number of images given are random, I don't know how this will work.
var imageLength = $('img').length;
var newLength = 0, differenceLength=0;
if(imageLength%2==0){
//incase of even number
//Do what you like here eg: $('img').css('width', '50%');
}
else{
// incase of odd number
newLength = Math.round(imageLength/2); //dividing number into two parts.
differenceLength = imageLength - newLength; //difference to put smaller above and greater below.
$('parent-div img:nth-child(1)').nextUntil('img:nth-child('+differenceLength+')').wrapAll('<div></div>') //wraps into a container div
}
Although this is just one way. You might have already realized a lot of logic by now.
PS: I have randomly written this code so take it as a logic for help. Not sure whether this will work.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I've seen this how to export javascript array info to csv on client side
which works fine for me but there's a thing that annoys me.
in CSV you can seperate the strings in differents cell with a simple comma (,) so you got like:
[["name1", "city_name1", ...], ["name2", "city_name2", ...]]
and name1 and city_name1 are in the same cell. Is there a way to get them in two different cells in Excel with JavaScript?
When you parse a CSV in JavaScript, the array of arrays that results is not an array of cells. It is an array of rows where Array[0] is a row and Array[0][0] is a cell. What you have here is exactly what you are already asking for- name1 in row 1 cell 1, and name2 in row 2 cell 1.
Why not just set your data up in a hidden html table? The table will pop into the csv complete with your css styles. So if you want name1 and city_name1 in cells 1 and 2 of row 1, and then name2 and city_name2 in cells 1 and 2 of row 2, set the table up like that.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Using Javascript, Html and BFO (Big Faceless Org) PDF Generator, I need to create a table with fixed number of rows for every page in a sales order. Basically, the table should consist of fixed 10 rows, however rows populated with information may only be 1 or 2 rows. The other rows will be empty.
Anyone can help?
Currently all I have is:
for(I=0;i<=salesitem.length;i++){
document.write('<tr><td>salesitem[I]</td></tr>');
}
That generates one td row for every sales item. However, I want a fixed 10 rows in the table.
There are several issues with the tiny piece of code you've supplied...
javascript is case sensitive, therefore I and i are different variables
looping from 0 to i<=salesitems.length will end in an error, because if length is 10 and you use salesitem[10] it will fail (arrays are 0-based, and therefore an array with length of 10 has items 0 to 9)
I believe you think that salesitem[I] will process like PHP, it won't. PHP allows you to use echo "print this $varName", javascript simply doesn't allow that.
Try something along these lines...
for (i = 0; i < salesitem.length; i++) {
document.write('<tr><td>' + salesitem[i] + '</td></tr>');
}
for (i = salesitem.length; i < 10; i++) {
document.write('<tr><td></td></tr>');
}
The first loop will display everything in your array (including any entries over 10)
The second loop will display lines to complete the table (if there are less than 10 entries)
Try this.
for (var i=0;i<10;i++) {
document.write("<tr>");
//This will depend entirely upon what conditions have to be met
//in order for you to display the content of each row
if(variable == 'condition') {
document.write("<td>content</td>");
}
document.write("</tr>");
}