PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have some asp code that I want to try and do the same thing with php, and I quite cannot figure it out.
What I really want to do is have an ID say XYZ1000
But everytime someone signs up I would like it to take the next number in the sequence. (ie XYZ1001)
Is there anywhere on the net or a book that could somehow explain this?
Below is the ASP code currently used. But I'm unable to convert it into php.
I think I'm missing something to tie the first code (listed above) with the rest. So I'm going to post the rest of the code to see where I have a hole.
$dbcxn = mysql_connect("$host","$user","$pswd");
if (!$dbcxn) die ("Could not connect MySQL");
mysql_select_db($dbname,$dbcxn) or die ("Could not open database");
$PilotID = 1000;
$strSQL = "SELECT * FROM Pilots" ;
$result = mysql_query($strSQL) or die ("Can't complete query because ".mysql_error*());
if ($result){
while($rows = mysql_fetch_array($result)){
If ($rows["Name"] == "Available"){
$PilotID = substr($rows["PilotID"],4);
$WTD = 1;
}else{
$PilotID++;
$WTD = 0
}//end if
}//end while
}//end
if $PilotID = "ZAV" . $PilotID;
$sql = "INSERT INTO Pilots (Name, State, Country, Email, Passwd, BirthDate, Vatsim, BVIAccount, HubID) VALUES ('$fullname', '$state', '$country', '$email', '$passwd', '$birthdate', '$vatsim', '$bviaccount', '$hub')";
$result = mysql_query($sql);
echo "<b>Thank you!</b> Your Information has been entered.";
I understand that there is an error. Cause when you run the page you do not get anything displayed..
If someone can point on the net where I can read about this type of thing then I can learn about it and get it figured out..
if ($PilotID == "ZAV" . $PilotID){
$sql = "INSERT INTO Pilots (Name, State, Country, Email, Passwd, BirthDate, Vatsim, BVIAccount, HubID) VALUES ('$fullname', '$state', '$country', '$email', '$passwd', '$birthdate', '$vatsim', '$bviaccount', '$hub')";
$result = mysql_query($sql);
echo "<b>Thank you!</b> Your Information has been entered.";
//end if
I'm following along with what you are doing..!
But here is a question. Do I need to somehow put the PilotID table into the insert statement.? And do I also need to reference it like $PilotID into the Values area..?
*Feyd - What I'm trying to do is assign a specific ID for people when they sign up into the database..
But I would like it to get the next available ID thats not in the DB...
Does that make sense..?