Jump to content


Photo

Duvida Em Php


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

#1 Renato Neves

Renato Neves

    Novato no fórum

  • Usuários
  • 8 posts
  • Sexo:Não informado

Posted 06/12/2010, 21:50

Esse código é de um form para cadastrar testemunhos e depois tem um select de alguns testemunhos cadastrados no banco porem preciso inverter e nao estou tendo exito da alguns erros muito estranhos, alguem poderia me ajudar:


Código original:


<?

foreach($_REQUEST as $ind=>$val)
{
	$$ind=$val;
}

if(isset($cad))
{
	$campos = objSql::camposTabela('tb_testemunhos');
	objSql::cadForm($campos,'tb_testemunhos');
	objSql::msg_box('Testemunho cadastrado com sucesso! Por favor aguarde a aprovação pelo Administrador.',"?pg=cad_ministerio");
}

?>
<!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>Untitled Document</title>
<link href="../css/estilo.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>

<body>
<table width="100%" border="0"  id="tit">
  <tr>
    <td><span>T</span>estemunhos</td>
  </tr>
</table>
<br />
<?
if($idT<>"T")
{
?>
<form name="frm1" method="post" action="">
  <table width="71%" border="0" align="center" cellpadding="3" cellspacing="0" class="txt_geral">
  <tr>
    <td colspan="2" class="outraNot">Deixe aqui seu Testemunho</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td width="6%">Titulo</td>
    <td width="94%"><label>
      <input name="titulo" type="text" class="campos_login" id="titulo" size="110" />
    </label></td>
  </tr>
  <tr>
    <td>Testemunho</td>
    <td><label>
    <textarea name="testemunho" cols="110" rows="5" class="campos_login" id="testemunho"></textarea>
    </label></td>
  </tr>
  <tr>
    <td>Autor</td>
    <td><input name="responsavel" type="text" class="campos_login" id="responsavel" size="110" /></td>
  </tr>
  <tr>
    <td>E-mail</td>
    <td><input name="responsavel2" type="text" class="campos_login" id="responsavel2" size="110" /></td>
  </tr>
  <tr>
    <td>Telefone</td>
    <td><input name="ddd" type="text" class="campos_login" id="ddd" size="3" />
      <input name="telefone" type="text" class="campos_login" id="telefone" size="15" /></td>
  </tr>
  <tr>
    <td class="outraNot">&nbsp;</td>
    <td class="outraNot"><label>
      <input name="cad" type="submit" class="bt_login" id="cad" value="Enviar Testemunho" />
    </label></td>
  </tr>
</table>
  <br />
</form>
<?
}
else
{
?>
<table width="100%" border="0">
  <tr>
    <td align="center"><input name="cad2" type="submit" class="bt_login" id="cad2" value="Clique aqui e envie seu testemunho" onclick="window.location='?p=testemunhos'" /></td>
  </tr>
</table>

<br />
<?
}
if($idT<>"" && $idT<>"T")
{
	$sql.=" id_testemunho=$idT";
}
if($sql<>"")
{
$sql.=" and ";
}
$sql.=" id_status=1";
$sT = objSql::selecionar('tb_testemunhos',"*",$sql);
$dT = objSql::dados($sT);
$rT = objSql::linhas($sT);

