while-loop

Handling while loop and grouping MYSQL PHP Values

给你一囗甜甜゛ 提交于 2019-12-08 07:56:22
问题 I have a table like this. author_id author_book rating 1 ABC 5 1 DEF 6 2 PPP 8 3 FFF 9 Here is my PHP Code <table> <tr><td>Author ID</td><td>Author Book</td><td>Rating</td></tr> <?php $row_data = mysql_query("select * from author_master" ); while($row = mysql_fetch_array($row_data) ) { ?> <tr> <td><?php echo $row['author_id']; ?></td> <td><?php echo $row['author_book']; ?></td> <td><?php echo $row['rating']; ?></td> </tr> <?php } ?> </table> What I would like to do is group the similar author

Loop through rows in an excel worksheet and copy a range if the cell isn't blank

烈酒焚心 提交于 2019-12-08 07:19:20
问题 I have virtually no VBA experience except that, from what I have seen other spreadsheets do, I am convinced this must be possible. I have searched all over but cannot find any explanations to help or code I can just use. I hope someone can help. I have a download from our website cart which does not format the data how it needs to be to then up-load into some new sales order/invoice generating software. As an example here is a link to an image that shows how the data currently looks(the

UPDATE Stored Procedure not Updating

风流意气都作罢 提交于 2019-12-08 07:04:44
问题 I've got a SQL Server stored procedure that references a table in my database where users can manually update values for a rent field ( 'Rent1' ). The procedure compares this rent value to a rent field in a different table ( 'Rent2' ). If Rent1 is different from Rent2 the value for Rent2 Is updated to the value of Rent1 ... or at least that's what is supposed to happen. When I execute this stored procedure, it runs fine and I receive these output messages: (1 row(s) affected) (1 row(s)

cin >> integer and while loop

风格不统一 提交于 2019-12-08 06:57:02
问题 With below code, if I enter a letter or a really long number, the while loop will go haywire, why is that? void main() { int n{ 0 }; while (true) { cout << "Enter a number: "; cin >> n; cout << n << endl; } } 回答1: The problem is that operator>> is expecting to draw an integer off of the input stream, but there is something else sitting there (the non-integer that the user typed). This sets an error state on the input stream. In this state, the cin >> ... construct no longer blocks for input

For Loop vs While Loop

╄→尐↘猪︶ㄣ 提交于 2019-12-08 06:40:32
问题 In my lecture of Design and Analysis of Algorithms the instructor said the for loop will take less time then while loop for the following sample algo. 1. for(int i=0;i<5;i++) { 2. print(i); } 1. int i=0; 2. while(i<5) { 3. print(i); 4. i++; } He said that the compiler will read the 1. of for while 5 times line 2. 4 times thus total time 5+4=9 But in the case of while loop. The compiler will read the 1. for 1 time,2. for 5 time, 3 for 4time and 4. for 4 time. Thus total time 1+5+4+4 = 14time

Excel VBA Find All

限于喜欢 提交于 2019-12-08 06:39:31
As usual, I've wasted hours working on a problem before finally giving in and asking for help, so any help would be greatly appreciated! I'm running a while loop on Sheet Test1 of my data in order to copy data to a specific row on Sheet Test2 where parameters match, but the way I'm currently doing this is by also looping through every row of Sheet 2 - both sheets of data are over 50,000 lines long, so although my method works perfectly for my 10 row tests it is taking several hours to work for the full data. I was wondering if someone could simplify my code, ideally so that it could search for

Excel VBA Find All

女生的网名这么多〃 提交于 2019-12-08 06:19:17
问题 As usual, I've wasted hours working on a problem before finally giving in and asking for help, so any help would be greatly appreciated! I'm running a while loop on Sheet Test1 of my data in order to copy data to a specific row on Sheet Test2 where parameters match, but the way I'm currently doing this is by also looping through every row of Sheet 2 - both sheets of data are over 50,000 lines long, so although my method works perfectly for my 10 row tests it is taking several hours to work

while loop that doesn't wait for cin

蹲街弑〆低调 提交于 2019-12-08 05:38:17
问题 quick question: why wont this while-loop wait for input? (ing is a string) while(ing != "0") { cout << "Ingredient name: "; cin >> ing; for(int i = 0; i < ing.length(); i++) { if(ing[i] == ' ') ing[i] = '#'; } fil << ing << ':'; cout << "Quantity: "; cin >> quant; fil << quant << ':'; } it just spamms "ingredient name: quantity: ingredient name: quantity: ..." and so on 回答1: Not sure what fil is. I think your problem is that you need to flush the stream with a cin.ignore() at the bottom of

Javascript store <select> dropdown values within array

我的梦境 提交于 2019-12-08 04:59:03
问题 I'm wondering if it's possible to store the selected values from a <select> in a JS array. What I finally need to do is calculate the highest 6 values out of around 10 dropdowns, which I think I can do by using the JS Math.max() function. Help is greatly appreciated. Here is some sample code: <? while($subjects = mysql_fetch_array($query)) { ?> <select class="points"> <optgroup label="<?=$subjects['name']?>"> <option value="100">A1</option> <option value="90">A2</option> <option value="85">B1

Using row count from a temporary table in a while loop SQL Server 2008

ⅰ亾dé卋堺 提交于 2019-12-08 04:57:48
问题 I'm trying to create a procedure in SQL Server 2008 that inserts data from a temp table into an already existing table. I think I've pretty much figured it out, I'm just having an issue with a loop. I need the row count from the temp table to determine when the loop should finish. I've tried using @@ROWCOUNT in two different ways; using it by itself in the WHILE statement, and creating a variable to try and hold the value when the first loop has finished (see code below). Neither of these