Jump to content

Result script php in same page


m2008

Recommended Posts

I have script a.php

 

<html>
<head>
<link rel="stylesheet" type="text/css" href="f.css">

</head>

<body>
<ul>
<li><a class="active" href="afisare.php">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>

</body>
</html>

 

and script afisare.php:

<?php
session_start();
// conectare la server
$conn = new mysqli('localhost', 'root', '', 'db');
// verifica conexiunea
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//require_once('conectare.php');
echo "<div id=\"continut\">";
$sql = "select denumire,pret,categorie from poze";
$result = $conn->query($sql);
$nr=$result->num_rows;
for ($i=0;$i<$nr;$i++)
{
$row=$result->fetch_assoc();
$poza=$row['denumire'].'.jpg';
echo "<img src=\"".$poza."\" style=\"width:200px;height:200px\">";
}
echo "</div>";
?>

 

if click on link Home, i want display result of script afisare.php in page of a.php, in new div element.

 

How do it?

Link to comment
Share on other sites

You need to use ajax. Have a Javascript function send an ajax request to get the output from that script and display it in the other element. Or you can set up your HTML as a template file and include the template and fill in the space for the div with the result from the script.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...