if($rT>0 && $idT<>"T")
{
?>
<table width="95%" border="0" align="center" cellspacing="0" class="txt_geral">
  <tr>
    <td class="lineC"><span class="style1" style="text-transform:uppercase; font-size:18px">
      <?=$dT['titulo']?>
    f</span></td>
  </tr>
  <tr>
    <td bgcolor="#FEF2C2"><?=$dT['testemunho']?></td>
  </tr>
  <tr>
    <td bgcolor="#FEF2C2" class="lineC"><strong>Autor:</strong>      <? if($dT['responsavel']<>""){echo $dT['responsavel'];}else{echo "Não Informado!";}?></td>
  </tr>
  <tr>
    <td align="center">&nbsp;</td>
  </tr>
  <tr>
    <td align="left" class="outraNot">Ultimos Testemunhos</td>
  </tr>
  <tr>
    <td align="left">
    
    <?
	$sUT = objSql::selecionar('tb_testemunhos',"*","id_status=1","id_testemunho desc",5);
	
	?>
    <table width="95%" border="0">
      <?
	  while($dUT=objSql::dados($sUT))
	  {
	  ?>
      <tr>
        <td><a href="?p=testemunhos&idT=<?=$dUT['id_testemunho']?>">[+] <?=$dUT['titulo']?> </a></td>
      </tr>
   	  <?
	  }
	  ?>	
    </table>
    
    
    </td>
  </tr>
  <tr>
    <td align="center"><a href="?p=testemunhos&idT=T"><strong>Ver Todos os Testemunhos</strong></a></td>
  </tr>
</table>
<?
}
?>

  <?

if($idT=='T')
{
	$sTT = objSql::selecionar('tb_testemunhos',"*","id_status=1","id_testemunho desc");
	$rTT = objSql::linhas($sTT);
	if($rTT>0)
	{
?>
<table width="95%" border="0" align="center" class="txt_geral">
 <tr>
    <td>Clique sobre os testemunhos para visualiz&aacute;-los</td>
  </tr>
  <?
  while($dTT=objSql::dados($sTT))
  {
  ?>
  
  <tr>
    <td bgcolor="#f5f5f5"><a href="?p=testemunhos&idT=<?=$dTT['id_testemunho']?>">- <?=$dTT['titulo']?></a></td>
  </tr>
  <?
  }
  ?>	
</table>
<?
	}
}
?>

<p>&nbsp;</p>
</body>
</html>




Código atual:

<?

foreach($_REQUEST as $ind=>$val)
{
	$$ind=$val;
}

if(isset($cad))
{
	$campos = objSql::camposTabela('tb_testemunhos');
	objSql::cadForm($campos,'tb_testemunhos');
	objSql::msg_box('Testemunho cadastrado com sucesso! Por favor aguarde a aprovação pelo Administrador.',"?pg=cad_ministerio");
}

?>
<!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>Untitled Document</title>
<link href="../css/estilo.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>

<body>
<table width="100%" border="0"  id="tit">
  <tr>
    <td><span>T</span>estemunhos</td>
  </tr>
</table>
<p>
  <?
}
if($idT<>"" && $idT<>"T")
{
	$sql.=" id_testemunho=$idT";
}
if($sql<>"")
{
$sql.=" and ";
}
$sql.=" id_status=1";
$sT = objSql::selecionar('tb_testemunhos',"*",$sql);
$dT = objSql::dados($sT);
$rT = objSql::linhas($sT);

if($rT>0 && $idT<>"T")
{
?>
</p>
<table width="95%" border="0" align="center" cellspacing="0" class="txt_geral">
  <tr>
    <td class="lineC"><span class="style1" style="text-transform:uppercase; font-size:18px">
      <?=$dT['titulo']?>
    </span></td>
  </tr>
  <tr>
    <td bgcolor="#FEF2C2"><?=$dT['testemunho']?></td>
  </tr>
  <tr>
    <td bgcolor="#FEF2C2" class="lineC"><strong>Autor:</strong>
      <? if($dT['responsavel']<>""){echo $dT['responsavel'];}else{echo "N&atilde;o Informado!";}?></td>
  </tr>
  <tr>
    <td align="center">&nbsp;</td>
  </tr>
  <tr>
    <td align="left" class="outraNot">Ultimos Testemunhos</td>
  </tr>
  <tr>
    <td align="left"><?
	$sUT = objSql::selecionar('tb_testemunhos',"*","id_status=1","id_testemunho desc",5);
	
	?>
      <table width="95%" border="0">
        <?
	  while($dUT=objSql::dados($sUT))
	  {
	  ?>
        <tr>
          <td><a href="?p=testemunhos&amp;idT=<?=$dUT['id_testemunho']?>">[+]
            <?=$dUT['titulo']?>
          </a></td>
        </tr>
        <?
	  }
	  ?>
      </table></td>
  </tr>
  <tr>
    <td align="center"><a href="?p=testemunhos&amp;idT=T"><strong>Ver Todos os Testemunhos</strong></a></td>
  </tr>
</table>
<?
}
?>
<?

