tfburges Posted July 18, 2008 Share Posted July 18, 2008 This code returns a form name and the timestamp of when the data was entered into the form. For some reason, when I load the page, it gets stuck in a loop until timeout and fills the pull down menu with the same value over and over. I must be too tired to see what's wrong... <td class=fstyle width=150 align=center valign=middle> <form name='nav'> <select name='SelectURL' onChange='document.location.href=document.nav.SelectURL.options[document.nav.SelectURL.selectedIndex].value'> <option value=''> "; $qfnv = mysql_query("SELECT DISTINCT `formx_name_v` FROM `formz`", $link) or die ('MYSQL error: ' . mysql_error()); $dfnv = mysql_fetch_array($qfnv); while ( $fnv = $dfnv['formx_name_v'] ) { $qfn = mysql_query("SELECT `formx_name` FROM `formz` WHERE `formx_name_v` = '$fnv'", $link) or die ('MYSQL error: ' . mysql_error()); $dfn = mysql_fetch_array($qfn); $fn = $dfn['formx_name']; if ( $fnv = $formx_name_v ) { echo " <option value='report_select.php?fnvs=",$fnv,"&did=",$did,"' selected>",$fn; } else { echo " <option value='report_select.php?fnvs=",$fnv,"&did=",$did,"'>",$fn; } } echo " </select> </form> </td> <td class=fstyle width=150 align=center valign=middle> <form name=form method=post action='report.php?fnvs=",$formx_name_v,"&rid=",$rid,"'> <select name=rid> <option value=''> "; $qid = mysql_query("SELECT `id` FROM `$formx_name_v`", $link) or die ('MYSQL error: ' . mysql_error()); $did = mysql_fetch_array($qid); while ( $rid = $did['id'] ) { $qts = mysql_query("SELECT `timestamp` FROM `$formx_name_v`", $link) or die ('MYSQL error: ' . mysql_error()); $dts = mysql_fetch_array($qts); $ts = $dts['timestamp']; if ( $rid = $did ) { echo " <option value='",$rid,"' selected>",$ts; } else { echo " <option value='",$rid,"'>",$ts; } } echo " </select> </td> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 18, 2008 Share Posted July 18, 2008 The problem is that you're while statement assigns one variable to another. There's no comparison going on. Since it's always able to assign, the loop is always true. Basic structure of a while loop: while($row = mysql_fetch_array($result)){ $var = $row['var']; echo $var.'<br />'; } On a site note, you should really consider naming your variables something a bit more descriptive. Quote Link to comment Share on other sites More sharing options...
tfburges Posted July 18, 2008 Author Share Posted July 18, 2008 WOW...... > > > :-\ I've done hundreds of while loops. I don't know how I screwed that up and managed to overlook it. That's the first time that's happened. Thanks... I really hate this time of day. Also, my variable names are abbreviations. I don't like long names. 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.