while-loop

PHP Infinite Loop “While” with Class

自古美人都是妖i 提交于 2020-01-07 05:46:10
问题 I made my scripts without class. (framework). Now I have changed my mind & I wanna make my scripts with classes. I like it. But there I have a problem.. Infinite Loop While. I didn't take this problem before with without classes.. While Rule; while ($fetch=$db->fetchObject($db->q("SELECT * FROM auction_house.items ORDER BY id DESC LIMIT ".$min_stuff.",".$max_stuff.""))) { // etc } Class; public function fetchObject($queryRes) { $this->queryRes = $queryRes; $this->record = mysql_fetch_object(

How to get record in while loop

a 夏天 提交于 2020-01-07 05:05:24
问题 producttable : id | mid | pid | owgh | nwgh | 1 3 12 1.5 0.6 2 3 12 1.5 0.3 3 3 14 0.6 0.4 4 3 15 1.2 1.1 5 4 16 1.5 1.0 6 4 17 2.4 1.2 7 3 19 3.0 1.4 8 3 19 3.0 1.2 I need result in while loop as below : as per mysql query $sql = "SELECT pid,owgh,nwgh from produttable WHERE mid = 3 "; RESULT I WANT AS BELOW : Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 ----------------

How to get record in while loop

做~自己de王妃 提交于 2020-01-07 05:05:23
问题 producttable : id | mid | pid | owgh | nwgh | 1 3 12 1.5 0.6 2 3 12 1.5 0.3 3 3 14 0.6 0.4 4 3 15 1.2 1.1 5 4 16 1.5 1.0 6 4 17 2.4 1.2 7 3 19 3.0 1.4 8 3 19 3.0 1.2 I need result in while loop as below : as per mysql query $sql = "SELECT pid,owgh,nwgh from produttable WHERE mid = 3 "; RESULT I WANT AS BELOW : Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 ----------------

I don't quite understand the while loop in python

拥有回忆 提交于 2020-01-07 03:07:23
问题 def AddSingleCard(self): symbols = ['heart', 'diamond', 'club', 'spade'] #newCardSign = '' newCardNumber, newCardSign = raw_input().split() try: newCardNumber = int(float(newCardNumber)) except: newCardNumber, newCardSign = raw_input().split() while (newCardNumber not in (2,15) or newCardSign not in symbols): newCardNumber, newCardSign = raw_input().split() newCard = [newCardNumber, newCardSign] I'm trying to loop until the input will be a number between 2-15, and the string will be one of

Creating file loop

左心房为你撑大大i 提交于 2020-01-07 02:01:20
问题 How can I ask the user for a file name and if it already exists, ask the user if they want to overwrite it or not, and obey their request. If the file does not exist, a new file (with the selected name) should be created. From some research on both the Python website and Stack Overflow, I've come up with this code try: with open(input("Please enter a suitable file name")) as file: print("This filename already exists") except IOError: my_file = open("output.txt", "r+") But this will not run in

scanf() in while loop not terminating?

左心房为你撑大大i 提交于 2020-01-07 01:11:30
问题 I have a while loop that scans in an input set of integers. It scans and prints all of the numbers with "..." at the end and skips to the next line. However, the script does not: execute past the while loop and print TEST. For example, I enter: 3 44 62 1 It prints: 3... 44... 62... 1... When it should print: 3... 44... 62... 1... TEST while(scanf("%d", &n) != -1) { x[i] = n; i++; printf("%d", n); printf("...\n"); } printf("TEST"); What am I doing wrong? 回答1: scanf("%d", &n) != 1 is wrong. It

While loop Vectorization

六月ゝ 毕业季﹏ 提交于 2020-01-07 00:35:54
问题 I would like to know if there is some way to vectorize this code. I tried so hard to do it... but failed. while (delta_F > e) && (i < maxLoop) x1 = x0+d; y0 = f(x0); y1 = f(x1); if y1 < y0 x0= x1; d = a*d; else vF = [vF;x1]; d = -b*d; end i = i + 1; if length(vF) > 1 ultm = vF(end); pultm = vF(end-1); delta_F = abs(ultm+pultm)/2; end end It's a simple implementation of the Rosenbrock method for finding the min of a function. 回答1: In general, Matlab's vectorization works over fixed-size arrays

While loop Vectorization

让人想犯罪 __ 提交于 2020-01-07 00:34:27
问题 I would like to know if there is some way to vectorize this code. I tried so hard to do it... but failed. while (delta_F > e) && (i < maxLoop) x1 = x0+d; y0 = f(x0); y1 = f(x1); if y1 < y0 x0= x1; d = a*d; else vF = [vF;x1]; d = -b*d; end i = i + 1; if length(vF) > 1 ultm = vF(end); pultm = vF(end-1); delta_F = abs(ultm+pultm)/2; end end It's a simple implementation of the Rosenbrock method for finding the min of a function. 回答1: In general, Matlab's vectorization works over fixed-size arrays

wait to trigger action

偶尔善良 提交于 2020-01-06 17:18:31
问题 I am looking to trigger a while loop, but only after the user selects an option. For some reason now, it is automatically blowing through the entire block of code even before the user picks an option. How can I force it to wait to continue until a user selects something? case R.id.buttonSetPlayers: //**********************// //***SET PLAYER COUNT***// //**********************// AlertDialog.Builder builderPC = new AlertDialog.Builder(this); final CharSequence[] playerCount = {"1", "2", "3", "4

wait to trigger action

假装没事ソ 提交于 2020-01-06 17:15:52
问题 I am looking to trigger a while loop, but only after the user selects an option. For some reason now, it is automatically blowing through the entire block of code even before the user picks an option. How can I force it to wait to continue until a user selects something? case R.id.buttonSetPlayers: //**********************// //***SET PLAYER COUNT***// //**********************// AlertDialog.Builder builderPC = new AlertDialog.Builder(this); final CharSequence[] playerCount = {"1", "2", "3", "4