Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 2nd, 2006, 01:33 AM
Authorized User
 
Join Date: Nov 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default display my database in an array

my database usersdb has a table named users and is made up of id, username and password i only need to display the username in an array, so that i can select them individually... thnx...

 
Old December 2nd, 2006, 01:51 AM
Authorized User
 
Join Date: Nov 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this is my html code and i want to insert a array box after the Access the time-in/time-out table for user
using php code, just like my previous post i only want to display in an array box the content of my table named users but only the username.

here's the html code:

<html>
<head>
</head>
<body>
<h3>USER'S MANAGEMENT</h3>
<input name="radiobutton" value="rb8" type="radio">
<b>Add/Delete/Modify password of users</b>
<br>
<br>
<input name="radiobutton" value="rb9" type="radio">
<b>Access the time-in/time-out table for user</b>
<br>
<br>
<input value="Manage User's" type="submit">
</body>
</html>

where should i insert my php script?

 
Old December 3rd, 2006, 01:25 AM
Registered User
 
Join Date: Dec 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It sounds like you want to construct a combo box/select field/etc that the user can click to drop down a list of users to select from - is that right?

How about something like this between the <br> tags after "Access the time..."?
<?
echo "<select>\n";
  $query = "SELECT username FROM users ORDER BY username ASC";
  $res = @mysql_query($query);
  while($row = mysql_fetch_array($res)) {
    printf("<option value=\"$row[username]\">$row[username]</option>\n");
  }
  mysql-free_result($res);
echo "</select>";
?>

I've assumed that you're connecting to the database somewhere above the opening <html> tag. If that's not a safe assumption, you might want to include something like this above <html>:

<?
$sql = mysql_connect(localhost, <db_user>, <password>);
@mysql_select_db(usersdb, $sql);
?>

Hope that helps.






Similar Threads
Thread Thread Starter Forum Replies Last Post
div element in array won't display onload linus9 BOOK: Beginning JavaScript 3rd Ed. ISBN: 978-0-470-05151-1 5 November 6th, 2008 02:08 AM
display byte array of pdf in jsp mahendra.w JSP Basics 2 September 23rd, 2007 11:23 PM
display byte array of jpeg in jsp mahendra.w JSP Basics 1 September 4th, 2007 06:53 AM
Get and Display Array shah123 C# 3 March 27th, 2007 09:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.