Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP or HTML Code Needed

Posted on 2011-02-28
3
Medium Priority
?
240 Views
Last Modified: 2012-05-11
I have a mysql database that I've entered some data into via the PHPADMIN page. Is there any way I can display all of this information in a browser? The mysql database name is PEND & the table is PENDING. The fileds are only f_name, l_name, assn_date, interv_date, and actual_date.

I already have a LAMP server setup to throw the code into the www folder. If I could get some help with the code I think I can take it from there. Thanks
0
Comment
Question by:wantabe2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 668 total points
ID: 34997194
Try this, replacing the user and pass with your own

<?php
error_reporting(E_ALL);
$link = mysql_connect('localhost','user','password') or die(mysql_error());
mysql_select_db("PEND") or die(mysql_error());

$query = "select f_name, l_name, assn_date, interv_date, actual_date from PENDING";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo"$row[f_name], $row[l_name], $row[assn_date], $row[interv_date], $row[actual_date]";
}
?>

Open in new window

0
 
LVL 6

Assisted Solution

by:MatthewP
MatthewP earned 664 total points
ID: 34997271
To connect to mysql:
http://php.net/manual/en/function.mysql-connect.php

To select the database:
http://www.php.net/manual/en/function.mysql-select-db.php

To run a SELECT query:
http://www.php.net/manual/en/function.mysql-query.php

To fetch rows of data:
http://www.php.net/manual/en/function.mysql-fetch-array.php

An example of all of this you should be able to modify with your own HTML: You will need to replace what's in CAPS below with your own credentials / SQL query:

$host="localhost";
$database = "MY_DATABASE_NAME";
$username = "USER_NAME";
$password = "PASSWORD";

$dbh=mysql_connect($host,$username,$password) or die("Could not connect to mysql");
$select=mysql_select_db($database,$dbh) or die ("Cannot select database");

$sql="SELECT * from MY_TABLE"; // Add your own query here

$query=mysql_query($sql);

while ($rows=mysql_fetch_array($query)){
        foreach ($rows as $fieldname => $value){
                print "$fieldname = $value<br />";
        }
        print "<hr>";
}

Open in new window

0
 
LVL 3

Assisted Solution

by:pius_babbun
pius_babbun earned 668 total points
ID: 34997282
Hi ,Please check if this code is helpful ,.
<?php
$conn 		= mysql_connect('hostname','db_username','db_pass');

$database   = mysql_select_db('database_name',$conn);//database_name = PENDING

$query      = "SELECT f_name, l_name, assn_date, interv_date,  actual_date FROM database_table_name ";

$result		= mysql_query($query) or die('Database Error:'.mysql_error());

$num_rows   = mysql_num_rows($results);

?>
<table>
<?php for($i=0;$i<$num_rows;$i++){ ?>
<?php $rows[]	= mysql_fetch_array($results);?>
	<tr>
		<td><?=$rows[$i]['f_name']?><td>
		<td><?=$rows[$i]['l_name']?><td>
		<td><?=$rows[$i]['assn_date']?><td>
		<td><?=$rows[$i]['interv_date']?><td>
		<td><?=$rows[$i]['actual_date']?><td>
	<tr>
<?php } ?>
</table>

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question