Question

Ok i have a while loop function in my site that pulls in excel documents and parses them to the database i want to check for duplicates and if duplicate skip it:

$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)...
}

i want to write in a script that checks to see if the record is a duplicate and if not enter it.

$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
    }
Was it helpful?

Solution

You are looking for the continue statement.

From the docs:

continue is used within looping structures to skip the rest of the current loop iteration and continue execution at the condition evaluation and then the beginning of the next iteration.

(See http://www.php.net/manual/en/control-structures.continue.php)

example:

<?php
while ( ... ) {
    if ($foo = 'bar') {
        // skip to the next iteration
        continue;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top