compare # with id, if id missing place that id # in text box
Posted: Sat Dec 07, 2002 10:21 pm
Ok,,now.. hope i dont make this more complicated than it is..
I have a categories script...
i was wondering if it is possible, and what the code would probably be like...
ok, this is the form im using to add a category...
-------------------------------------------------------------------------------------
elseif($_SERVER['QUERY_STRING'] == "catadd") {
?>
<font size="4" face="Verdana">Add Category</font><HR>
<? echo "You have $numrows Categories in the database<BR>"; ?>
<table><tr><td>
<?
echo "<form method=post action=admin.php?addcat>";
?>
<input type=hidden name=Cat_MainID value=\"\">
</td></tr><tr><td>
ID:</td><td><? echo "<input type=Text name=Cat_MainID size=1 value=\"$num\">"; ?>
</td></tr><tr><td>
Category Name:</td><td><input type=Text name=Cat_Name>
<input type=Submit name=submit value=Add></form></td></tr></table>
<?
}
-------------------------------------------------------------------------------------
if you notice i have :
ID:</td><td><? echo "<input type=Text name=Cat_MainID size=1 value=\"$num\">"; ?>
i get this from this mysql...
$num = ($numrows+1);
--------------------------------------------------------------------------------------
Now, this is my main problem,,,
when i have 3 categories,,,
Cat1
Cat2
Cat3
and i delete Cat2, im left with
Cat1
Cat3
-------------------------------------------------------------------------------------
my code does not detect that The id for Cat2 is missing, so wants to add the id for 3 again...
------------------------------------------------------------------------------------
what i want to know, is,,,
is there a way to detect that a number for the id is missing, or skips a number,, and have an if, else statement say, "hey, Category 2 is missing, and put the number 2 in the proper place for the cat id?
like this?
ID:</td><td><input type=Text name=Cat_MainID size=1 value=";
<?
if($numrows is missing a decimal){
echo $missing number;
}
else{
echo $num;
}
?>
\">";
I have a categories script...
i was wondering if it is possible, and what the code would probably be like...
ok, this is the form im using to add a category...
-------------------------------------------------------------------------------------
elseif($_SERVER['QUERY_STRING'] == "catadd") {
?>
<font size="4" face="Verdana">Add Category</font><HR>
<? echo "You have $numrows Categories in the database<BR>"; ?>
<table><tr><td>
<?
echo "<form method=post action=admin.php?addcat>";
?>
<input type=hidden name=Cat_MainID value=\"\">
</td></tr><tr><td>
ID:</td><td><? echo "<input type=Text name=Cat_MainID size=1 value=\"$num\">"; ?>
</td></tr><tr><td>
Category Name:</td><td><input type=Text name=Cat_Name>
<input type=Submit name=submit value=Add></form></td></tr></table>
<?
}
-------------------------------------------------------------------------------------
if you notice i have :
ID:</td><td><? echo "<input type=Text name=Cat_MainID size=1 value=\"$num\">"; ?>
i get this from this mysql...
$num = ($numrows+1);
--------------------------------------------------------------------------------------
Now, this is my main problem,,,
when i have 3 categories,,,
Cat1
Cat2
Cat3
and i delete Cat2, im left with
Cat1
Cat3
-------------------------------------------------------------------------------------
my code does not detect that The id for Cat2 is missing, so wants to add the id for 3 again...
------------------------------------------------------------------------------------
what i want to know, is,,,
is there a way to detect that a number for the id is missing, or skips a number,, and have an if, else statement say, "hey, Category 2 is missing, and put the number 2 in the proper place for the cat id?
like this?
ID:</td><td><input type=Text name=Cat_MainID size=1 value=";
<?
if($numrows is missing a decimal){
echo $missing number;
}
else{
echo $num;
}
?>
\">";