Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá pessoal... estou há algum tempo tentando desenvolver um sistema de notícias através do DW, baseado em php e mysql... mas infelizmente meu conhecimento neste área AINDA é pequeno, e estou me batendo faz mais de um mês... Procurei bastante... até em sites estrangeiros, mas devo ser mto iniciante...
Minha idéia era a seguinte:
-Ter uma página com um form onde eu faço o upload da imagem pra uma pasta e o url pro banco, entre outros dados como título, fonte da notícia...
-Ter outra página que mostre todas as notícias cadastradas no banco...
-Ter uma terceira página que mostrasse a foto da notícia, seu título e os primeiros 200 caracteres do texto da notícia...
Atualmente eu faço o upload manual de uma imagem através de ftp pra um diretório, depois pego esse caminho e adiciono num campo de texto do banco, e depois coloco esse dado no patch da imagem...
Acredito que o raciocínio é mais ou menos este, falta conseguir fazer isso automaticamente...
Como disse antes, AINDA manjo bem pouco de php e mysql... por isso to usando o dreamweaver... será que alguém consegue me ajudar a fazer esse esquema funcionar usando o meu código do DW?
Formulário de envio:
<?php require_once('../Connections/conexao.php'); ?><?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}}$editFormAction = $_SERVER['PHP_SELF'];if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO noticias (fonte, titulo, subtitulo, texto, url_foto) VALUES (%s, %s, %s, %s, %s)", GetSQLValueString($_POST['fonte'], "text"), GetSQLValueString($_POST['titulo'], "text"), GetSQLValueString($_POST['subtitulo'], "text"), GetSQLValueString($_POST['texto'], "text"), GetSQLValueString($_POST['arquivo'], "text")); mysql_select_db($database_conexao, $conexao); $Result1 = mysql_query($insertSQL, $conexao) or die(mysql_error()); $insertGoTo = "ok.html"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo));}?><html><head><title>Upload</title></head><body bgcolor = "#FFFFFF" text = "#000000"><form action="<?php echo $editFormAction; ?>" name = "form1" method = "POST" enctype = "multipart/form-data"> <p>Upload de imagem:</p> <p>Título:</p> <p> <input name="titulo" type="text" id="titulo"> </p> <p>Sub-título:</p> <p> <input name="subtitulo" type="text" id="subtitulo"> </p> <p>Texto:</p> <p> <textarea name="texto" cols="100" rows="5" id="texto"></textarea> </p> <p>Nome da fonte fonte:</p> <p> <input name="fonte" type="text" id="fonte"> </p> <p>Foto:</p> <p> <input name="arquivo" type="text" id="arquivo"> </p> <p> <input type = "submit" name = "Submit" value = "Enviar"> <input type="reset" name="Submit2" value="limpar"> </p> <input type="hidden" name="MM_insert" value="form1"></form></body></html>
Arquivo que lista as noticias:
<?php require_once('../Connections/conexao.php'); ?><?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}}mysql_select_db($database_conexao, $conexao);$query_Recordset1 = "SELECT * FROM noticias";$Recordset1 = mysql_query($query_Recordset1, $conexao) or die(mysql_error());$row_Recordset1 = mysql_fetch_assoc($Recordset1);$totalRows_Recordset1 = mysql_num_rows($Recordset1);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><?php do { ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="58%"><h1><?php echo $row_Recordset1['titulo']; ?></h1></td> <td width="42%"><div align="center"><img src="<?php echo $row_Recordset1['url_foto']; ?>" width="200" height="100" /></div></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><h2><?php echo $row_Recordset1['subtitulo']; ?></h2></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="50"> </td> <td><?php echo $row_Recordset1['texto']; ?></td> <td width="50"> </td> </tr> </table></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2">fonte:<?php echo $row_Recordset1['fonte']; ?></td> </tr> <tr> <td colspan="2"> </td> </tr> </table> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?><p> </p><p> </p></body></html><?phpmysql_free_result($Recordset1);?>
Agradeço desde já a todos pela atenção dispensada...
http://forum.imasters.com.br/public/style_emoticons/default/joia.gif Um grande abraço. http://forum.imasters.com.br/public/style_emoticons/default/joia.gif
Carregando comentários...