$r = mysql_query ( "SELECT guid FROM characters" );
if (mysql_num_rows($r) != 0) {
while ( $row == mysql_fetch_array ( $r ) ) {
$cap = rand ( 0, $char );
if ($row ['guid'] != $cap) {
$captain = rand ( 0, $char );
}
}
} else {
$captain = rand ( 0, $char );
}
Run Code Online (Sandbox Code Playgroud)
这段代码应该返回我的字符guid,它还没有记录在字符表中.第一部分如果有效,但循环根本不起作用,我试图添加打印"文本"; 在它,但它没有返回任何东西.
我用这个:
//if in landscape mode
while(window.orientation == 90 || window.orientation == -90) {
if(!$('#page' + hiddenNextPage).hasClass('showUp')) {
$('#page' + hiddenNextPage).addClass('showUp');
$('#page' + hiddenNextPage).css('margin-left', '300px');
};
}
//if in portrait mode
while(window.orientation == 0) {
if($('#page' + hiddenNextPage).hasClass('showUp')) {
$('#page' + hiddenNextPage).removeClass('showUp');
$('#page' + hiddenNextPage).css('margin-left', '5px');
};
};
Run Code Online (Sandbox Code Playgroud)
但它使我的页面不再加载..并且它需要这么长的时间来加载它.它有什么问题吗?
是否有更好的方法可以不使用while循环不断检查方向是否已更改?
这是为ipad/iphone
谢谢!
我个人使用while(true)无限循环,但我已经看到在线使用的示例for(;;).实际上,这两者之间是否有任何差异,还是只是一种风格?
我们在C#while循环中遇到了性能问题.循环非常缓慢只做一个简单的数学计算.事实证明,parmIn从999999999到MaxInt ,这可能是一个巨大的数字.我们没有预料到巨大的价值parmIn.我们使用不同的方法修复了代码.
循环编码为了简单起见,做了一个数学计算.我只是想知道包含一个简单数学计算的while循环的单次迭代的实际执行时间是多少?
int v1=0;
while(v1 < parmIn) {
v1+=parmIn2;
}
Run Code Online (Sandbox Code Playgroud) 我的WHILE Loop有什么问题吗?
<?php
include('header.php');
$manage = "current_page_item";
include('nav.php');
include('sidebar.php');
?>
<div class="primary">
<br/>
<?php
$userId = $_GET['id'];
echo "<div class=\"item_list\">";
$sql = "SELECT * FROM user WHERE id = " . intval($userId);
$result = mysql_query($sql);
while($item = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "<b>Title: </b>" . $item['item'] . "<br/><b>Email: </b>" . $item['email'] . "<br/>";
echo "<b>Price: </b>" . $item['price'] . "</b><br/><b>Category: </b>" . $item['category'] . "</b><br/> <b>Extra: </b>" . ($item['extra'] ."</b><br/><b>Date Listed: </b>". $item['date'];
}
echo "</div>";
?>
</div>
<?php include('footer.php'); ?>
Run Code Online (Sandbox Code Playgroud) 我很困惑为什么输出不是我期望它在以下嵌套while循环中:
i = 1
j = 1
while(i<5){
print("i")
print(i)
i = i + 1
while(j<5){
print("j")
print(j)
j = j + 1
}
}
Run Code Online (Sandbox Code Playgroud)
我得到的输出是:
[1] "i"
[1] 1
[1] "j"
[1] 1
[1] "j"
[1] 2
[1] "j"
[1] 3
[1] "j"
[1] 4
[1] "i"
[1] 2
[1] "i"
[1] 3
[1] "i"
[1] 4
Run Code Online (Sandbox Code Playgroud)
但我期待的是一些东西
[1] "i"
[1] 1
[1] "j"
[1] 1
[1] "j"
[1] 2
[1] "j"
[1] 3
[1] "j"
[1] 4
[1] …Run Code Online (Sandbox Code Playgroud) while循环不起作用.当它遇到休息时退出循环时我得到一个错误.错误是没有循环语句来突破.
static void Main(string[] args)
{
accounts myclass = new accounts();
string userin;
myclass.fillAccounts();
//int i = 0;
//while (i != 1)
do
{
}
while (userin != "x")
{
//use the following menu:
Console.WriteLine("*****************************************");
Console.WriteLine("enter an a or A to search account numbers");
Console.WriteLine("enter a b or B to average the accounts");
Console.WriteLine("enter an x or X to exit program");
Console.WriteLine("*****************************************");
Console.Write("Enter option-->");
userin = Console.ReadLine();
if (userin == "a" || userin == "A")
{
myclass.searchAccounts();
}
else if …Run Code Online (Sandbox Code Playgroud) 好的,所以我正在尝试创建一个文件夹,子文件夹及其文件的列表,但是现在它没有打印任何东西,似乎进入了一个无限循环.知道为什么吗?
//infinate loop start
for(int j = 0; j < (int) dirs[i].folders.size(); j++){
dirs.push_back(Directory(dirs[i].folders[j]));
getfiles(dirs[i].dir,dirs[i].files);
getfolders(dirs[i].dir,dirs[i].folders);
}
//infinate loop end
Run Code Online (Sandbox Code Playgroud)
这是完整的来源:
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
struct Directory{
public:
int indent;
vector<string> files;
vector<string> folders;
string dir;
Directory(string mydir){ dir = mydir;}
};
int getfolders (string dir, vector<string> &folders)
{
DIR *dp;
struct stat st;
struct dirent *dirp;
if((dp = opendir(dir.c_str())) == NULL) {
cout << "Error(" << …Run Code Online (Sandbox Code Playgroud) 我写了这段代码:
<?php
mysql_connect("localhost", "root", "root") or
die("Could not connect: " . mysql_error());
mysql_select_db("internal");
$result = mysql_query("SELECT Title, Message FROM msg");
?>
<?php
while ($row = mysql_fetch_array($result, MYSQL_NUM)){
?>
<div>
<h3><a href="#"><?php printf("%s", $row[0]); ?></a></h3>
<div><?php printf("%s", $row[1]); ?></div>
</div>
<?php
mysql_free_result($result);
}
?>
Run Code Online (Sandbox Code Playgroud)
我得到的结果是MySQL表的第一行(使用正确的格式)我包含一个图像以防万一:

(这实际上是我的MySQL数据库的第一行,也是我唯一看到的)
代码循环,直到我不得不添加html标签,我的意思是,如果我只是这样做:
<?php printf("%s", $row[0]); ?>
&
<?php printf("%s", $row[1]); ?>
Run Code Online (Sandbox Code Playgroud)
它循环并带来了所有结果.
这可能是语法错误吗?
我需要在while循环中交替显示三个div .第一个div的类名为box-hdr5,第二个div为box-hdr4
有没有办法这样做?请给我一些想法.
while-loop ×10
loops ×5
php ×4
c# ×3
c++ ×1
directory ×1
for-loop ×1
html ×1
ipad ×1
iphone ×1
javascript ×1
jquery ×1
mysql ×1
performance ×1
r ×1