Jump to content

uncanny variable


ScrewLooseSalad

Recommended Posts

<?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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.