By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,353 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,353 IT Pros & Developers. It's quick & easy.

Getting list values dyanmically from website

P: 2
Hi All,

I am a java developer got a php project from the office how to create a list.values in the list should come from the database MYSQL what to do for this please help me out as early as possible.

Thanks in Advance,

Nov 7 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 5K+
P: 5,058

You would obviously have to have PHP fetch the data from your MySQL database and print it into this list you need. You could use the Improved MySQL extension to get the data, and the echo statement to print it.

Give it a try and let us know if you run into any problems.
Nov 8 '08 #2

P: 16

You must first connect to the database. There are many ways to connect to the database. I will present one simple example. First create a config.php file an write:
$dbhost = "your_mysql_host"; // most of the times is "localhost"
$dbuser = "your_mysql_user";
$dbpassword = "your_mysql_password";
$dbname = "your_mysql_database_name";

$conn = mysql_connect($dbhost,$dbuser,$dbpassword) or die("Can not connect to MySQL!");
mysql_select_db($dbname, $conn) or die("Can not find the database");


Then in your let's say list.php write:


$q = mysql_query("SELECT * FROM yor_database_table");
while($row = mysql_fetch_array($q)) {
echo $row['your_database_table_column'];

There are many ways you can do that. I wanted to present one simple approach.
I must admit i did not verified the code. I've just wrote it as I knew at the moment.

Hope it helps.
Nov 8 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.