Ver Mensaje Individual
  #9 (permalink)  
Antiguo 28/02/2011, 17:20
nuevoconphp
 
Fecha de Ingreso: febrero-2011
Mensajes: 64
Antigüedad: 13 años, 2 meses
Puntos: 3
Exclamación Respuesta: Crear tabla consulta con php

Cita:
Iniciado por bUllan9ebrio Ver Mensaje
acuerdence q estoy aprendiendo , Ok pero tienes algo avanzado el codigo?? para verlo e ir ayudandote
ok, este es el codigo y la forma para hacer una nueva tabla, como veran parte esta echo con dreamweaver pues me ayuda mucho ya q no soy un experto en el tema de php

Código:
<?php require_once('coneccion'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO `albun de fotos` (albuns) VALUES (%s)",
                       GetSQLValueString($_POST['albuns'], "text"));
					   
					  
  mysql_select_db($database_IBC, $IBC);
  $Result1 = mysql_query($insertSQL, $IBC) or die(mysql_error());
  
   //crear nueva tabla cogiendo nombre de textfield//
 mysql_select_db("ibc") or die(mysql_error()); 
 mysql_query("CREATE TABLE `".$_POST['albuns']."` ( id_albun INT(11), nombre_albun TEXT )"); 
 Print "Your table has been created";

  $insertGoTo = "hacer_albun.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
  
 
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  <table align="center">
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Albuns:</td>
      <td><input type="text" name="albuns" value="" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">&nbsp;</td>
      <td><input type="submit" value="Insert record" /></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
</body>
</html>

despues que creo cada tabla que seria un albun nuevo con un campo en cada tabla donde guardaria la direccion de las fotos de cada albun quiero hacer consultas de cada tabla creada de tal forma que pueda visulisarlas de tal forma:

Código:
<ul id="fp_galleryList" class="fp_galleryList">
    <li>"nombre de tabla creada1"</li>
    <li>"nombre de tabla creada2"</li>
    <li>"nombre de tabla creada3"</li>
    <li>"nombre de tabla creada4"</li>
</ul>

 <div class="content">
                <div>
                    <a href="#">
                        cada uno de los campos de la tabla creada1
                    </a>
                </div>
            </div>

<div class="content">
                <div>
                    <a href="#">
                        cada uno de los campos de la tabla creada2
                    </a>
                </div>
            </div>

<div class="content">
                <div>
                    <a href="#">
                        cada uno de los campos de la tabla creada3
                    </a>
                </div>
            </div>

<div class="content">
                <div>
                    <a href="#">
                        cada uno de los campos de la tabla creada4
                    </a>
                </div>
            </div>
espero me explique mas, cualquier cosa me dicen y explico enseguida, gracias