|
|||
Linux - Algumas dicas e exemplos 02-10Índice do grupo | Página anterior | Próxima página | PHP | |
mysql> select * from pgs; +------+-------+------------+-------------+--------+ | id | grupo | nome | url | valor | +------+-------+------------+-------------+--------+ | 0001 | abc | página xy | xy_010.html | 000045 | | 0002 | rst | página wz | wz_310.html | 000003 | | 0003 | klm | página uv | uv_145.html | 000018 | | 0004 | rst | página tx | tx_420.html | 000012 | | 0005 | rst | página xx | xx_025.html | 000115 | | 0006 | abc | página yy | yy_500.html | 000020 | | 0009 | abc | página zz | zz_120.html | 000009 | | 0008 | abc | página zy | zy_100.html | 000044 | | 0010 | klm | página uu | uu_220.html | 000021 | | 0011 | abc | página yu | yu_180.html | 000055 | +------+-------+------------+-------------+--------+ 10 rows in set (0.00 sec)
<html>
<head>
<title>Teste 20</title>
</head>
<body>
<?php
$msg0 = "Falha na conexão com o banco de dados";
$msg1 = "Impossível selecionar o banco de dados";
$conex = mysql_pconnect("localhost","root") or die($msg0);
mysql_select_db("stats",$conex) or die($msg1);
?>
<table width="430" cellspacing="0" border="1" cellpadding="2">
<tbody>
<tr>
<td>Id</td>
<td>Grupo</td>
<td>Nome</td>
<td>Url</td>
<td>Valor</td>
</tr>
<?php
$query = "SELECT id,grupo,nome,url,valor FROM pgs ORDER BY grupo";
$result = mysql_query($query, $conex);
while ($line = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>$line[id]</td>";
echo "<td>$line[grupo]</td>";
echo "<td>$line[nome]</td>";
echo "<td>$line[url]</td>";
echo "<td>$line[valor]</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</body>
</html>
| Id | Grupo | Nome | Url | Valor |
| 0001 | abc | página xy | xy_010.html | 000045 |
| 0008 | abc | página zy | zy_100.html | 000044 |
| 0009 | abc | página zz | zz_120.html | 000009 |
| 0006 | abc | página yy | yy_500.html | 000020 |
| 0011 | abc | página yu | yu_180.html | 000055 |
| 0003 | klm | página uv | uv_145.html | 000018 |
| 0010 | klm | página uu | uu_220.html | 000021 |
| 0005 | rst | página xx | xx_025.html | 000115 |
| 0004 | rst | página tx | tx_420.html | 000012 |
| 0002 | rst | página wz | wz_310.html | 000003 |
setcookie(name, value, expire, path, domain);
<?php
setcookie("esta_pag", "sim", time()+3600);
?>
<html>
<head>
<title>Teste</title>
</head>
<body>
Página de teste
</body>
</html>
<html>
<head>
<title>Teste</title>
</head>
<body>
Página de teste<br>
<br>
<?php
// ver um cookie
echo $_COOKIE["esta_pag"];
//ver todo os cookies do domínio
print_r($_COOKIE);
?>
</body>
</html>
<?php
setcookie("esta_pag", "", time()-3600);
?>
|
Melhor visto com 1024x768 px © Marco Soares Termos de uso |