Jump to content

dynamic Php <a href="?opc=news">news</a>


Recommended Posts

Hi.

 

I am trying to list, modify, and delete capturing the form action, but it seem I have an error on:

<a href="?opc=news">news</a>

 

Can anyone help?

 

This is the code:

 

<html>

<head>

<title></title>

</head>

<body>

<h3>menu principal

<table witdh=100% with=100% align=right><tr><td><b>[</b><a href="?opc=news">news</a><b>]</b></td></tr></table>

</h3>

<br>

<?

$conn=mysql_connect("localhost","","")or die(mysql_error());

mysql_select_db("news")or die(mysql_error());

if($action=="delete"){

if(isset($email_id)) {

mysql_query("delete from emails where id=$email_id",$conn)or die(mysql_error());

$action="list";

}

}

//save

if($submitit=="guardar noticia"){

if($action=="update") $query=mysql_query("update noticias set fecha='$fecha',titulo='$titulo',contenido='$contenido' where id=$id",$conn)or die(mysql_error()); else $query=mysql_query("insert into noticias (fecha,titulo,contenido) values ('$fecha','$titulo','$contenido')",$conn)or die(mysql_error());

unset($submitit,$fecha,$titulo,$contenido);

$opc="news";

}

//*** NEWS

if($opc=="news"){

echo "aqui estoy";

if($action=="edit"){

$query=mysql_query("select * from noticias where id=$id",$conn)or die(mysql_error());

list($id,$fecha,$titulo,$contenido)=mysql_fetch_row($query);

}

echo "<form method=post action=$PHP_SELF";

if($action=="edit") echo "?action=update&id=$id";

echo " onsubmit=\"if(titulo.value=='' || contenido.value==''){alert('Los datos en blanco no estan permitidos.');return false;}\"><table><tr><td>fecha<br><input class=text type=text name=fecha size=40 value=";

if($action=="edit")echo $fecha; else echo date("Y-m-d");

echo "><font class=note> Ej: aaaa-mm-dd</font><br>titulo<br><input class=text id=titulo type=text name=titulo size=40 value='$titulo'><br>contenido<br><textarea id=contenido rows=15 cols=60 name=contenido>$contenido</textarea></td></tr><tr><td align=right><input class=text type=submit name=submitit value='guardar noticia'></td></tr></table></form>";

$query=mysql_query("select * from noticias order by fecha DESC",$conn)or die(mysql_error());

$exis=mysql_num_rows($query);

if($exis){

echo "<table width=100% align=center class=data1 border=0 cellspacing=0 cellpadding=0><caption>Noticias Existentes</caption><tr><th>Id</th><th>Fecha</th><th>Titulo<br>Contenido</th></tr>";

$color="#dddddd";

while(list($id_noti,$fecha,$titulo,$noticia)=mysql_fetch_row($query)){

if($color=="#dddddd") $color = "#ffffff"; else $color="#dddddd";

echo "<tr bgcolor=$color><td valign=top>$id</td><td nowrap valign=top>$fecha</td><td valign=top><a href=?opc=$opc&action=edit&id=$id class=link2>$titulo</a></td></tr>";

}

echo "</table>";

}

}

//END NEWS

?>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/111486-dynamic-php-news/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.