ursula Posted June 23, 2008 Share Posted June 23, 2008 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 More sharing options...
MadTechie Posted June 23, 2008 Share Posted June 23, 2008 1. please use code tags 2. and "the problem" is ? more details please, i don't want to waste my time checking every line of code because you don't give the details required.. Link to comment https://forums.phpfreaks.com/topic/111486-dynamic-php-news/#findComment-572213 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.