Olá pessoal, como faz tempo que não posto códigos, irei adiantar aqui algumas funções que haverá no próximo upload da crisLib ;]

PHP:
  1. function campo($tabela,$campo,$id){
  2.     $sel = mysql_query("SELECT * FROM $tabela WHERE id = '$id'") or die(mysql_error());
  3.     $linha = mysql_fetch_array($sel);
  4.     return $linha[$campo];
  5. }

A função campo() serve para resgatar dados rapidinho somente usando o ID do registro. Por exemplo, se estivermos exibindo uma notícia, basta fazer:

PHP:
  1. <b><?= campo("tabela_noticias","titulo",$_GET["id"]) ?></b><br />
  2. <?= campo("tabela_noticias","descricao",$_GET["id"]) ?><br /><br />
  3. <?= campo("tabela_noticias","texto",$_GET["id"]) ?><br /><br />
  4. Fonte: <?= campo("tabela_noticias","fonte",$_GET["id"]) ?>

De outra forma teríamos que escrever:

PHP:
  1. <?
  2. $sel = mysql_query("SELECT * FROM tabela_noticias WHERE id = '{$_GET["id"]}'") or die(mysql_error());
  3. $linha = mysql_fetch_array($sel);
  4. ?>
  5. <b><?= $linha["titulo"] ?></b><br />
  6. <?= $linha["descricao"] ?><br /><br />
  7. <?= $linha["texto"] ?><br /><br />
  8. <?= $linha["fonte"] ?>

Economia de algumas linhas e algum tempo digitando códigos...

Outra função é um resumo do mysql_num_rows, barbadinha e que me economiza também alguns segundos:

PHP:
  1. function total($query){
  2.     $num = mysql_num_rows($query);
  3.     return $num;
  4. }

E pra fechar:

PHP:
  1. function str($nome,$tipo){
  2.     if($tipo == 0){
  3.         $var = mysql_real_escape_string($_POST[$nome]);
  4.     }else{
  5.         $var = mysql_real_escape_string($_GET[$nome]);
  6.     }
  7.     return $var;
  8. }

Com a função acima, em vez de escrever...

PHP:
  1. $nome = mysql_real_escape_string($_POST["nome"]);
  2. $email = mysql_real_escape_string($_POST["email"]);
  3. $telefone = mysql_real_escape_string($_POST["telefone"]);

...para resgatar dados vindos de um formulário, bastará escrever...

PHP:
  1. $nome = str("nome",0);
  2. $email = str("email",0);
  3. $telefone = str("telefone",0);

Facinho não?