lupld Posted August 24, 2007 Share Posted August 24, 2007 ok, I need to pass off certain variables if the room number equals a certain number, (the big huge long lines....) problem is, when it does, it sets the variable to 0 and doesn't set it back after the query is completed... so every 100 increments on rnum, it goes back to blank and starts again from one... anyone see why it's not working??? <?php //* This is a room generator, puts out an INSERT string........ creates rooms 10,001-20,000, or the second floor... $rnum = 10001; $lup = 20001; $ldown = 1; $lwest = "10000"; $lnorth = ""; $least = "10002"; $lsouth = 10100; $rcontents = "There is nothing currently in this room."; $rname = "New Room"; while($rnum <= 20000) { //remove north and south links for certain room numbers if($rnum == 10101) { $lnorth = "10001"; } if($rnum <= 10100) { $lnorth = ""; } if(lsouth >= "19000") { $lsouth = ""; } //remove links for left and right borders if($rnum == "10100" || $rnum == "10200" || $rnum == "10300" || $rnum == "10400" || $rnum == "10500" || $rnum == "10600" || $rnum == "10700" || $rnum == "10800" || $rnum == "10900" || $rnum == "101000" || $rnum == "11100" || $rnum == "11200" || $rnum == "11300" || $rnum == "11400" || $rnum == "11500" || $rnum == "11600" || $rnum == "11700" || $rnum == "11800" || $rnum == "11900" || $rnum == "12000" || $rnum == "12100" || $rnum == "12200" || $rnum == "12300" || $rnum == "12400" || $rnum == "12500" || $rnum == "12600" || $rnum == "12700" || $rnum == "12800" || $rnum == "12900" || $rnum == "13000" || $rnum == "13100" || $rnum == "13200" || $rnum == "13300" || $rnum == "13400" || $rnum == "13500" || $rnum == "13600" || $rnum == "13700" || $rnum == "13800" || $rnum == "13900" || $rnum == "14000" || $rnum == "14100" || $rnum == "14200" || $rnum == "14300" || $rnum == "14400" || $rnum == "14500" || $rnum == "14600" || $rnum == "14700" || $rnum == "14800" || $rnum == "14900" || $rnum == "15000" || $rnum == "15100" || $rnum == "15200" || $rnum == "15300" || $rnum == "15400" || $rnum == "15500" || $rnum == "15600" || $rnum == "15700" || $rnum == "15800" || $rnum == "15900" || $rnum == "16000" || $rnum == "16100" || $rnum == "16200" || $rnum == "16300" || $rnum == "16400" || $rnum == "16500" || $rnum == "16600" || $rnum == "16700" || $rnum == "16800" || $rnum == "16900" || $rnum == "17000" || $rnum == "17100" || $rnum == "17200" || $rnum == "17300" || $rnum == "17400" || $rnum == "17500" || $rnum == "17600" || $rnum == "17700" || $rnum == "17800" || $rnum == "17900" || $rnum == "18000" || $rnum == "18100" || $rnum == "18200" || $rnum == "18300" || $rnum == "18400" || $rnum == "18500" || $rnum == "18600" || $rnum == "18700" || $rnum == "18800" || $rnum == "18900" || $rnum == "19000" || $rnum == "19100" || $rnum == "19200" || $rnum == "19300" || $rnum == "19400" || $rnum == "19500" || $rnum == "19600" || $rnum == "19700" || $rnum == "19800" || $rnum == "19900" || $rnum == "20000") { $tempvar = "$least"; $least = ""; } if($rnum == "10001" || $rnum == "10101" || $rnum == "10201" || $rnum == "10301" || $rnum == "10401" || $rnum == "10501" || $rnum == "10601" || $rnum == "10701" || $rnum == "10801" || $rnum == "10901" || $rnum == "11001" || $rnum == "11101" || $rnum == "11201" || $rnum == "11301" || $rnum == "11401" || $rnum == "11501" || $rnum == "11601" || $rnum == "11701" || $rnum == "11801" || $rnum == "11901" || $rnum == "12001" || $rnum == "12101" || $rnum == "12201" || $rnum == "12301" || $rnum == "12401" || $rnum == "12501" || $rnum == "21601" || $rnum == "12701" || $rnum == "12801" || $rnum == "12901" || $rnum == "13001" || $rnum == "13101" || $rnum == "13201" || $rnum == "13301" || $rnum == "13401" || $rnum == "13501" || $rnum == "13601" || $rnum == "13701" || $rnum == "13801" || $rnum == "13901" || $rnum == "14001" || $rnum == "14101" || $rnum == "14201" || $rnum == "14301" || $rnum == "14401" || $rnum == "14501" || $rnum == "14601" || $rnum == "14701" || $rnum == "14801" || $rnum == "14901" || $rnum == "15001" || $rnum == "15101" || $rnum == "15201" || $rnum == "15301" || $rnum == "15401" || $rnum == "15501" || $rnum == "15601" || $rnum == "15701" || $rnum == "15801" || $rnum == "15901" || $rnum == "16001" || $rnum == "16101" || $rnum == "16201" || $rnum == "16301" || $rnum == "16401" || $rnum == "16501" || $rnum == "16601" || $rnum == "16701" || $rnum == "16801" || $rnum == "16901" || $rnum == "17001" || $rnum == "17101" || $rnum == "17201" || $rnum == "17301" || $rnum == "17401" || $rnum == "17501" || $rnum == "17601" || $rnum == "17701" || $rnum == "17801" || $rnum == "17901" || $rnum == "18001" || $rnum == "18101" || $rnum == "18201" || $rnum == "18301" || $rnum == "18401" || $rnum == "18501" || $rnum == "18601" || $rnum == "18701" || $rnum == "18801" || $rnum == "18901" || $rnum == "19001" || $rnum == "19101" || $rnum == "19201" || $rnum == "19301" || $rnum == "19401" || $rnum == "19501" || $rnum == "19601" || $rnum == "19701" || $rnum == "19801" || $rnum == "19901") { $tempvar2 = "$lwest"; $lwest = ""; } echo "INSERT INTO `rooms` VALUES ('~rnum~$rnum', '~lup~$lup', '~ldown~$ldown', '~lwest~$lwest', '~least~$least', '~lnorth~$lnorth', '~lsouth~$lsouth', '~rcontents~$rcontents', '~rname~$rname', ~permis~0);<br />"; $rnum++; $lup++; $ldown++; $lwest++; if($lnorth) { $lnorth++; } $least++; if($lsouth) { $lsouth++; } if($least == "") { $least = "$tempvar"; $least++; } if($lwest == "") { $lwest = "$tempvar2"; $lwest++; } } die; ?> an example of the result can be found at http://www.arcane-studios.net/roomgenerator.php I'm going to remove the ~rnum~, ~lup~, etc... from the query when it's completed... Quote Link to comment https://forums.phpfreaks.com/topic/66570-solved-problems-with-passing-of-a-variable/ Share on other sites More sharing options...
MadTechie Posted August 24, 2007 Share Posted August 24, 2007 so every 100 increments on rnum, it goes back to blank and starts again from one... anyone see why it's not working??? Erm.. theirs no logic in their to set rnum back to anything its set to go up by one thats it!! Quote Link to comment https://forums.phpfreaks.com/topic/66570-solved-problems-with-passing-of-a-variable/#findComment-333477 Share on other sites More sharing options...
lupld Posted August 24, 2007 Author Share Posted August 24, 2007 eh, I was in a hurry and worded it wrong.. the part that gets set blank is the west links and east links, but it depends on the room number.. this is that part that doesn't work... <?php if($rnum == "10100" || $rnum == "10200" || $rnum == "10300" || etc...... { $tempvar = "$least"; $least = ""; } if($rnum == "10001" || $rnum == "10101" || $rnum == "10201" || etc...... { $tempvar2 = "$lwest"; $lwest = ""; } //echoes back the text in a line somewhere around here so I can copy it into a mysql backup file and load it into the database //put lwest and least back to what they were... if($least == "") { $least = "$tempvar"; $least++; } if($lwest == "") { $lwest = "$tempvar2"; $lwest++; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/66570-solved-problems-with-passing-of-a-variable/#findComment-333485 Share on other sites More sharing options...
lupld Posted August 24, 2007 Author Share Posted August 24, 2007 kinda got it to work.. the code is a bit weird, but I just changed it so that it only echoed back the west and east links if the room number wasn't one of the ones to be left blank... <?php //* This is a room generator, puts out an INSERT string........ $rnum = 10001; $lup = 20001; $ldown = 1; $lwest = "10000"; $lnorth = ""; $least = "10002"; $lsouth = 10100; $rcontents = "There is nothing currently in this room."; $rname = "New Room"; while($rnum <= 20000) { //remove north and south links for certain room numbers if($rnum == 10101) { $lnorth = "10001"; } if($rnum <= 10100) { $lnorth = ""; } if(lsouth >= "19000") { $lsouth = ""; } //remove links for left and right borders echo "INSERT INTO `rooms` VALUES ('$rnum', '$lup', '$ldown', '"; if($rnum == "10001" || $rnum == "10101" || $rnum == "10201" || $rnum == "10301" || $rnum == "10401" || $rnum == "10501" || $rnum == "10601" || $rnum == "10701" || $rnum == "10801" || $rnum == "10901" || $rnum == "11001" || $rnum == "11101" || $rnum == "11201" || $rnum == "11301" || $rnum == "11401" || $rnum == "11501" || $rnum == "11601" || $rnum == "11701" || $rnum == "11801" || $rnum == "11901" || $rnum == "12001" || $rnum == "12101" || $rnum == "12201" || $rnum == "12301" || $rnum == "12401" || $rnum == "12501" || $rnum == "21601" || $rnum == "12701" || $rnum == "12801" || $rnum == "12901" || $rnum == "13001" || $rnum == "13101" || $rnum == "13201" || $rnum == "13301" || $rnum == "13401" || $rnum == "13501" || $rnum == "13601" || $rnum == "13701" || $rnum == "13801" || $rnum == "13901" || $rnum == "14001" || $rnum == "14101" || $rnum == "14201" || $rnum == "14301" || $rnum == "14401" || $rnum == "14501" || $rnum == "14601" || $rnum == "14701" || $rnum == "14801" || $rnum == "14901" || $rnum == "15001" || $rnum == "15101" || $rnum == "15201" || $rnum == "15301" || $rnum == "15401" || $rnum == "15501" || $rnum == "15601" || $rnum == "15701" || $rnum == "15801" || $rnum == "15901" || $rnum == "16001" || $rnum == "16101" || $rnum == "16201" || $rnum == "16301" || $rnum == "16401" || $rnum == "16501" || $rnum == "16601" || $rnum == "16701" || $rnum == "16801" || $rnum == "16901" || $rnum == "17001" || $rnum == "17101" || $rnum == "17201" || $rnum == "17301" || $rnum == "17401" || $rnum == "17501" || $rnum == "17601" || $rnum == "17701" || $rnum == "17801" || $rnum == "17901" || $rnum == "18001" || $rnum == "18101" || $rnum == "18201" || $rnum == "18301" || $rnum == "18401" || $rnum == "18501" || $rnum == "18601" || $rnum == "18701" || $rnum == "18801" || $rnum == "18901" || $rnum == "19001" || $rnum == "19101" || $rnum == "19201" || $rnum == "19301" || $rnum == "19401" || $rnum == "19501" || $rnum == "19601" || $rnum == "19701" || $rnum == "19801" || $rnum == "19901") { echo ""; } else { echo "$lwest"; } echo "', '"; if($rnum == "10100" || $rnum == "10200" || $rnum == "10300" || $rnum == "10400" || $rnum == "10500" || $rnum == "10600" || $rnum == "10700" || $rnum == "10800" || $rnum == "10900" || $rnum == "101000" || $rnum == "11100" || $rnum == "11200" || $rnum == "11300" || $rnum == "11400" || $rnum == "11500" || $rnum == "11600" || $rnum == "11700" || $rnum == "11800" || $rnum == "11900" || $rnum == "12000" || $rnum == "12100" || $rnum == "12200" || $rnum == "12300" || $rnum == "12400" || $rnum == "12500" || $rnum == "12600" || $rnum == "12700" || $rnum == "12800" || $rnum == "12900" || $rnum == "13000" || $rnum == "13100" || $rnum == "13200" || $rnum == "13300" || $rnum == "13400" || $rnum == "13500" || $rnum == "13600" || $rnum == "13700" || $rnum == "13800" || $rnum == "13900" || $rnum == "14000" || $rnum == "14100" || $rnum == "14200" || $rnum == "14300" || $rnum == "14400" || $rnum == "14500" || $rnum == "14600" || $rnum == "14700" || $rnum == "14800" || $rnum == "14900" || $rnum == "15000" || $rnum == "15100" || $rnum == "15200" || $rnum == "15300" || $rnum == "15400" || $rnum == "15500" || $rnum == "15600" || $rnum == "15700" || $rnum == "15800" || $rnum == "15900" || $rnum == "16000" || $rnum == "16100" || $rnum == "16200" || $rnum == "16300" || $rnum == "16400" || $rnum == "16500" || $rnum == "16600" || $rnum == "16700" || $rnum == "16800" || $rnum == "16900" || $rnum == "17000" || $rnum == "17100" || $rnum == "17200" || $rnum == "17300" || $rnum == "17400" || $rnum == "17500" || $rnum == "17600" || $rnum == "17700" || $rnum == "17800" || $rnum == "17900" || $rnum == "18000" || $rnum == "18100" || $rnum == "18200" || $rnum == "18300" || $rnum == "18400" || $rnum == "18500" || $rnum == "18600" || $rnum == "18700" || $rnum == "18800" || $rnum == "18900" || $rnum == "19000" || $rnum == "19100" || $rnum == "19200" || $rnum == "19300" || $rnum == "19400" || $rnum == "19500" || $rnum == "19600" || $rnum == "19700" || $rnum == "19800" || $rnum == "19900" || $rnum == "20000") { echo ""; } else { echo "$least"; } echo "', '$lnorth', '$lsouth', '$rcontents', '$rname', 0);<br />"; $rnum++; $lup++; $ldown++; $lwest++; $least++; if($lnorth) { $lnorth++; } if($lsouth) { $lsouth++; } } die; ?> still buggy, but the part I needed to work works now... Quote Link to comment https://forums.phpfreaks.com/topic/66570-solved-problems-with-passing-of-a-variable/#findComment-333524 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.