使用PHP的While循环中的下一条语句


Next statement in a While Loop with PHP

好的,我的站点中有一个while循环函数,它可以提取excel文档并将其解析到我想要检查重复项的数据库中,如果重复,则跳过它:

$content = file($selectfile1);
$posted_content = array();
list($rownum, $row) = each($content);
$posted_content[0] = explode(",", $row);
array_push($posted_content[0], "ID");
$count = 0;
// iterate each row (1 post)
while (list($rownum, $row) = each($content))
{
    $count++;
    $cols = "orderid, created_at, updated_at, notification_type, radius, available, expiration, ";
    $vals = "";
    $cols2 = "equipment_id";
    $vals2 = "";
....{parsing data)...
}

我想写一个脚本,检查记录是否重复,如果没有输入。

$sql25 = "SELECT * FROM notifications WHERE origin =" . $origin_id . " user_id =12039";
$rs25 = $conn->Execute($sql25);
if($rs25->RecordCount() == 1 || $rs25->RecordCount() >= 1)
    {

here is where i need a command. Can you use? next()
--------------------------------------------------

    }
else
{
         Insert query
    }

您正在查找continue语句。

来自文档:

在循环结构中使用continue来跳过当前循环迭代的剩余部分,并在条件评估时继续执行,然后开始下一次迭代。

(请参见http://www.php.net/manual/en/control-structures.continue.php)

示例:

<?php
while ( ... ) {
    if ($foo = 'bar') {
        // skip to the next iteration
        continue;
    }
}