01-07-2009, 02:31 PM
|
#1 (permalink)
|
|
The Contributor
Join Date: Sep 2008
Posts: 39
Thanks: 9
|
Need help creating a function
How can I make a function out of the code below but continue to cycle until it gets a number that does not exist.
PHP Code:
//Generate unique incident number.
$incident_number = rand(1000000, 100000000);
//echo $incident_number;
// Check incident number.
$query = "SELECT * FROM ers_report where incident = '$incident_number'";
$reslut = mysql_query($query) or die(mysql_error());
$numrows = mysql_num_rows($result);
if ($numrows < 1) {
$row = mysql_fetch_array($result);
echo $incident_number;
} else {
echo "Failed";
}
__________________
Trying to learn all I can about PHP. Teach me what you know...
|
|
|
|