Link to home
Start Free TrialLog in
Avatar of pingeyeg
pingeyeg

asked on

Same record being displayed for each value

Ok, I've got this thing working right, but I am getting the same record for each value displayed on the page.

<?php
$i = 0;
while ($i < 2) {
      $i = $i+1;
      if ($i==1) {
            echo "<tr>";
      }
      echo "<td width=\"250\">";
?>
<form action="/admin/delete_provider.php?Company=<?= $strCompanyname ?>" method="post">
     <a href="/admin/edit_provider.php?providerID=<?= $providerID ?>" >
       <?= $strCompanyname ?>
     </a>&nbsp;
     <a href="/admin/confirm_provider.php?Company=<?= $strCompanyname ?>">
       <input type="button" value="Delete" class="btn2">
     </a>
</form>
<?php
 echo "</td>";
      if ($i==3) {
            echo "</tr>";
            $i=0;
      }
}
?>
Avatar of glcummins
glcummins
Flag of United States of America image

Where are $strCompanyname and $providerID being set?
Avatar of pingeyeg
pingeyeg

ASKER

This is the entire code block:

<?php
if ($_GET['list'] == "list") {

$SQLstr2 = mysql_query("SELECT tblAdspace.providerID, tblAdspace.strCompanyname FROM tblAdspace")
or die(mysql_error());

while($row = mysql_fetch_array($SQLstr2)){
      $strCompanyname = $row['strCompanyname'];
      $providerID = $row['providerID'];
}
?>
<table id="admin_list" align="center" border="1">
<?php
$i = 0;
while ($i < 2) {
      $i = $i+1;
      if ($i==1) {
            echo "<tr>";
      }
      echo "<td width=\"250\">";
?>
<form action="/admin/delete_provider.php?Company=<?= $strCompanyname ?>" method="post">
     <a href="/admin/edit_provider.php?providerID=<?= $providerID ?>" >
       <?= $strCompanyname ?>
     </a>&nbsp;
     <a href="/admin/confirm_provider.php?Company=<?= $strCompanyname ?>">
       <input type="button" value="Delete" class="btn2">
     </a>
</form>
<?php
 echo "</td>";
      if ($i==3) {
            echo "</tr>";
            $i=0;
      }
}
?>
ASKER CERTIFIED SOLUTION
Avatar of under_dog
under_dog

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As under_dog said, your display portion needs to be inside the while() loop. As it stood before, your while loop was completing, and only the very last record found in the loop was passed on to the display portion of the script.