-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconectar2.php
More file actions
36 lines (30 loc) · 929 Bytes
/
conectar2.php
File metadata and controls
36 lines (30 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
$cn=new mysqli("localhost","root","root","world");
if ( !$cn->query("drop table if exists test") ||
!$cn->query("create table test(id int)")||
!$cn->query("insert into test(id) value (1),(2),(3),(4)")
) {
echo "Fallo la creacion de la tabla:(".$cn->errno.")".
$cn->error;
}
$resultado=$cn->query("select id from test order by id Asc");
echo "orden inverso...<br>";
for ($i=$resultado->num_rows-1; $i>=0; $i--) {
$resultado->data_seek($i);
$fila=$resultado->fetch_assoc();
echo "id= ".$fila['id']."<br>";
}
echo "orden de conunto de resultado <br>";
$resultado->data_seek(0);
while ($i=$resultado->fetch_assoc()) {
echo "id =". $i['id']."<br>";
}
?>
<?php
$cn->real_query("SELECT id FROM test ORDER BY id ASC");
$resultado = $cn->use_result();
echo "Orden del conjunto de resultados...\n";
while ($fila = $resultado->fetch_assoc()) {
echo " id = " . $fila['id'] . "\n";
}
?>