Ok I have a blog in php and mysql. I want to open the url in a div with show and hide javascript functions. Works fine with the rest of divs but the problem is when I click on a vanity url my web is always updated. I have a function that format this urls and i can't edit the html from this urls. I want open the content of this url on the same div that blog is it without updating the index page. How can I implement this? Here my code:
blog.php
<?php
if($_GET['id']) {
$sql = "select * from blog where id = '".$_GET['id']."' ";
$consulta = mysql_query($sql);
if (mysql_num_rows($consulta)!=0) {
$fila=mysql_fetch_assoc($consulta);
$fecha = date("d.m.Y", strtotime($fila['fecha']));
echo $fila["nombre"];
}
} else {
$sql = "select * from blog where estado = 1 order by fecha desc ";
$consulta = mysql_query($sql);
while ($fila=mysql_fetch_assoc($consulta)) {
$fecha = date("d.m.Y", strtotime($fila['fecha']));
$url = "blog/".formato($fila["nombre"])."-".$fila["id"].".html";
?>
<a id="enlace" href="<? echo $url; ?>"><?php echo $fila["nombre"]; ?></a>
<?
}
} ?>
My javascript function:
<script type="text/javascript">
$(document).ready(function(){
$("#enlace").click(function(){
$('#blog').hide(); //muestro mediante id
$('#content_blog').show(); //muestro mediante clase
});
});