Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
01-24-2012, 03:55 AM #1
- Join Date
- Sep 2010
- Thanked 0 Times in 0 Posts
How do i get missing internal no`s
here is my code
$connection = mysql_connect("localhost", "user", "xxxxx");
$sql = "SELECT Internal FROM CusDec";
$result = mysql_query($sql);
$count = 0; // set a counter variable to zero
$employee_array = null; // this is our empty PHP array
while ($row = mysql_fetch_array($result)) // iterate through array
// store results from mysql in our own PHP array
$employee_array[$count] = $row['Internal'];
// increment counter
// we can now iterate through our own array to retrieve the data
for ($i = 0; $i < count($employee_array); $i++)
//echo $employee_array[$i] . '<br />';
//$arr1 = $employee_array[$i];
// construct a new array:1,2....max(given array).
// use array_diff to get the missing elements
$missing = array_diff($arr2,$employee_array[$i]);
01-24-2012, 04:21 AM #2
- Join Date
- Jul 2011
- Thanked 171 Times in 171 Posts
Your code is very inefficient as well. Why do you need to iterate through your results twice? Why not just do all the actions needed the first time? Also, you don't need a counter to push a new index onto an array - you can use array_push OR just do $array to append a new numeric index.
Useful function to retrieve difference in times
The best PHP resource
A good PHP FAQ
PLEASE remember to wrap your code in [PHP] tags.
// Replace this
// With this
// Then check for values/forms. Some IE versions don't send the submit button
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.