troubleshooting Question

PHP code to display database records in a table on different pages

Avatar of imranasif17
imranasif17Flag for United States of America asked on
7 Comments1 Solution188 ViewsLast Modified:
Hi Experts:

I have a MySQL database table with the following columns: id (primary key), type, title, description

I want to display the the records in a table on a page based on the type.  If type = A display on page 1 and if type = B display on page 2.

I have the below code but it does not pull any data.

<!doctype html>
    <html lang="en">
      <meta charset="UTF-8">
      <title>database connections</title>
		$link = mysql_connect('', 'user_name', 'password'); 
		if (!$link) { 
			die('Could not connect: ' . mysql_error()); 
		echo 'Connected successfully'; 

      //execute the SQL query and return records
      $result = mysql_query("SELECT * FROM persons");
      <table border="2" style= "background-color: #84ed86; color: #761a9b; margin: 0 auto;" >
          while( $row = mysql_fetch_assoc( $result ) ){
     <?php mysql_close($connector); ?>
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros