Jump to content
unrealmanel

Ver a informação contida na BD

Recommended Posts

unrealmanel

<html>
<style type="text/css">
.bold {
font-weight: bold;
}
</style>
<body>
<?php
$db="localhost";
$username="";
$password="";
$database="";

mysql_connect($db,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$code = mysql_real_escape_string($_POST['textfield']);
$query = mysql_query("SELECT * FROM wp_wpdeals_permissions WHERE code = '{$code}' ");

$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
?>
<table border="1" cellspacing="2" cellpadding="2">
<tr>
<td><font face="Arial, Helvetica, sans-serif" class="bold">Voucher Code</font></td>
<td><font face="Arial, Helvetica, sans-serif" class="bold">Deal ID</font></td>
<td><font face="Arial, Helvetica, sans-serif" class="bold">Order ID</font></td>
<td><font face="Arial, Helvetica, sans-serif" class="bold">Order Key</font></td>
<td><font face="Arial, Helvetica, sans-serif" class="bold" color="#0000FF">User Email</font></td>
</tr>

<?php
$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,"vouchers");
$f2=mysql_result($result,$i,"deal_id");
$f3=mysql_result($result,$i,"order_id");
$f4=mysql_result($result,$i,"order_key");
$f5=mysql_result($result,$i,"user_email");
?>

<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td>
</tr>

<?php
$i++;
}
?>
</body>
</html> 

Oi pessoal tudo bem? Estou tendo aqui um problema que não percebo porque esta acontecendo, a conexão é feita com sucesso a BD mas nao Retorna nenhuma informação, Alguma dica?

Agradecido desde já :)

Edited by brunoais
tags code + geshi.

Share this post


Link to post
Share on other sites
pikax

Nao uses a funcao mysql*, usa antes o mysqli*

Se usares mysqli* usa prepared statments

Tens dados na tabela?

Qual e' o valor do $code.

Usa as tags para por codigo sff.


Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender.

A beleza de um código está em decompor problemas complexos em pequenos blocos simples.

"learn how to do it manually first, then use the wizzy tool to save time."

"Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."

Share this post


Link to post
Share on other sites
unrealmanel

<!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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="test.php">
Voucher Code
<input type="text" name="textfield" value ='' />
 <input type="submit" name="Get Details" value="Get Details" />
  </label>

 </p>
</form>
</body>
</html>

Sim tenho dados na BD o Valor do $code Vai até 20 que é um numero de codigo de voucher digitado no form acima

Edited by brunoais
geshi

Share this post


Link to post
Share on other sites
pikax

o campo code na tabela e' uma string, certo?

Edited by pikax

Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender.

A beleza de um código está em decompor problemas complexos em pequenos blocos simples.

"learn how to do it manually first, then use the wizzy tool to save time."

"Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."

Share this post


Link to post
Share on other sites
HappyHippyHippo
$result=mysql_query($query) or die(mysql_error());

Edited by HappyHippyHippo

IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites
HappyHippyHippo

Esta me retornando o erro Query was empty :/

ups ... queria que fizesses isso era no query anterior

$query = mysql_query("SELECT * FROM wp_wpdeals_permissions WHERE code = '{$code}' ") or die(mysql_error());


IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.