topflight Posted April 7, 2009 Share Posted April 7, 2009 This code I have is suppose to check the member list in the hub field and assign the new member a login id depending on what their hub is +1 well it works for all the other hubs but when the user selects the KSEA then it assigns it a KPDX hub id please help. This is my code: <?php $plist = mysql_query("SELECT * FROM `members` WHERE hub='$_POST[hub]' ORDER BY login DESC LIMIT 1") or die(mysql_error()); $plrows = mysql_num_rows($plist); if ($plrows=="0"){ if ($_POST[hub]=="KSEA"){ $login = "1000"; } if ($_POST[hub]=="KLAX"){ $login = "2000"; } if ($_POST[hub]=="KPDX"){ $login = "3000"; } if ($_POST[hub]=="PANC"){ $login = "4000"; }} else { while($plr = mysql_fetch_array($plist)){ $login = $plr[login]; } $login = $login + 1; } ?> Also this is the part of the form that contains the hub part. <select name="hub"> <option>- SELECT A HUB -</option> <option value="KPDX">Portland</option> <option value="KSEA">Seattle</option> <option value="KLAX">Los Angeles</option> <option value="PANC">Anchorage</option> </select> thanks in advanced! Link to comment https://forums.phpfreaks.com/topic/152931-not-working-right/ Share on other sites More sharing options...
MasterACE14 Posted April 7, 2009 Share Posted April 7, 2009 try this... <?php $plist = mysql_query("SELECT * FROM `members` WHERE hub='".$_POST['hub']."' ORDER BY login DESC LIMIT 1") or die(mysql_error()); $plrows = mysql_num_rows($plist); if ($plrows=="0") { if ($_POST['hub']=="KSEA"){ $login = "1000"; } elseif ($_POST['hub']=="KLAX"){ $login = "2000"; } elseif ($_POST['hub']=="KPDX"){ $login = "3000"; } elseif ($_POST['hub']=="PANC"){ $login = "4000"; } } else { while($plr = mysql_fetch_array($plist)) { $login = $plr['login']; } $login = $login + 1; } ?> Regards, ACE Link to comment https://forums.phpfreaks.com/topic/152931-not-working-right/#findComment-803187 Share on other sites More sharing options...
topflight Posted April 7, 2009 Author Share Posted April 7, 2009 nope still assign it to 3000. Any other help? Link to comment https://forums.phpfreaks.com/topic/152931-not-working-right/#findComment-803194 Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Share Posted April 7, 2009 Have a play with this and see how it goes. I've added 3 lines showing some debug info so you can see exactly what data is being returned and where. <?php $plist = mysql_query("SELECT * FROM `members` WHERE hub='".$_POST['hub']."' ORDER BY login DESC LIMIT 1") or die(mysql_error()); $plrows = mysql_num_rows($plist); //DEBUG DATA TO SEE WHAT WE'RE PLAYING WITH echo 'rows='.$plrows.'<br>'; echo 'POST='.$_POST['hub'].'<br>'; if ($plrows=="0") { switch ($_POST['hub']) { case 'KSEA':$login='1000';break; case 'KLAX':$login='2000';break; case 'KPDX':$login='3000';break; case 'PANC':$login='4000';break; default: while ($plr=mysql_fetch_array($plist)) { $login=$plr['login']; } $login++; } } echo 'login='.$login.'<br>'; ?> Link to comment https://forums.phpfreaks.com/topic/152931-not-working-right/#findComment-803216 Share on other sites More sharing options...
topflight Posted April 7, 2009 Author Share Posted April 7, 2009 That dosen't even assigns an login. I get a blank login but we are getting close because at least it is not doing 3000 no more. Any more suggestions please! And thanks!!! actually that code is not assigning a login to no hubs now. Link to comment https://forums.phpfreaks.com/topic/152931-not-working-right/#findComment-803603 Share on other sites More sharing options...
topflight Posted April 7, 2009 Author Share Posted April 7, 2009 any other help please this is like a major part of my site. Link to comment https://forums.phpfreaks.com/topic/152931-not-working-right/#findComment-803626 Share on other sites More sharing options...
topflight Posted April 7, 2009 Author Share Posted April 7, 2009 Any more help please this is only happen when the users selects the KSEA hub please help thanks! Link to comment https://forums.phpfreaks.com/topic/152931-not-working-right/#findComment-803962 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.