m2008 Posted February 5, 2016 Share Posted February 5, 2016 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: <?phpsession_start();// conectare la server$conn = new mysqli('localhost', 'root', '', 'db');// verifica conexiuneaif ($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 More sharing options...
justsomeguy Posted February 5, 2016 Share Posted February 5, 2016 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 More sharing options...
m2008 Posted February 5, 2016 Author Share Posted February 5, 2016 i am beginner. Who has an example? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 5, 2016 Share Posted February 5, 2016 There are many, many ajax examples online. You can either use plain Javascript to send and handle ajax requests, or you can use a library like jQuery to help simplify the process. The W3schools site has examples of both. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now