troubleshooting Question

Display MySql queries

Avatar of Jacko_Pinto
Jacko_Pinto asked on
PHPMySQL ServerSQL
11 Comments1 Solution352 ViewsLast Modified:
Hi Experts,

I'm a php-mysql newbie and I'm trying to set up a web page which basically displays the data that I collect from a form.  The query is working fine and it's pulling up the 5 most recent records, but I'm completely stuck with this:

 - At the bottom of the page I want to add the "Next and Previous" option, so that readers can navigate to another page if there are more than five records and come back to a previous page if needed.  

Here's is the current code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>My web page</title>
 <?php
include 'inc/config.php';
include 'inc/opendb.php'; ?>
<link rel="stylesheet" type="style/principal.css" />

</head>

<body>

 <div>    
   
           <!-- QUERY STARTS HERE --->
      <?php
         mysql_query("SET NAMES 'charset=CP1251' ", $conn );
$query = "SELECT * FROM `ap_form_1` INNER JOIN `ap_element_options` ON (ap_form_1.element_4 = ap_element_options.option_id)  ORDER BY ID DESC LIMIT 5";


$result = mysql_query($query, $conn );       
       
         
if( $result === FALSE ) {
  echo '<div class="ERROR">'.mysql_error().'</div>';
} else {
while($row = mysql_fetch_array($result))
{

echo "<div id=\"bloque\">
<div id=\"fecha\">" . utf8_encode($row["element_1"]). "</div>
<div id=\"actititle\">" . utf8_encode($row["element_3"]). "</div>
<div id=\"actititle\">" . utf8_encode($row["element_5"]). "</div>
<div id=\"actititle\">" . utf8_encode($row["option"]). "(Tipo de archivo)</div>
<div id=\"actititle\">" . utf8_encode($row["element_6"]). "</div>
";

}
}

?>

                   <!--END QUERY--->


</div>


</body>
</html>

Thanks for the help!
ASKER CERTIFIED SOLUTION
skullnobrains

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 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 11 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