mwalsh Posted August 23, 2007 Share Posted August 23, 2007 Thanks in advance for your help!! I have been trying to fix this all day. I need to look at the database to see if a record exists, if not do an insert, if it does, do an update (pretty easy stuff... huh). The problem I am have=ing is that mysql_num_rows is returning an inconsistent number of rows. Below is a code snippet. I would really appreciate any help: // Connect to database and assign values to the variables for ( $counter = 0; $counter < 4; $counter++ ) { $query = "SELECT * FROM schedule WHERE fto_id = '$fto_id' AND class = '$class_id' AND phase = '$counter'"; $result_id = mysql_query($query, $link) or die("Could not read from database: " . mysql_error()); $num_rows = mysql_num_rows( $result_id ); // If rows exist do an update else do an insert if( $num_rows > 0 ) { $query = "UPDATE schedule SET fto_id = '$fto_id', class = '$class_id', phase = '$counter', available = '$phase[$counter]'"; } else { $query = "INSERT INTO schedule VALUES ('$fto_id', '$class_id', '$counter', '$phase[$counter]', NULL)"; } $result_id = mysql_query($query, $link) or die(mysql_error()); } Quote Link to comment Share on other sites More sharing options...
matthewhaworth Posted August 23, 2007 Share Posted August 23, 2007 Does num_rows return 0 every time? That's because, at the beginning you're looking for a row that doesn't exist each time, therefore it'll also opt for the INSERT query. It doesn't exist because the counter increases each time, and the last time you performed the insertion query you only inserted the previous counter number .. I'm explaining this really badly. Also, put your code in code tags please. Quote Link to comment Share on other sites More sharing options...
mwalsh Posted August 23, 2007 Author Share Posted August 23, 2007 Oops... sorry about the code tags (I'm new to the forum). It was inconsistent. Usually it would return a positive number when counter == 0 but not when it was anything else. It wasn't consistent however and would occasionally return a positive number when counter == 3. Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 23, 2007 Share Posted August 23, 2007 See comments for ( $counter = 0; $counter < 4; $counter++ ) { //Where does $fto_id come & $class_id from? $query = "SELECT * FROM schedule WHERE fto_id = '$fto_id' AND class = '$class_id' AND phase = '$counter'"; // Add me to see if $query is what you really expect: print $query.'<br />'; $result_id = mysql_query($query, $link) or die("Could not read from database: " . mysql_error()); //Add me to see what is the result: print '<pre>'; print_r($result_id); $num_rows = mysql_num_rows( $result_id ); // If rows exist do an update else do an insert if( $num_rows > 0 ) { $query = "UPDATE schedule SET fto_id = '$fto_id', class = '$class_id', phase = '$counter', available = '$phase[$counter]'"; } else { $query = "INSERT INTO schedule VALUES ('$fto_id', '$class_id', '$counter', '$phase[$counter]', NULL)"; } $result_id = mysql_query($query, $link) or die(mysql_error()); } Quote Link to comment Share on other sites More sharing options...
matthewhaworth Posted August 23, 2007 Share Posted August 23, 2007 See comments for ( $counter = 0; $counter < 4; $counter++ ) { //Where does $fto_id come & $class_id from? $query = "SELECT * FROM schedule WHERE fto_id = '$fto_id' AND class = '$class_id' AND phase = '$counter'"; // Add me to see if $query is what you really expect: print $query.'<br />'; $result_id = mysql_query($query, $link) or die("Could not read from database: " . mysql_error()); //Add me to see what is the result: print '<pre>'; print_r($result_id); $num_rows = mysql_num_rows( $result_id ); // If rows exist do an update else do an insert if( $num_rows > 0 ) { $query = "UPDATE schedule SET fto_id = '$fto_id', class = '$class_id', phase = '$counter', available = '$phase[$counter]'"; } else { $query = "INSERT INTO schedule VALUES ('$fto_id', '$class_id', '$counter', '$phase[$counter]', NULL)"; } $result_id = mysql_query($query, $link) or die(mysql_error()); } Yea, though it's obvious what's wrong from the beginning, it's trying to insert every time instead of update because there's an error in your logic. (I'm saying this to the threadstarter btw) Also, jesirose, bold tags don't work within code tags lol. for ( $counter = 0; $counter < 4; $counter++ ) { $query = "SELECT * FROM schedule WHERE fto_id = '$fto_id' AND class = '$class_id' AND phase = '$counter'"; This query is looking for something where the counter's phase field is equal to 0 at first, after that however, it'll be looking for something that's equal to 1, then 2.. but it'll never be able to find it, because in the previous iteration, we only inserted the number BEFORE it to the database. Unless this is it's aim? I'm assuming it isn't the aim otherwise the UPDATE query wouldn't exist. What I think you're after doing is INSERTING it first them then UPDATING it everytime there after? In which case that won't work, because, as I've explained earlier, as there'll never be rows matching what you're searching for, it'll chose the INSERT query on every iteration. $result_id = mysql_query($query, $link) or die("Could not read from database: " . mysql_error()); $num_rows = mysql_num_rows( $result_id ); // If rows exist do an update else do an insert if( $num_rows > 0 ) { $query = "UPDATE schedule SET fto_id = '$fto_id', class = '$class_id', phase = '$counter', available = '$phase[$counter]'"; } else { $query = "INSERT INTO schedule VALUES ('$fto_id', '$class_id', '$counter', '$phase[$counter]', NULL)"; } $result_id = mysql_query($query, $link) or die(mysql_error()); } Quote Link to comment Share on other sites More sharing options...
mwalsh Posted August 23, 2007 Author Share Posted August 23, 2007 jesirose: the fto_id comes from a text field but I'm inputting the same one each time. the class comes from a drop down list box that is populated from another table, and the available field comes from a radio button. Also the $result_id is providing a resource id every time matthewhaworth: there are 4 phases so the counter just steps through the phases, and is supposed to look to see if the row exists already, if so update it, if not insert it. I'm proably too close to the problem because I'm just not seeing the logic error. Thanks, Mike Quote Link to comment Share on other sites More sharing options...
matthewhaworth Posted August 23, 2007 Share Posted August 23, 2007 jesirose: the fto_id comes from a text field but I'm inputting the same one each time. the class comes from a drop down list box that is populated from another table, and the available field comes from a radio button. Also the $result_id is providing a resource id every time matthewhaworth: there are 4 phases so the counter just steps through the phases, and is supposed to look to see if the row exists already, if so update it, if not insert it. I'm proably too close to the problem because I'm just not seeing the logic error. Thanks, Mike So, it's supposed to INSERT UPDATE UPDATE UPDATE? Yeah, just let me make sure I have it right, otherwise I'm completely wrong lol. Quote Link to comment Share on other sites More sharing options...
mwalsh Posted August 23, 2007 Author Share Posted August 23, 2007 You are correct... if the FTO_ID, class, and phase don't exist it needs to be inserted, after that if the FTP changes their availability for that class and phase the program should just update the row. Most of the time my version updates the row for phase 0 and then inserts for the remaining phases. Oddly enough the inserts the 2nd time around seem to all be in the same phase (usually phase 3). Quote Link to comment Share on other sites More sharing options...
mwalsh Posted August 23, 2007 Author Share Posted August 23, 2007 BTW... here is the entire app: <?php $fto_id = $_POST["fto_id"]; $class_id = $_POST["classdrop"]; $phase[0] = $_POST["phase1"]; $phase[1] = $_POST["phase2"]; $phase[2] = $_POST["phase3"]; $phase[3] = $_POST["phase4"]; /* for( $counter = 0; $counter < 4; $counter++ ) { print( "phase['x'] = '$phase[$counter]'\n"); } */ if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form ?> <HTML> <HEAD> <TITLE> FTO Scedule Availability </TITLE> </HEAD> <BODY> <form method="post" action="<?php echo $PHP_SELF;?>"> <?php // **************************************************************************************************** $db_host2 = "localhost"; $db_user2 = "leftasys_log3"; $db_pwd2 = "admin01x"; $db_name2 = "leftasys_dbapp"; $link = mysql_connect($db_host2, $db_user2, $db_pwd2) or die('Could not connect to server to read data<br>' . mysql_error()); $selected = mysql_select_db($db_name2, $link) or die('Could not connect to database to read data<br>' . mysql_error()); ?> <TABLE width=740 align=center cellspacing=0 cellpadding=0> <TR> <TD colspan=2 bgcolor=FFCC00><FONT FACE="ARIAL" SIZE="2"><B>FTO Scheduling</B></FONT></TD> </TR> <TR> <TD> <FONT FACE="ARIAL" color=" FFCC00" SIZE="1"><B>FTO ID</B></FONT> <INPUT TYPE="text" NAME="fto_id" SIZE="10" MAXLENGTH="7"> </TD> <TD> <FONT FACE="ARIAL" color=" FFCC00" SIZE="1"><B>Class ID</B></FONT> <SELECT NAME="classdrop" SIZE="1"> <?php // Get a list of class numbers for the drop down list box $query = "SELECT DISTINCT class FROM recruits ORDER BY class"; $result_id = mysql_query($query, $link) or die(mysql_error()); // Get selected class and assign to a variable while( list($key, $val) = mysql_fetch_array($result_id)) { print "<OPTION value=\"$key\">"; print "$key"; print "</OPTION>\n"; } echo("</select>"); mysql_close($link); ?> <br> </TD> </TR> <TR> <TD><FONT FACE="ARIAL" color=" FFCC00" SIZE="1"><B>Phase 1 Availability</B></FONT></TD><TD><FONT FACE="ARIAL" color=" FFCC00" SIZE="1">yes</FONT> <INPUT TYPE="radio" NAME="phase1" VALUE="yes"> <FONT FACE="ARIAL" color=" FFCC00" SIZE="1">no</FONT><INPUT TYPE="radio" NAME="phase1" VALUE="no" CHECKED></TD> </TR> <TR> <TD><FONT FACE="ARIAL" color=" FFCC00" SIZE="1"><B>Phase 2 Availability</B></FONT></TD><TD><FONT FACE="ARIAL" color=" FFCC00" SIZE="1">yes</FONT> <INPUT TYPE="radio" NAME="phase2" VALUE="yes"> <FONT FACE="ARIAL" color=" FFCC00" SIZE="1">no</FONT><INPUT TYPE="radio" NAME="phase2" VALUE="no" CHECKED></TD> </TR> <TR> <TD><FONT FACE="ARIAL" color=" FFCC00" SIZE="1"><B>Phase 3 Availability</B></FONT></TD><TD><FONT FACE="ARIAL" color=" FFCC00" SIZE="1">yes</FONT> <INPUT TYPE="radio" NAME="phase3" VALUE="yes"> <FONT FACE="ARIAL" color=" FFCC00" SIZE="1">no</FONT><INPUT TYPE="radio" NAME="phase3" VALUE="no" CHECKED></TD> </TR> <TR> <TD><FONT FACE="ARIAL" color=" FFCC00" SIZE="1"><B>Phase 4 Availability</B></FONT></TD><TD><FONT FACE="ARIAL" color=" FFCC00" SIZE="1">yes</FONT> <INPUT TYPE="radio" NAME="phase4" VALUE="yes"> <FONT FACE="ARIAL" color=" FFCC00" SIZE="1">no</FONT><INPUT TYPE="radio" NAME="phase4" VALUE="no" CHECKED></TD> </TR> </TABLE> <input type="submit" value="submit" name="submit"><br> </form><br> </BODY> </HTML> <?php } else { $db_host2 = "localhost"; $db_user2 = "leftasys_log3"; $db_pwd2 = "admin01x"; $db_name2 = "leftasys_dbapp"; $link = mysql_connect($db_host2, $db_user2, $db_pwd2) or die('Could not connect to server to write data<br>' . mysql_error()); $selected = mysql_select_db($db_name2, $link) or die('Could not connect to database to write data<br>' . mysql_error()); for ( $counter = 0; $counter < 4; $counter++ ) { if( $phase[$counter] == "yes" ) $phase[$counter] = "y"; else $phase[$counter] = "n"; $query = "SELECT * FROM schedule WHERE fto_id = '" . $fto_id . "' AND class = '" . $class_id . "' AND phase = '" . $counter . "'"; print( $query . "<BR>"); print( "fto_id = '$fto_id'<br>"); print( "class = '$class_id'<br>"); print( "phase = '$counter'<br>"); print( "available = '$phase[$counter]'<br>"); $result_id = mysql_query($query, $link) or die("Could not read from database: " . mysql_error()); $num_rows = mysql_num_rows( $result_id ); print( "num of rows " . $num_rows . "<br>"); if( $num_rows > 0 ) { $query = "UPDATE schedule SET fto_id = '$fto_id', class = '$class_id', phase = '$counter', available = '$phase[$counter]'"; $result_id = mysql_query($query, $link) or die(mysql_error()); echo( $query . "<br>" ); } else { $query = "INSERT INTO schedule VALUES ('$fto_id', '$class_id', '$counter', '$phase[$counter]', NULL)"; $result_id = mysql_query($query, $link) or die(mysql_error()); echo( $query . "<br>" ); } print("<BR><BR>"); } mysql_close($link); } ?> Quote Link to comment Share on other sites More sharing options...
matthewhaworth Posted August 23, 2007 Share Posted August 23, 2007 Lol, ok, I'll do a dry run for you. for ( $counter = 0; $counter < 4; $counter++ ) { $query = "SELECT * FROM schedule WHERE fto_id = '$fto_id' AND class = '$class_id' AND phase = '$counter'"; $result_id = mysql_query($query, $link) or die("Could not read from database: " . mysql_error()); $num_rows = mysql_num_rows( $result_id ); // If rows exist do an update else do an insert if( $num_rows > 0 ) { $query = "UPDATE schedule SET fto_id = '$fto_id', class = '$class_id', phase = '$counter', available = '$phase[$counter]'"; } else { $query = "INSERT INTO schedule VALUES ('$fto_id', '$class_id', '$counter', '$phase[$counter]', NULL)"; } $result_id = mysql_query($query, $link) or die(mysql_error()); } $counter = 0. for ( $counter = 0; $counter < 4; $counter++ ) { $query = "SELECT * FROM schedule WHERE fto_id = '$fto_id' AND class = '$class_id' AND phase = 0"; $result_id = mysql_query($query, $link) or die("Could not read from database: " . mysql_error()); // Ah! This is the first iteration, therefore it doesn't exist, and we should get 0 from the following function: $num_rows = mysql_num_rows( $result_id ); // If rows exist do an update else do an insert // Since, num_rows didn't return anything bigger than 0, we'll skip to the insert. if( $num_rows > 0 ) { $query = "UPDATE schedule SET fto_id = '$fto_id', class = '$class_id', phase = '$counter', available = '$phase[$counter]'"; } else { // WE HAVE INSERTED : fto_id = $fto_id, class_id = $class_id PHASE = 0 $query = "INSERT INTO schedule VALUES ('$fto_id', '$class_id', '$counter', '$phase[$counter]', NULL)"; } $result_id = mysql_query($query, $link) or die(mysql_error()); } $counter = 1. for ( $counter = 0; $counter < 4; $counter++ ) { $query = "SELECT * FROM schedule WHERE fto_id = '$fto_id' AND class = '$class_id' AND phase = 1"; $result_id = mysql_query($query, $link) or die("Could not read from database: " . mysql_error()); // WE HAVE JUST LOOKED FOR WHERE IT IS EQUAL 1, IT'S ONE OF THE CONDITIONS IT MUST MEET // IF YOU REMEMBER THE LAST ITERATION, WE INSERTED: // "WE HAVE INSERTED : fto_id = $fto_id, class_id = $class_id PHASE = 0" // THEREFORE, NO ROWS WILL EXISTS WHERE PHASE = 1. $num_rows = mysql_num_rows( $result_id ); // If rows exist do an update else do an insert // Since, num_rows didn't return anything bigger than 0, we'll skip to the insert. if( $num_rows > 0 ) { $query = "UPDATE schedule SET fto_id = '$fto_id', class = '$class_id', phase = '$counter', available = '$phase[$counter]'"; } else { // WE HAVE INSERTED : fto_id = $fto_id, class_id = $class_id PHASE = 0 $query = "INSERT INTO schedule VALUES ('$fto_id', '$class_id', '$counter', '$phase[$counter]', NULL)"; } $result_id = mysql_query($query, $link) or die(mysql_error()); } Sorry for the caps, but it's hard to make stuff stand out inside in code tags. The solution is simple. Put this: $query = "SELECT * FROM schedule WHERE fto_id = '$fto_id' AND class = '$class_id' AND phase = 0"; instead of: $query = "SELECT * FROM schedule WHERE fto_id = '$fto_id' AND class = '$class_id' AND phase = '$counter'"; Because num_rows will never be bigger than 0, as what you're looking for hasn't been created yet. I get your logic, but your query won't follow it. Quote Link to comment Share on other sites More sharing options...
mwalsh Posted August 23, 2007 Author Share Posted August 23, 2007 I am with you and your email points out that I have spent too many hours of staring at this. The first time through the program everything inserts like it should. the problem is if they run this page again to change their availability. The first phase usually updates OK but subsequent phases (the counter) does an insert most of the time. Quote Link to comment Share on other sites More sharing options...
matthewhaworth Posted August 23, 2007 Share Posted August 23, 2007 I am with you and your email points out that I have spent too many hours of staring at this. The first time through the program everything inserts like it should. the problem is if they run this page again to change their availability. The first phase usually updates OK but subsequent phases (the counter) does an insert most of the time. Have you changed what I said and tried it? I think the reason it does it sometimes is because it's iterated previously, delete the content from the db each time and start again, logging what the database does every time. Quote Link to comment Share on other sites More sharing options...
mwalsh Posted August 23, 2007 Author Share Posted August 23, 2007 I made the change, truncated the table, and got the following (note several inserts and then an update): SELECT * FROM schedule WHERE fto_id = '54321' AND class = '0807' AND phase = '0' fto_id = '54321' class = '0807' phase = '0' available = 'n' num of rows 0 INSERT INTO schedule VALUES ('54321', '0807', '0', 'n', NULL) SELECT * FROM schedule WHERE fto_id = '54321' AND class = '0807' AND phase = '0' fto_id = '54321' class = '0807' phase = '1' available = 'y' num of rows 1 UPDATE schedule SET fto_id = '54321', class = '0807', phase = '1', available = 'y' SELECT * FROM schedule WHERE fto_id = '54321' AND class = '0807' AND phase = '0' fto_id = '54321' class = '0807' phase = '2' available = 'y' num of rows 0 INSERT INTO schedule VALUES ('54321', '0807', '2', 'y', NULL) SELECT * FROM schedule WHERE fto_id = '54321' AND class = '0807' AND phase = '0' fto_id = '54321' class = '0807' phase = '3' available = 'n' num of rows 0 INSERT INTO schedule VALUES ('54321', '0807', '3', 'n', NULL) Quote Link to comment Share on other sites More sharing options...
matthewhaworth Posted August 23, 2007 Share Posted August 23, 2007 Hold on, does what I'm saying make sense? Because I'm starting to doubt myself now..how did you get the data you listed above? Query: SELECT * FROM schedule WHERE fto_id = '54321' AND class = '0807' AND phase = '0' Result: fto_id = '54321' class = '0807' phase = '1' available = 'y' num of rows 1 UPDATE schedule SET fto_id = '54321', class = '0807', phase = '1', available = 'y' Is that how it works? Because it can't be, that query cannot possibly produce them results as phase != 0 Quote Link to comment Share on other sites More sharing options...
mwalsh Posted August 23, 2007 Author Share Posted August 23, 2007 I posted the entire app a few messages back (instead of just the snippet). It has a number of print statements in it for debugging. What you are seeing are those print statements Quote Link to comment Share on other sites More sharing options...
matthewhaworth Posted August 23, 2007 Share Posted August 23, 2007 Ah, I realise what's gone wrong and am formulating a solution SELECT * FROM schedule WHERE fto_id = '54321' AND class = '0807' AND phase = '0' fto_id = '54321' class = '0807' phase = '0' available = 'n' num of rows 0 INSERT INTO schedule VALUES ('54321', '0807', '0', 'n', NULL) First entry, we want to insert, good good, we didn't find anything because we've never entered anything before. SELECT * FROM schedule WHERE fto_id = '54321' AND class = '0807' AND phase = '0' fto_id = '54321' class = '0807' phase = '1' available = 'y' num of rows 1 UPDATE schedule SET fto_id = '54321', class = '0807', phase = '1', available = 'y' Now, we've found something, because that's what we just entered.. NOW we want it to start counting upwards.. if you get me You need it to be equal to 0 for the first time and again the second time, but start counting. SELECT * FROM schedule WHERE fto_id = '54321' AND class = '0807' AND phase = '0' fto_id = '54321' class = '0807' phase = '2' available = 'y' num of rows 0 INSERT INTO schedule VALUES ('54321', '0807', '2', 'y', NULL) ...if phase was equal to 1 now, it'd find something and UPDATE instead of INSERT SELECT * FROM schedule WHERE fto_id = '54321' AND class = '0807' AND phase = '0' fto_id = '54321' class = '0807' phase = '3' available = 'n' num of rows 0 INSERT INTO schedule VALUES ('54321', '0807', '3', 'n', NULL) ...if phase was equal to 2 now, it'd find something and UPDATE instead of INSERT Replace this: $query = "SELECT * FROM schedule WHERE fto_id = '$fto_id' AND class = '$class_id' AND phase = 0"; with this: if ($counter == 0) { $query = "SELECT * FROM schedule WHERE fto_id = '$fto_id' AND class = '$class_id' AND phase = ".$counter.";"; } else { $newcounter = $counter - 1 $query = "SELECT * FROM schedule WHERE fto_id = '$fto_id' AND class = '$class_id' AND phase = ".$newcounter.";"; truncate, and try again. Quote Link to comment Share on other sites More sharing options...
mwalsh Posted August 23, 2007 Author Share Posted August 23, 2007 Well it's a little closer... notice the initial INSERT followed by Updates : SELECT * FROM schedule WHERE fto_id = '54321' AND class = '0807' AND phase = 0; fto_id = '54321' class = '0807' phase = '0' available = 'n' num of rows 0 INSERT INTO schedule VALUES ('54321', '0807', '0', 'n', NULL) SELECT * FROM schedule WHERE fto_id = '54321' AND class = '0807' AND phase = 0; fto_id = '54321' class = '0807' phase = '1' available = 'y' num of rows 1 UPDATE schedule SET fto_id = '54321', class = '0807', phase = '1', available = 'y' SELECT * FROM schedule WHERE fto_id = '54321' AND class = '0807' AND phase = 1; fto_id = '54321' class = '0807' phase = '2' available = 'y' num of rows 6 UPDATE schedule SET fto_id = '54321', class = '0807', phase = '2', available = 'y' SELECT * FROM schedule WHERE fto_id = '54321' AND class = '0807' AND phase = 2; fto_id = '54321' class = '0807' phase = '3' available = 'n' num of rows 6 UPDATE schedule SET fto_id = '54321', class = '0807', phase = '3', available = 'n' Also the table looks like this: fto_id class phase available recruit_id 54321 0807 3 n NULL 54321 0807 3 n NULL 54321 0807 3 n NULL 54321 0807 3 n NULL 54321 0807 3 n NULL 54321 0807 3 n NULL Quote Link to comment Share on other sites More sharing options...
matthewhaworth Posted August 23, 2007 Share Posted August 23, 2007 Isn't that what's supposed to happen? Ah, no I see what's happened, I have a habit of just scanning things instead of reading them lol. That's a crazy problem.. let's look into it. UPDATE schedule SET fto_id = '54321', class = '0807', phase = '1', available = 'y' can we try getting rid of the 's. It's an integer value and therefore should be entered as one.. well, apart from available.. I don't know how that'll fix it, but in the mean time.. UPDATE schedule SET fto_id = '54321', class = '0807', phase = '1', available = 'y' That is the line that's causing the problem, hmm. Quote Link to comment Share on other sites More sharing options...
mwalsh Posted August 23, 2007 Author Share Posted August 23, 2007 I'm not sure what you mean by "getting rid of the 's". The first time through the program everything should insert. The next time I run it everything should update if all I've changed is the availability. In addition the phase should be the same as the counter (0-4) but it's 3 on all of these... weird huh??? Quote Link to comment Share on other sites More sharing options...
matthewhaworth Posted August 23, 2007 Share Posted August 23, 2007 Not really, you said LESS THAN 4, not LESS THAN OR EQUAL TO 4 for ( $counter = 0; $counter < 4; $counter++ ) Look. If you want 0 - 4. it should be for ( $counter = 0; $counter =< 4; $counter++ ) Quote Link to comment Share on other sites More sharing options...
mwalsh Posted August 23, 2007 Author Share Posted August 23, 2007 Oops.. phases should be 0 - 3 Quote Link to comment Share on other sites More sharing options...
matthewhaworth Posted August 23, 2007 Share Posted August 23, 2007 Oops.. phases should be 0 - 3 Be consistent in what you say lol Give us the latest copy of the application? Please Quote Link to comment Share on other sites More sharing options...
mwalsh Posted August 23, 2007 Author Share Posted August 23, 2007 Yeah... it's getting late here on the east coast and I've been up since 4:30am so I'm getting a little tired. If you look at the insert statements the phase should have populated with 0-3 instead of all 3's. Doesn't make sense to me. Quote Link to comment Share on other sites More sharing options...
matthewhaworth Posted August 23, 2007 Share Posted August 23, 2007 Yeah... it's getting late here on the east coast and I've been up since 4:30am so I'm getting a little tired. If you look at the insert statements the phase should have populated with 0-3 instead of all 3's. Doesn't make sense to me. So you want the database to contain: fto_id class phase available recruit_id 54321 0807 0 n NULL 54321 0807 1 n NULL 54321 0807 2 n NULL 54321 0807 3 n NULL ? If so, you're going about it completely wrong. Quote Link to comment Share on other sites More sharing options...
mwalsh Posted August 23, 2007 Author Share Posted August 23, 2007 Yes... The app can be run more than once. The first time through it should look like this below (the available flag may be "y" depeding on what they pick: fto_id class phase available recruit_id 54321 0807 0 n NULL 54321 0807 1 n NULL 54321 0807 2 n NULL 54321 0807 3 n NULL the second time they run the app (to change their availability) it should look like this (or what ever they put in for availability): fto_id class phase available recruit_id 54321 0807 0 n NULL 54321 0807 1 y NULL 54321 0807 2 n NULL 54321 0807 3 n NULL So the initial time they run it there should be nothing but inserts and in successive times it should be updates Quote Link to comment 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.