associar sistema de notícias em 2 tabela
Desde já agradeço a atenção !
Minha dúvida e o seguinte, eu tenho um sistema de notícias, na verdade estou arrumando ele e retirando alguns erros.
Enfim, na hora de fazer uma postagem as informações do usuário que criou a notícia não fica salva o nome do mesmo, e sim o ID do ADM que estiver logado no painel e fazer a postagem.
As informações da notícia fica em ma_noticias e os dados de login do user fica em ma_usuario.
minha dúvida é a seguinte, como posso pela id fornecida pela tabela ma_noticias informa o nome do usuário que está armazenado na tabela ma_usuario. ambas possuem mesmo nome nas id "usr_id" .
eu fiz uma listagem simples pelas ferramente que dreamweaver oferece, porém precisaria colocar o nome do autor nas postagem, mais so fornece o ID, no caso se eu linkar ficaria " Autor: 1 "
me falaram para efetuar consulta pelo ID fornecido porém sei quase nada de conexão com SQL
infelizmente tentei vários coisas que eu vi pela internet e não tive sucesso se alguém poder me ajudar nesta ocasião.
Códigos utilizado do local que travei, sem códigos reconhecidos pela net >
<?php require_once('../Connections/database.php'); ?>
Se
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = ""){
if (PHP_VERSION < 6) {
$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;
}
}
$maxRows_config = 10;
$pageNum_config = 0;
if (isset($_GET['pageNum_config'])) {
$pageNum_config = $_GET['pageNum_config'];
}
$startRow_config = $pageNum_config * $maxRows_config;
mysql_select_db($database_database, $database);
$query_config = "SELECT * FROM ma_noticias ORDER BY not_id DESC";
$query_limit_config = sprintf("%s LIMIT %d, %d", $query_config, $startRow_config, $maxRows_config);
$config = mysql_query($query_limit_config, $database) or die(mysql_error());
$row_config = mysql_fetch_assoc($config);
if (isset($_GET['totalRows_config'])) {
$totalRows_config = $_GET['totalRows_config'];} else {
$all_config = mysql_query($query_config);
$totalRows_config = mysql_num_rows($all_config);
}
$totalPages_config = ceil($totalRows_config/$maxRows_config)-1;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>index noticias</title>
<style type="text/css">body{
margin:0;
}
#fundo{
background-image: url(fundo.png);
background-repeat: no-repeat;
height: 81px;
width: 620px;
}
.titulo{
font-family: Verdana, Geneva, sans-serif;
font-size: 16px;
color: #000;
text-decoration: none;
font-weight: bold;
margin-top: auto;
margin-left: auto;
text-align: left;
padding:2px;
}
.sub{
font-family: sans-serif;
font-size: 14px;
color: #797979;
text-decoration: none;
font-weight: bold;
text-align: left;
}
.extras {
font-family: Verdana, Geneva, sans-serif;
font-size: 14px;
font-weight: bold;
color: #000;
text-decoration: none;
text-align: right;
}
</style>
</head>
<body>
<?php do { ?>
<div id="fundo">
<table width="623" height="67" border="0">
<tr>
<th width="621" height="61" rowspan="3" scope="col"><table width="609" border="0">
<tr>
<th width="108" height="50" rowspan="3" scope="col"><img src="<?php echo $row_config['not_rev']; ?>" width="100" height="50"/></th>
<th width="383" scope="col" class="titulo"><?php echo $row_config['not_titulo']; ?></th>
<th width="104" rowspan="3" scope="col"></th>
</tr>
<tr>
<td class="sub"><?php echo $row_config['not_resumo']; ?></td>
</tr>
<tr>
<td height="21" class="extras"> </td>
</tr>
</table></th>
</tr>
</table>
</div>
<?php } while ($row_config = mysql_fetch_assoc($config)); ?>
</body>
</html>
<?php
mysql_free_result($config);
?>
Obrigado pessoalDiscussão (1)
Carregando comentários...