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
ghadacr
Forum Contributor
Posts: 135 Joined: Fri May 11, 2007 10:44 am
Post
by ghadacr » Wed May 16, 2007 11:25 am
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%"> </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
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Wed May 16, 2007 11:36 am
You already have a thread on the exact same topic. No need for a new one. please use 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%"> </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
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Wed May 16, 2007 1:35 pm
Locked because of double posting.