0
In a table generated from database data, you would need to change a to certain colors of a <td></td>
if the field value ipaymentstatus
in the database is as: completed, pending, Canceled_reversal.
Php code:
header('Content-Type: text/html; charset=utf-8');
// Conexão ao banco
$link = mysql_connect('localhost','paypalapi','123456');
// Seleciona o Banco de dados através da conexão acima
$conexao = mysql_select_db('paypalbd',$link); if($conexao){
$sql = "SELECT iname,iemail,ipaymentstatus,itransaction_date FROM ibn_table ORDER by itransaction_date DESC"; //Exibir últimos 10 registros, DESC
$consulta = mysql_query($sql);
echo '<table class="table">'; //table table-hover
echo '<tr>';
echo '<td><b>Cliente</b></td>';
echo '<td><b>Email</b></td>';
echo '<td><b>Status</b></td>';
echo '<td><b>Data</b></td>';
echo '</tr>';
// Armazena os dados da consulta em um array associativo
while($registro = mysql_fetch_assoc($consulta)){
echo '<tr>';
echo '<td>'.$registro["iname"].'</td>';
echo '<td>'.$registro["iemail"].'</td>';
//echo '<td>'.$registro["ipaymentstatus"].'</td>';
// Se o pagamento é aprovado seleciona cor verde
if ($registros["ipaymentstatus"] == 'Completed') {
echo '<td style="background: #222; color: #fff;">'.$registro["ipaymentstatus"].'</td>';
} else {
echo '<td style="background: #ccc; color: #222;">'.$registro["ipaymentstatus"].'</td>';
}
echo '<td>'.$registro["itransaction_date"].'</td>';
echo '</tr>';
}
echo '</table>';
}
Well didactic example, worked perfectly, thank you!
– the flash
Great! Need, the disposition.
– Sr. André Baill