ScrewLooseSalad Posted February 21, 2013 Share Posted February 21, 2013 <?php #!---------------------------------- $i=1; while ($i <= $maxnumber) { //gather the details for an item $query = "SELECT * FROM database WHERE PartID = $i;"; //$result = $db->query($query); //$num_results = $result->num_rows; //$row = $result->fetch_assoc(); $result = $db->query($query); $num_results = $result->num_rows; $row = $result->fetch_assoc(); $itemname = $row[Part_Name]; if($i = $row[PartID]){ echo " <form action='action.php' method='post'> <tr> <td width='60px'><input type='text' name='PartID' maxlength='100' value='$row[PartID]' size='5' readonly /></td> <td><input type='text' name='Part_Name' maxlength='100' value='$row[Part_Name]' size='40' readonly /></td> <td><input type='text' name='Stock' maxlength='10' value='$row[stock]' size='10' readonly /></td> <td><input type='text' name='Notes' maxlength='100' value='$row[Notes]' size='56' readonly /></td> <td><input type='submit' name='submit' value='Delete'/><input type='submit' name='submit' value='Edit'/></td> </tr> </form> ";} $i++; } ?> usually the $i variable increments properly at the bottom of the script, but when the "if($i = $row[PartID])" statement isn't carried out the $i variable doesn't increment; it behaves as if the incrementation happens in the if statement, so when "$i != $row[PartID" it loops forever with $i not incrementing. Can anyone shed some light on my predicament? Thanks Quote Link to comment Share on other sites More sharing options...
mikosiko Posted February 21, 2013 Share Posted February 21, 2013 A common mistake... in you if = is an assigment operator not a comparison operator Quote Link to comment Share on other sites More sharing options...
ScrewLooseSalad Posted February 21, 2013 Author Share Posted February 21, 2013 A common mistake... in you if = is an assigment operator not a comparison operator lol oh yeah :S thanks for that! 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.