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 Link to comment https://forums.phpfreaks.com/topic/274769-uncanny-variable/ 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 Link to comment https://forums.phpfreaks.com/topic/274769-uncanny-variable/#findComment-1413890 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! Link to comment https://forums.phpfreaks.com/topic/274769-uncanny-variable/#findComment-1413891 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.