Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Same record being displayed for each value

Posted on 2007-03-23
4
191 Views
Last Modified: 2007-03-24
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;
      }
}
?>
0
Comment
Question by:pingeyeg
  • 2
4 Comments
 
LVL 24

Expert Comment

by:glcummins
ID: 18782334
Where are $strCompanyname and $providerID being set?
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18782377
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;
      }
}
?>
0
 
LVL 9

Accepted Solution

by:
under_dog earned 500 total points
ID: 18782429
Try this:

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

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

$i = 0;

while($row = mysql_fetch_array($SQLstr2)){
      $strCompanyname = $row['strCompanyname'];
      $providerID = $row['providerID'];
?>
<table id="admin_list" align="center" border="1">
<?php
      $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;
      }
}
?>
0
 
LVL 24

Expert Comment

by:glcummins
ID: 18782454
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.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question