Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/05/2009, 17:23
Avatar de AJVEvoluzione
AJVEvoluzione
 
Fecha de Ingreso: agosto-2004
Ubicación: Buenos Aires
Mensajes: 195
Antigüedad: 19 años, 8 meses
Puntos: 1
Como crear un nombre de imput en secuencia?

Hola!
Espero que alguien pueda ayudarme, estoy haciendo un php para poder leer y luego modificar un xml.
Lo que me hace falta saber es como cambiar el nombre del input automaticamente de acuerdo a la cantidad de lineas que tenga el xml.
Nose si se entiende cual es mi pregunta asi que paso a poner lo que tengo.

notas.xml
Código PHP:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<content>
    <featured>
        <title>1231</title>
        <copy>Texto 1.</copy>
        <image>fotos/1231.JPG</image>
        <link></link>
    </featured>
    <featured>
        <title>1302</title>
        <copy>Texto 2.</copy>
        <image>fotos/1302.JPG</image>
        <link></link>
    </featured>
    <featured>
        <title>1024</title>
                <copy>Texto 3.</copy>
        <image>fotos/1024.JPG</image>
        <link></link>
    </featured>
    <featured>
        <title>802</title>
                <copy>Texto 4.</copy>
        <image>fotos/802.JPG</image>
        <link></link>
    </featured>
    <featured>
        <title>1423</title>
                <copy>Texto 5.</copy>
        <image>fotos/1423.JPG</image>
        <link></link>
    </featured>
    <featured>
        <title>1214</title>
                <copy>Texto 6.</copy>
        <image>fotos/1214.JPG</image>
        <link></link>
    </featured>
</content>
Y este sería el php que lo lee:

Código PHP:
<?php 
$xmlstr 
file_get_contents'notas.xml' );   
$content = new SimpleXMLElement$xmlstr );   
$c2 $content->$featured->title[0];

echo 
'<table>';   
echo 
'<tr>';   
echo 
'<th>Codigo</th><th>Texto</th>  
       <th>Direccion</th><th>-</th>'
;   
echo 
'</tr>';   
foreach( 
$content->featured as $featured ) {   
    echo 
'<tr>';   
    echo 
'<td><input type="text" name="nombre1" VALUE="' $featured->title  '"  size="10"></td>';   
    echo 
'<td>' $featured->copy '</td>';   
    echo 
'<td>' $featured->image '</td>';   
    echo 
'<td>' $featured->link '</td>';   
    echo 
'</tr>';   
}   
echo 
'</table>';  

?>
Lo que quiero lograr es que en el mobre de la input (name="nombre1") , automáticamente me cambien el nombre1, por nombre2, nombre3, asi en adelante de acuerdo a la cantidad de items que tenga el xml.
Si alguien me puede dar una mano.
Muchas gracias!

Última edición por AJVEvoluzione; 23/05/2009 a las 17:24 Razón: Error en el codigo