Page 1 of 1

Same problem but different results

Posted: Wed May 16, 2007 11:25 am
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

Posted: Wed May 16, 2007 11:36 am
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

Double Post

Posted: Wed May 16, 2007 1:35 pm
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.