Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    Passare una variabile da form alla funzione "Create Table"

    Buongiorno a tutti e grazie per il vostro aiuto.
    obiettivo: far passare dal form il nome univoco per la tabella che vado a creare in sql

    questo il codice del form:
    Codice PHP:
    <form action="create_table.php" method="post">
    <
    div align="center">

      <
    table width="900" border="0">
        <
    tr>
          <
    th scope="col"><div align="left"></div></th>
        </
    tr>
      </
    table>
    </
    div>
      <
    div align="center">
        <
    table width="902" border="0" background="back_fidelity.png" repeat="norepeat">
            

    </
    p></th>
            <
    th scope="col">

    </
    p>
              

    </
    p>
            

    </
    p></th>
            <
    th scope="col"></th>
            <
    th width="469" rowspan="10" scope="col">

    </
    p>
            

    </
    p></th>
          </
    tr>
          <
    tr>
            <
    th scope="col"></th>
            <
    th scope="col"></th>
            <
    th scope="col"></th>
          </
    tr>
          <
    tr>
            <
    th width="33" height="83" scope="col"></th>
            <
    th width="183" scope="col"><div align="left">[b]Create TB:[/b]</div></th>
            <
    th width="192" scope="col"> <div align="center">
              <
    input type="text" name="CODE" />
            </
    div></th>
          </
    tr>
          <
    tr>
            <
    td height="110"></td>
            <
    td></td>
            <
    td><div align="center">
              


                <
    input type="submit" />
                
            </
    div></td>
          </
    tr>
        </
    table>
      </
    div>
    </
    form
    QUESTO IL FILE PHP X LA CREAZIONE DELLA TABELLA:

    Codice PHP:
    <?php
    $con 
    mysql_connect("localhost","XXXXXXXX","XXXXXXXX");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    // Create table
    mysql_select_db("raffaele_loyalty_card"$con);

    $sql "CREATE TABLE [COLOR=skyblue]QUI DEVO FAR PASSARE IL NOME DELLA TABELLA DAL FORM[/COLOR]  
    FirstName varchar(15),
    LastName varchar(15),
    Age int
    )"
    ;

    // Execute query
    mysql_query($sql,$con);

    mysql_close($con);
    ?>

    COME FACCIO? GRAZIE IN ANTICIPO

    RAFFAELE

  2. #2
    ricavi il nome dal metodo post, lo filtri per evitare problemi di sicurezza, e lo aggiungi alla query. Cosa non sai fare?
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  3. #3
    non conosco quale sia lo script da aggiungere (mi sto approcciando al php, portate pazienza) dove ho messo la scritta in blu (dopo CREATE TABLE) per aggiungere il nome con il metodo post.grazie se mi puoi scrivere il codice

  4. #4
    Una volta filtrato la POST che ti arriva dal form fai cosi:

    Codice PHP:
    $sql "CREATE TABLE ".$_POST["CODE"]." FirstName varchar(15), LastName varchar(15), Age int )"

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.