Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid

Status
Not open for further replies.

Sitehelp

Technical User
Feb 4, 2004
142
GB
Any ideas how I create a BASIC datagrid, well at least I presume its a datagrid anyway, what I want is a list of all users in my database and then next to that an option to edit and delete them, is this easy and quick? I really could do with something like this? any ideas anyone! cheers all!
 
What you want to do is create a repeating block of HTML in which the dynamic content is printed. Here's the basic idea:
Code:
# SQL etc.
$SQL = "SELECT * FROM userlist";
$result = mysql_query($SQL) OR die(mysql_error());

# open table 
print('<table width="500">');

# repeating section
while($row = mysql_fetch_assoc($result)){

   # one <tr> per user
   print('<tr><td>'.$row['firstname].' '.$row['lastname']."</td>\n");
   print('<td><a href="delete_user.php?id='.$row['id'].'>Delete</a></td></tr>');
}
# close table
print('</table>');

This assumes you have a script to delete the user by id. If it were in a form you could have checkboxes etc.

Anyway, this is more a question about the HTML then than PHP. It's a design question. The implementation above solves it in principle.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top