Foros del Web » Programando para Internet » PHP »

Pregunta tonta

Estas en el tema de Pregunta tonta en el foro de PHP en Foros del Web. En esta parte de mi codigo mis Surname y los ID aparecen juntos ej:TEST1 hola2 etc... como hago para poner texto en medio ej: TEST ...
  #1 (permalink)  
Antiguo 13/07/2005, 08:32
 
Fecha de Ingreso: junio-2005
Mensajes: 111
Antigüedad: 18 años, 10 meses
Puntos: 0
Pregunta Pregunta tonta

En esta parte de mi codigo mis Surname y los ID aparecen juntos
ej:TEST1
hola2 etc...

como hago para poner texto en medio
ej: TEST ID: 1

Código PHP:
while($row mysql_fetch_array($sql)){ 
    
// Build your formatted results here. 
    
echo $row['Surname']. $row['ID']."<br />"
    } 
Bueno soy nuevo con PHP .
Gracias pot tu ayuda.
Lobo
  #2 (permalink)  
Antiguo 13/07/2005, 08:36
Avatar de Seppo  
Fecha de Ingreso: marzo-2005
Ubicación: Buenos Aires, Argentina
Mensajes: 1.284
Antigüedad: 19 años, 1 mes
Puntos: 17
Bienvenido a PHP :P
Código PHP:
while($row mysql_fetch_array($sql)){
    
// Build your formatted results here.
    
echo $row['Surname'] . " ID: " $row['ID'] . "<br />";

con los . "concatenas" lo que se muestra
  #3 (permalink)  
Antiguo 13/07/2005, 08:41
 
Fecha de Ingreso: junio-2005
Mensajes: 111
Antigüedad: 18 años, 10 meses
Puntos: 0
gracias! funciona perfecto.
  #4 (permalink)  
Antiguo 13/07/2005, 08:55
 
Fecha de Ingreso: junio-2005
Mensajes: 111
Antigüedad: 18 años, 10 meses
Puntos: 0
otra pregunta, como remplazo ID: por: <a href='instructores_update.php?ID=<?php echo $row_rs_countries['ID']; ?>'>Modify this countrys profile</a>

gracias de antemano
  #5 (permalink)  
Antiguo 13/07/2005, 19:59
Avatar de CORE
Usuario no validado
 
Fecha de Ingreso: abril-2002
Ubicación: Merida
Mensajes: 2.165
Antigüedad: 22 años
Puntos: 3
Código PHP:
<?php echo "<a href=\"instructores_update.php?ID=".$row_rs_countries["ID"]."\">Modify this countrys profile</a>"?>
saludos
  #6 (permalink)  
Antiguo 13/07/2005, 20:09
Avatar de FuLaNo_  
Fecha de Ingreso: mayo-2003
Ubicación: Don Torcuato, Buenos Aires, Argentina
Mensajes: 1.250
Antigüedad: 20 años, 11 meses
Puntos: 2
usa el "echo" con comillas simples y te evitas tener que poner la barra ante cada "...

Código PHP:
<?php
echo $row["una_var"].' <a href="instructores_update.php?ID='.$row_rs_countries["ID"].'">Modify this countrys profile</a> '.$row["otra_var"];
?>
__________________
I Love Programming...
  #7 (permalink)  
Antiguo 14/07/2005, 00:54
 
Fecha de Ingreso: junio-2005
Mensajes: 111
Antigüedad: 18 años, 10 meses
Puntos: 0
Core: Muchas gracias por tu ayuda!
FuLaNo_ : Exelente el TIP, funciona muy bien es mas sencillo asi.

aunque ya "funciona" tengo un problema con el codigo es es mi codigo original que funciona perfecto:
Código PHP:
    <table width="98%" border="1" cellpadding="3" cellspacing="0">
    <?php
        
do {
    
?>
    <tr>
        <td><?php echo $row_rs_countries['Surname']; ?></td>
        <td><a href="instructores_update.php?ID=<?php echo $row_rs_countries['ID']; ?>">Modify this country's profile</a></td>
        <td><a href="delete_processor.php?ID=<?php echo $row_rs_countries['ID']; ?>">Delete</a></td>
    </tr>
    <?php
        
}
        while (
$row_rs_countries mysql_fetch_assoc($rs_countries));
    
?>
    </table>
al darme cuenta que este codigo me bota miles de entradas de MYSQL trato de hacer una paginacion osea que me despliegue 300 entradas por pagina ahora mi problema es que me hace 11 paginas con el mismo contenido alguna idea de como lo soluciono ? En la linea donde esta Fulano (comentario en el codigo) esta el codigo que me ayudaron a cambiar y es donde radicaria el problema.

Código PHP:
<?php require_once('../../Connections/conn_newland.php'); ?>
<?php
mysql_select_db
($database_conn_newland$conn_newland);
$query_rs_countries "SELECT ID, Surname FROM tbl_instructores ORDER BY Surname ASC";
$rs_countries mysql_query($query_rs_countries);
$row_rs_countries mysql_fetch_assoc($rs_countries);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?php 

// Database Connection 
mysql_select_db('newland_tours'mysql_pconnect('localhost','root','root')) or die (mysql_error()); 

// If current page number, use it 
// if not, set one! 

if(!isset($_GET['page'])){ 
    
$page 1
} else { 
    
$page $_GET['page']; 


// Define the number of results per page 
$max_results 10

// Figure out the limit for the query based 
// on the current page number. 
$from = (($page $max_results) - $max_results); 

// Perform MySQL query on only the current page number's results 

$sql mysql_query("SELECT * FROM tbl_instructores LIMIT $from, $max_results"); 

while(
$row mysql_fetch_array($sql)){ 
do {
    
// Ayuda de FULANO  

echo $row_rs_countries["Surname"]. " ID: " $row_rs_countries['ID'] . ' <a href="instructores_update.php?ID='.$row_rs_countries["ID"].'">Modify this countrys profile</a> '"<br />"
}    
        while (
$row_rs_countries mysql_fetch_assoc($rs_countries));
    



// Figure out the total number of results in DB: 
$total_results mysql_result(mysql_query("SELECT COUNT(*) as Num FROM tbl_instructores"),0); 

// Figure out the total number of pages. Always round up using ceil() 
$total_pages ceil($total_results $max_results); 

// Build Page Number Hyperlinks 
echo "<center>Select a Page<br />"

// Build Previous Link 
if($page 1){ 
    
$prev = ($page 1); 
    echo 
"<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "


for(
$i 1$i <= $total_pages$i++){ 
    if((
$page) == $i){ 
        echo 
"$i "
        } else { 
            echo 
"<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "
    } 


// Build Next Link 
if($page $total_pages){ 
    
$next = ($page 1); 
    echo 
"<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"

echo 
"</center>"
?> 

Alright, it looks like I have some explaining to do! Let's break the code 

</body>
</html>
  #8 (permalink)  
Antiguo 14/07/2005, 01:09
 
Fecha de Ingreso: junio-2005
Mensajes: 111
Antigüedad: 18 años, 10 meses
Puntos: 0
ya encontre la solucion, muchas gracias por su ayuda ! genial este foro

Código PHP:
<?php require_once('../../Connections/conn_newland.php'); ?>
<?php
mysql_select_db
($database_conn_newland$conn_newland);
$query_rs_countries "SELECT ID, Surname FROM tbl_instructores ORDER BY Surname ASC";
$rs_countries mysql_query($query_rs_countries);
$row_rs_countries mysql_fetch_assoc($rs_countries);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?php 

// Database Connection 
mysql_select_db('newland_tours'mysql_pconnect('localhost','root','root')) or die (mysql_error()); 

// If current page number, use it 
// if not, set one! 

if(!isset($_GET['page'])){ 
    
$page 1
} else { 
    
$page $_GET['page']; 


// Define the number of results per page 
$max_results 10

// Figure out the limit for the query based 
// on the current page number. 
$from = (($page $max_results) - $max_results); 

// Perform MySQL query on only the current page number's results 

$sql mysql_query("SELECT * FROM tbl_instructores LIMIT $from, $max_results"); 

while(
$row_rs_countries mysql_fetch_array($sql)){ 
//do {
    // Build your formatted results here. 
    //echo $row['Surname'] . " ID: " . $row['ID'] . "<br />"; 

echo $row_rs_countries["Surname"]. " ID: " $row_rs_countries['ID'] . ' <a href="instructores_update.php?ID='.$row_rs_countries["ID"].'">Modify this countrys profile</a> '"<br />"
//}    
        //while ($row_rs_countries = mysql_fetch_assoc($rs_countries));
    



// Figure out the total number of results in DB: 
$total_results mysql_result(mysql_query("SELECT COUNT(*) as Num FROM tbl_instructores"),0); 

// Figure out the total number of pages. Always round up using ceil() 
$total_pages ceil($total_results $max_results); 

// Build Page Number Hyperlinks 
echo "<center>Select a Page<br />"

// Build Previous Link 
if($page 1){ 
    
$prev = ($page 1); 
    echo 
"<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "


for(
$i 1$i <= $total_pages$i++){ 
    if((
$page) == $i){ 
        echo 
"$i "
        } else { 
            echo 
"<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "
    } 


// Build Next Link 
if($page $total_pages){ 
    
$next = ($page 1); 
    echo 
"<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"

echo 
"</center>"
?> 

Alright, it looks like I have some explaining to do! Let's break the code 

</body>
</html>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:08.