Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/02/2009, 05:18
lauchalp95
 
Fecha de Ingreso: julio-2006
Mensajes: 254
Antigüedad: 18 años, 9 meses
Puntos: 0
Como mostrar opciones de un campo

Pues, es que tengo un inventario, y en esa pagina salen los objetos que tienes.
La tabla tiene un campo que dice se_tira, se_da, se_come , se_lee. Si el campo es si, quiero qe haya un limk qe diga, se tira, sino, nda.
pero no me sale..
Solo me salen todos los links pero no los que se pueden hacer con ese objeto
Mi codigo:
Código PHP:
Ver original
  1. <?php
  2. # FileName="Connection_php_mysql.htm"
  3. # Type="MYSQL"
  4. # HTTP="true"
  5. $hostname_Noone = "mXXXXXXXXXXXXm";
  6. $database_Noone = "aXXXXXXXXXXl";
  7. $username_Noone = "XXXXXXXXXXXXXXXl";
  8. $password_Noone = "XXXXXXXXXX";
  9. $Noone = mysql_pconnect($hostname_Noone, $username_Noone, $password_Noone) or trigger_error(mysql_error(),E_USER_ERROR);
  10. ?>
  11. <?php
  12. if (!function_exists("GetSQLValueString")) {
  13. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  14. {
  15.   if (PHP_VERSION < 6) {
  16.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  17.   }
  18.  
  19.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  20.  
  21.   switch ($theType) {
  22.     case "text":
  23.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  24.       break;    
  25.     case "long":
  26.     case "int":
  27.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  28.       break;
  29.     case "double":
  30.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  31.       break;
  32.     case "date":
  33.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  34.       break;
  35.     case "defined":
  36.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  37.       break;
  38.   }
  39.   return $theValue;
  40. }
  41. }
  42.  
  43. $colname_usuarios = "-1";
  44. if (isset($_SESSION['MM_Username'])) {
  45.   $colname_usuarios = $_SESSION['MM_Username'];
  46. }
  47. mysql_select_db($database_Noone, $Noone);
  48. $query_usuarios = sprintf("SELECT id, usuario FROM usuarios WHERE usuario = %s", GetSQLValueString($colname_usuarios, "text"));
  49. $usuarios = mysql_query($query_usuarios, $Noone) or die(mysql_error());
  50. $row_usuarios = mysql_fetch_assoc($usuarios);
  51. $totalRows_usuarios = mysql_num_rows($usuarios);
  52.  
  53. mysql_select_db($database_Noone, $Noone);
  54. $query_objetos = "SELECT * FROM objetos ";
  55. $objetos = mysql_query($query_objetos, $Noone) or die(mysql_error());
  56. $row_objetos = mysql_fetch_assoc($objetos);
  57. $totalRows_objetos = mysql_num_rows($objetos);
  58.  
  59. mysql_select_db($database_Noone, $Noone);
  60. $query_relacion = "SELECT * FROM objetos INNER JOIN inventario ON inventario.id_o = objetos.id WHERE inventario.id_u = $row_usuarios[id]  ORDER BY id_o ASC";
  61. $relacion = mysql_query($query_relacion, $Noone) or die(mysql_error());
  62. $row_relacion = mysql_fetch_assoc($relacion);
  63. $totalRows_relacion = mysql_num_rows($relacion);  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. ?>
  71. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  72. <html xmlns="http://www.w3.org/1999/xhtml">
  73. <head>
  74. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  75. <title>Documento sin t&iacute;tulo</title>
  76. <style type="text/css">
  77. <!--
  78. .contenido {color: #000000}
  79. .important {color: #FF0000}
  80. .Estilo1 {
  81.     font-family: Arial, Helvetica, sans-serif;
  82.     font-weight: bold;
  83. }
  84. .Estilo2 {
  85.     font-family: Arial, Helvetica, sans-serif;
  86.     font-size: 12px;
  87. }
  88. .Estilo3 {font-size: 12px}
  89. -->
  90. </style>
  91. </head>
  92.  
  93. <body>
  94. <div align="left" class="Estilo1 Estilo3">Tu inventario</div>
  95. <p align="center" class="Estilo2">&nbsp;</p>
  96. <p align="center" class="Estilo2">&nbsp;</p>
  97. <table border="1">
  98.   <?php do { ?>
  99.     <tr>
  100.       <td><?php echo "<center>$row_relacion[nombre]</center>"; ?><br /><? echo "<center><img src=$row_relacion[img]></center>"; ?></td>
  101.       <td><? if( $row_relacion['se_subasta'] = si )
  102.       {
  103.           echo " >> Subastar objeto ";
  104.       }
  105.      
  106.    
  107.       if( $row_relacion['se_tira'] = si )
  108.       {
  109.           echo " >> Tirar objeto ";
  110.       }
  111.       if( $row_relacion['se_dona'] = si )
  112.       {
  113.           echo " Donar objeto ";
  114.       }
  115.       if( $row_relacion['se_da_a_otro'] = si )
  116.       {
  117.           echo " Regalar objeto ";
  118.       }
  119.       if( $row_relacion['se_come'] = si )
  120.       {
  121.           echo " Comer alimento ";
  122.       }
  123.       if( $row_relacion['se_lee'] = si )
  124.       {
  125.           echo " Subastar objeto ";
  126.       }
  127.      
  128.      
  129.      
  130.      
  131.      
  132.       ?>&nbsp;</td>
  133.     </tr>
  134.     <?php } while ($row_relacion = mysql_fetch_assoc($relacion)); ?>
  135. </table>
  136. </body>
  137. </html>
  138. <?php
  139. mysql_free_result($usuarios);
  140.  
  141.  
  142. mysql_free_result($relacion);
  143. ?>