Jump to content


Photo

Inner Join Socorro!


  • Faça o login para participar
6 replies to this topic

#1 guikassio

guikassio

    Novato no fórum

  • Usuários
  • 16 posts
  • Sexo:Masculino

Posted 07/12/2010, 17:15

Olá boa tarde a todos, estou coma seguinte dúvida no meu código. Quando peço para imprimir na tela os dados digitados anteriormente ele aparece somente os campo Hora, Cliente, Data, tecnico responsavel, produtos, materia, ferramentas, tipo de serviço, garantia, observações... Contudo os campos CPF, endereço, bairro, cidade, estado, cep, email, telefones não aparece. Segue abaixo o código usado por mim.


<?php require_once('Connections/data.php'); ?>
<?php require_once('Connections/data.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!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;
}
}

$colname_DetailRS1 = "-1";
if (isset($_GET['recordID'])) {
$colname_DetailRS1 = $_GET['recordID'];
}
mysql_select_db($database_data, $data);
$query_DetailRS1 = sprintf("SELECT * FROM ordemservico INNER JOIN cliente ON ordemservico.Cliente = nome WHERE Cod_Equipamento = %s", GetSQLValueString($colname_DetailRS1, "int"));
$DetailRS1 = mysql_query($query_DetailRS1, $data) or die(mysql_error());
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);
$totalRows_DetailRS1 = mysql_num_rows($DetailRS1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>.:: Intranet Pro CAB ::.</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<p>
<script type="text/javascript">
self.print ();
</script>
<table width="640" border="1" align="center" cellpadding="4" cellspacing=" 0" bordercolor="#000000">
<tr>
<td><table width="100%" border="0" cellspacing=" 0" cellpadding="0">
<tr bgcolor="#FFFFCC">
<td width="151"><img src="img/logo-procab.png" width="224" height="93" alt="Logo Pro CAB" /></td>
<td align="center" bgcolor="#FFFFCC"><p><b>ORDEM
DE SERVI&Ccedil;O - No. <?php echo $row_DetailRS1['Cod_Equipamento']; ?><br />
</b>Pro CAB TECNOLOGIA EM REDES LTDA - Av. Oito de Dezembro, nº 31, Centro - 36.307-250 - Telefone: (32) 3372-7033 - Site: www.ProcabRedes.com.br</p></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing=" 0" cellpadding="0">
<tr>
<td width="276"><b><font color="#000000">T&Eacute;CNICO
RESPONS&Aacute;VEL</font></b><font color="#000000"><?php echo $row_DetailRS1['Funcionario']; ?></font> <font color="#000000"><br />
</font></td>
<td width="176"><b>DATA
ENTRADA </b><?php echo $row_DetailRS1['Data_Entrada']; ?><b><br />
</b></td>
<td width="176" valign="top"><b>HORA
ENTRADA </b><?php echo $row_DetailRS1['Hora_Entrada']; ?><b><br />
</b></td>
</tr>
</table></td>
</tr>
<tr>
<td><div align="left">
<table width="100%" border="0" cellspacing=" 0" cellpadding="0">
<tr>
<td><div align="center"><b>DADOS
DO CLIENTE</b></div></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="450"><b>Raz&atilde;o
Social/Nome :</b> <?php echo $row_DetailRS1['Cliente']; ?><br />
</td>
<td><b>CGC/CPF:</b> <?php echo $row_DetailRS1['cpf']; ?><br /></td>
</tr>
</table>
<b>Endere&ccedil;o:</b> <span class="verdana"></span><span class="verdana"></span><?php echo $row_DetailRS1['endereco']; ?><br />
<table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="189"><strong>Bairro:</strong> <?php echo $row_DetailRS1['bairro']; ?></td>
<td width="146"><strong>Cidade:</strong> <?php echo $row_DetailRS1['cidade']; ?></td>
<td width="143"><b><strong>Estado: </strong></b><?php echo $row_DetailRS1['estado']; ?></td>
<td width="140"><strong>CEP:</strong> <?php echo $row_DetailRS1['cep']; ?><br /></td>
</tr>
<tr>
<td colspan="3"><b>Telefones: </b> <span class="verdana"></span><?php echo $row_DetailRS1['fone_com']; ?>/<span class="verdana"></span> <?php echo $row_DetailRS1['fone_res']; ?>/<span class="verdana"></span> <?php echo $row_DetailRS1['celular']; ?></td>
<td><b>E-mail: </b><span class="verdana"></span> <?php echo $row_DetailRS1['email']; ?></td>
</tr>
</table></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td colspan="2"><div align="center"><b>DADOS
DO EQUIPAMENTO</b></div></td>
</tr>
<tr>
<td width="239" valign="top"><b> Produtos:
</b><?php echo $row_DetailRS1['Equipamento']; ?><b><br />
</b></td>
<td width="383" valign="top"><b>Tipo de Serviço:
</b><?php echo $row_DetailRS1['Marca']; ?><b><br />
</b></td>
</tr>
<tr>
<td colspan="2" valign="top"><b>Materias Necessários: </b><?php echo $row_DetailRS1['Modelo']; ?><b><br />
</b></td>
</tr>
<tr>
<td colspan="2" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="25%"><b>Ferramentas Necessárias:<br />
</b><?php echo $row_DetailRS1['Setor']; ?><b><br />
<br />
</b></td>
<td width="26%"><b>Garantia:<br />
</b><?php echo $row_DetailRS1['Garantia']; ?><b><br />
</b></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2" valign="top"><p><b>Observações:<br />
</b><?php echo $row_DetailRS1['Problemacliente']; ?><b><br />
</b>&nbsp;&nbsp;</p>

<p align="right">&nbsp;</p></td>
</tr>
<tr>
<td valign="top">&nbsp;&nbsp;&nbsp;______________________&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
<b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Assinatura
do T&eacute;cnico</b>&nbsp;</td>
<td valign="top"><div align="right">_____________________&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
<b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Assinatura
do Cliente</b>&nbsp;<b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></div></td>
</tr>
</table></td>
</tr>
<tr>
<td><div align="center"><b>Pro CAB TECNOLOGIA EM REDES LTDA - Av. Oito de Dezembro, nº 31, Centro - 36.307-250 - Telefone: (32) 3372-7033 - Site: www.ProcabRedes.com.br</b></div></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($DetailRS1);
?>

#2 Laureano Pereira

Laureano Pereira

    Novato no fórum

  • Usuários
  • 15 posts
  • Sexo:Masculino
  • Localidade:Porto Alegre

Posted 09/12/2010, 13:12

Tende fazer assim a sua consulta:

$query_DetailRS1 = sprintf("SELECT os.*, cli.* FROM ordemservico os INNER JOIN cliente cli ON os.Cliente = nome WHERE os.Cod_Equipamento = %s", GetSQLValueString($colname_DetailRS1, "int"));

Edição feita por: Laureano Pereira, 09/12/2010, 13:13.


#3 guikassio

guikassio

    Novato no fórum

  • Usuários
  • 16 posts
  • Sexo:Masculino

Posted 10/12/2010, 07:14

Tende fazer assim a sua consulta:

$query_DetailRS1 = sprintf("SELECT os.*, cli.* FROM ordemservico os INNER JOIN cliente cli ON os.Cliente = nome WHERE os.Cod_Equipamento = %s", GetSQLValueString($colname_DetailRS1, "int"));



Amigo, trocando a linha, todos os campos ficarão em branco.

#4 Laureano Pereira

Laureano Pereira

    Novato no fórum

  • Usuários
  • 15 posts
  • Sexo:Masculino
  • Localidade:Porto Alegre

Posted 10/12/2010, 10:17


Tende fazer assim a sua consulta:

$query_DetailRS1 = sprintf("SELECT os.*, cli.* FROM ordemservico os INNER JOIN cliente cli ON os.Cliente = nome WHERE os.Cod_Equipamento = %s", GetSQLValueString($colname_DetailRS1, "int"));



Amigo, trocando a linha, todos os campos ficarão em branco.


Testa a consulta diretamente no phpmyadmin, ou mysql query browser, troca só a variável na cláusula where por um valor... e vê o resultado

#5 guikassio

guikassio

    Novato no fórum

  • Usuários
  • 16 posts
  • Sexo:Masculino

Posted 10/12/2010, 10:28

Quando eu modifico a linha por: $query_DetailRS1 = sprintf("SELECT ordemservico, cliente FROM ordemservico.cliente = nome WHERE Cod_Equipamento = %s", GetSQLValueString($colname_DetailRS1, "int"));
vem a resposta: SELECT command denied to user 'procabrede'@'187.17.98.11' for table 'cliente'

#6 Laureano Pereira

Laureano Pereira

    Novato no fórum

  • Usuários
  • 15 posts
  • Sexo:Masculino
  • Localidade:Porto Alegre

Posted 13/12/2010, 10:44

Você fez alguns dos testes que falei?

#7 guikassio

guikassio

    Novato no fórum

  • Usuários
  • 16 posts
  • Sexo:Masculino

Posted 13/12/2010, 16:50

Sim, fiz os testes, contudo me deparo com uma situação inusitada, pois fazendo testes no servidor local o sistema funciona perfeitamente, realizando todas consultas e jogando na tela os resultados.

Segue alguns arquivos os arquivo

Attached Files


Edição feita por: guikassio, 13/12/2010, 16:50.





1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq