Skip to content

Instantly share code, notes, and snippets.

@ChrisGehm
Last active December 27, 2015 03:29
Show Gist options
  • Save ChrisGehm/7259858 to your computer and use it in GitHub Desktop.
Save ChrisGehm/7259858 to your computer and use it in GitHub Desktop.
primer hueco
<?php
include ('connect.php');
$primerdisponible = "";
$sql1 = mysql_query("SELECT MIN(Numero) AS Numero
FROM historial_inventario_cajas
WHERE Numero NOT IN (SELECT Numero
FROM inventario_cajas)");
while ($g = mysql_fetch_array($sql1))
{
$primerdisponible = $g['Numero'];
}
if ($primerdisponible == "")
{
$sql2=mysql_query("SELECT MAX(Numero) AS Numero
FROM inventario_cajas");
while ($f = mysql_fetch_array($sql2))
{
$primerdisponible = $f['Numero']+1;
}
}
echo 'Primer numero disponible: '.$primerdisponible.'';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment