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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.