Ver Mensaje Individual
  #4 (permalink)  
Antiguo 25/03/2011, 08:59
meuca
 
Fecha de Ingreso: marzo-2011
Mensajes: 12
Antigüedad: 13 años, 1 mes
Puntos: 1
Respuesta: Arrays en php

Cita:
Iniciado por Nexus10 Ver Mensaje
Hola meuca.
Para ir incluyendo más valores en el array sin machacar los demás tienes que poner la variable así: $torneo[]
$torneo[]=.....

Mira a ver si te funciona así.

Un saludo.



Ante todo gracias ...!!



<?php

//iniciamos una sesion para todas las páginas
session_start();

//Conectamos con la base
$conexion=mysql_connect("localhost","root","");

//seleccionamos la base de datos
mysql_select_db("torneos")
or die("Problemas en la seleccion de la base de datos");


$c=0;

$_SESSION['continente']="Europa";
function funcion_continente(){//abro funcion
$continentes = "select * from paises where Continente='".$_SESSION['continente']."'";
$continente = mysql_query($continentes);
$c=0;
while($A=mysql_fetch_array($continente)){ //abro while 1
$paises = "select * from torneos";
$pais = mysql_query($paises);

while($B=mysql_fetch_array($pais)){ //abro while 2

if ($A['nombre']==$B['pais']){ // abro if
$c=$c+1;
$nom="torneo".$c;
echo $nom."<br>";

$torneo[]=array //PONGO COM ME DICES VERDAD??
(
$nom => array
("pais" => $B['pais'],
"mes" => $B['mes'],
"ano" => $B['ano'],
"tipo" => $B['tipo'],
"nombre" => $B['nombre'],
"tipo" => $B['tipo'],
"usuario" => $B['usuario'],
"web" => $B['web'],
),
);

} // cierro if



} //cierro while 2





} //cierro while 1

ECHO "<br>pais".$torneo["torneo1"]["pais"];
ECHO "<br>nom".$torneo["torneo1"]["nombre"];
ECHO "<br>pais".$torneo["torneo3"]["pais"];
ECHO "<br>nom".$torneo["torneo3"]["nombre"];
ECHO "<br>pais".$torneo["torneo18"]["pais"];
ECHO "<br>nom".$torneo["torneo18"]["nombre"];



} //cierro funcion

funcion_continente()

?>


















Resultado : sigo sin hacer bien la operación.........






torneo1
torneo2
torneo3
torneo4
torneo5
torneo6
torneo7
torneo8
torneo9
torneo10
torneo11
torneo12
torneo13
torneo14
torneo15
torneo16
torneo17
torneo18

Notice: Undefined index: torneo1 in C:\Archivos de programa\EasyPHP5.2.10\www\allyearchess\continente .php on line 58

pais
Notice: Undefined index: torneo1 in C:\Archivos de programa\EasyPHP5.2.10\www\allyearchess\continente .php on line 59

nom
Notice: Undefined index: torneo3 in C:\Archivos de programa\EasyPHP5.2.10\www\allyearchess\continente .php on line 60

pais
Notice: Undefined index: torneo3 in C:\Archivos de programa\EasyPHP5.2.10\www\allyearchess\continente .php on line 61

nom
Notice: Undefined index: torneo18 in C:\Archivos de programa\EasyPHP5.2.10\www\allyearchess\continente .php on line 62

pais
Notice: Undefined index: torneo18 in C:\Archivos de programa\EasyPHP5.2.10\www\allyearchess\continente .php on line 63

nom