Created
January 15, 2013 13:35
-
-
Save diogomachado/4538679 to your computer and use it in GitHub Desktop.
Exemplo de conexão com php/mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Arquivo que abre conexão com bd | |
require("conecta.php"); | |
// Sql | |
$sql = mysql_query("SELECT p.idproduto, | |
21 p.nome_produto, | |
p.descricao_produto, | |
p.preco_produto, | |
p.imagem_produto | |
FROM produto p, | |
tipo_produto tp | |
WHERE p.cod_tipo_produto = tp.cod_tipo_produto AND | |
tp.nome_tipo_produto = '$busca'")or die("Erro:" .mysql_error()); | |
$numeroLinhas = mysql_num_rows($sql) or die('<center><img src="img/ndencontrado.png" /></center> <br/> <a href="index.php"> Voltar</a>'); | |
////////////////////////////////////////// | |
for ($i=0; $i < $numeroLinhas; $i++){ | |
// recebe array | |
$resultado = mysql_fetch_array($busca); | |
// Trata os dados | |
} | |
/////////////////////////////////////////// | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment