Same problem but different results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
User avatar
ghadacr
Forum Contributor
Posts: 135
Joined: Fri May 11, 2007 10:44 am

Same problem but different results

Post by ghadacr »

Hi Again,

Right I'm started to get somewhere, i edited the code(slightly) as follows: but the problem is know that its outputting the table header twice, any suggestions, and its not outputting all the records from the database.

Code: Select all

<?PHP include 'opendb.php'; ?>
<?PHP

$query="SELECT * FROM Users";
$result=mssql_query($query);
$num=mssql_num_fields ($result); 
//mysql_close();



?>

<form action="updated.php">


  <table width="75%" border="0"><?PHP $i=0;
	while ($i < $num) {

	$UserInitials=mssql_result($result,$i,"UserInitials");
	$UserID=mssql_result($result,$i,"UserID"); 
	$UserName=mssql_result($result,$i,"UserName"); ?>
    <tr> 
      <td width="16%"><strong>Username:</strong></td>
      <td width="22%"><strong>User initials</strong></td>
      <td width="62%">&nbsp;</td>
    </tr>
    <tr> 

	
      <td><?php echo "$UserName";?></td>
      <td><?php echo "$UserInitials";?></td>
      <td><input type=radio name=UserID value=<?php echo "$UserID"; ?><?php
++$i;
} 
?> </td>
    </tr>
    <tr> 
      <td colspan="3"><input type="Submit" value="Update"> <input type="reset" name="Reset" value="Reset"></td>
    </tr>
  </table>
</form>
Burrito: Please use php tags when posting code in the forums
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

  1. You already have a thread on the exact same topic. No need for a new one.
  2. please use

    Code: Select all

    tags when posting php code.

    Code: Select all

    <?PHP include 'opendb.php'; ?>
    <?PHP
    
    $query="SELECT * FROM Users";
    $result=mssql_query($query);
    $num=mssql_num_fields ($result); 
    //mysql_close();
    
    
    
    ?>
    
    <form action="updated.php">
    
    
      <table width="75%" border="0"><?PHP $i=0;
    	while ($i < $num) {
    
    	$UserInitials=mssql_result($result,$i,"UserInitials");
    	$UserID=mssql_result($result,$i,"UserID"); 
    	$UserName=mssql_result($result,$i,"UserName"); ?>
        <tr> 
          <td width="16%"><strong>Username:</strong></td>
          <td width="22%"><strong>User initials</strong></td>
          <td width="62%">&nbsp;</td>
        </tr>
        <tr> 
    
    	
          <td><?php echo "$UserName";?></td>
          <td><?php echo "$UserInitials";?></td>
          <td><input type=radio name=UserID value=<?php echo "$UserID"; ?><?php
    ++$i;
    } 
    ?> </td>
        </tr>
        <tr> 
          <td colspan="3"><input type="Submit" value="Update"> <input type="reset" name="Reset" value="Reset"></td>
        </tr>
      </table>
    </form>
    It's much more readable this way
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Double Post

Post by RobertGonzalez »

Locked because of double posting.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:3. Do not make multiple, identical posts. This is viewed as spam and will be deleted.
Locked