if($idT=='T')
{
	$sTT = objSql::selecionar('tb_testemunhos',"*","id_status=1","id_testemunho desc");
	$rTT = objSql::linhas($sTT);
	if($rTT>0)
	{
?>
<table width="95%" border="0" align="center" class="txt_geral">
  <tr>
    <td>Clique sobre os testemunhos para visualiz&aacute;-los</td>
  </tr>
  <?
  while($dTT=objSql::dados($sTT))
  {
  ?>
  <tr>
    <td bgcolor="#f5f5f5"><a href="?p=testemunhos&amp;idT=<?=$dTT['id_testemunho']?>">-
      <?=$dTT['titulo']?>
    </a></td>
  </tr>
  <?
  }
  ?>
</table>
<p>
  <?
	}
}
?>
</p>
<p><br />
  <?
if($idT<>"T")
{
?>
</p>
<form name="frm1" method="post" action="">
  <table width="71%" border="0" align="center" cellpadding="3" cellspacing="0" class="txt_geral">
  <tr>
    <td colspan="2" class="outraNot">Deixe aqui seu Testemunho</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td width="6%">Titulo</td>
    <td width="94%"><label>
      <input name="titulo" type="text" class="campos_login" id="titulo" size="110" />
    </label></td>
  </tr>
  <tr>
    <td>Testemunho</td>
    <td><label>
    <textarea name="testemunho" cols="110" rows="5" class="campos_login" id="testemunho"></textarea>
    </label></td>
  </tr>
  <tr>
    <td>Autor</td>
    <td><input name="responsavel" type="text" class="campos_login" id="responsavel" size="110" /></td>
  </tr>
  <tr>
    <td>E-mail</td>
    <td><input name="responsavel2" type="text" class="campos_login" id="responsavel2" size="110" /></td>
  </tr>
  <tr>
    <td>Telefone</td>
    <td><input name="ddd" type="text" class="campos_login" id="ddd" size="3" />
      <input name="telefone" type="text" class="campos_login" id="telefone" size="15" /></td>
  </tr>
  <tr>
    <td class="outraNot">&nbsp;</td>
    <td class="outraNot"><label>
      <input name="cad" type="submit" class="bt_login" id="cad" value="Enviar Testemunho" />
    </label></td>
  </tr>
</table>
  <br />
</form>
<?
}
else
{
?>
<table width="100%" border="0">
  <tr>
    <td align="center"><input name="cad2" type="submit" class="bt_login" id="cad2" value="Clique aqui e envie seu testemunho" onclick="window.location='?p=testemunhos'" /></td>
  </tr>
</table>

<p><br />
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>



#2 Luckas

Luckas

    Luckas

  • Usuários
  • 341 posts
  • Sexo:Masculino
  • Localidade:Itapira SP.
  • Interesses:HTML
    PHP
    CSS
    PhotoShop

Posted 07/12/2010, 00:25

desculpa a ignorancia, mas não entendi.

precisa inverter??
Luckas_
********
cheeseboy_@hotmail.com

#3 André Manoel

André Manoel

    Doutor

  • Usuários
  • 996 posts
  • Sexo:Masculino
  • Localidade:Brasilia

Posted 07/12/2010, 09:17

Qual o erro que está ocorrendo?
Iniciando na Ajuda On line...

Posted Image Meu post lhe ajudou? Reputar/votar é uma das formas de agradecer.




1 user(s) are reading this topic

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

IPB Skin By Virteq