TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 01-07-2009, 02:31 PM   #1 (permalink)
The Contributor
 
Join Date: Sep 2008
Posts: 39
Thanks: 9
code_junkie is on a distinguished road
Default 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(1000000100000000);
  
//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...
code_junkie is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a gallery class Tanax Advanced PHP Programming 25 02-19-2013 04:25 AM
Timezone Class: Dealing with Timezones the Proper Way Wildhoney General 2 01-10-2011 11:01 PM
Creating a Simple Currency Converter with Automatic Symbols Wildhoney General 11 03-16-2010 05:22 PM
Part 2: Giving our Currency Conversion Script some Responsibility Wildhoney General 15 03-17-2009 01:53 PM
[Tutorial] How to organize your classes | Part 1 Tanax Advanced PHP Programming 10 03-01-2009 10:08 PM


All times are GMT. The time now is 09:16 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design