Creating Table in Mysqldatabase Using PHP coding

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shalini Bhalla
    New Member
    • Dec 2007
    • 190

    #1

    Creating Table in Mysqldatabase Using PHP coding

    I am trying to create a table in mysql using php , but the problem is that no. of fields and their datatype is taken from user in input form in am array .so , i want to know that how should i create a table , how should i specify feild names and datatype in string .Pls Help .....
  • VinniemacND
    New Member
    • Mar 2008
    • 13

    #2
    Originally posted by Shalini Bhalla
    I am trying to create a table in mysql using php , but the problem is that no. of fields and their datatype is taken from user in input form in am array .so , i want to know that how should i create a table , how should i specify feild names and datatype in string .Pls Help .....
    Is the user just selecting a single datatype for all fields?

    Also, a little more background info could help. How will the table be used? Are there any fields that need to be added in addition to those chosen by the user, like a uid column?

    Comment

    • TheServant
      Recognized Expert Top Contributor
      • Feb 2008
      • 1168

      #3
      Originally posted by Shalini Bhalla
      I am trying to create a table in mysql using php , but the problem is that no. of fields and their datatype is taken from user in input form in am array .so , i want to know that how should i create a table , how should i specify feild names and datatype in string .Pls Help .....
      Please post you code that you have, it wastes time trying to guess how you have written the code.

      Comment

      • Shalini Bhalla
        New Member
        • Dec 2007
        • 190

        #4
        <form method="GET" action="createt able.php">
        <?
        $i = 0 ;
        for ($i = 0; $i<=$no ; $i++)
        { ?>
        <table width="456">
        <tr>
        <td>Name:</td>
        <td><input type='text' name='Fname[$i]'> <input type='hidden' name='tname' value="$tname" ></td>
        <td>Data Type :</td>
        <td><input type='text' name='Dtype[$i]' /></td>
        </td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td colspan="3">&nb sp;</td>
        </td>
        </tr>
        <?
        }

        ?>
        <tr>
        <td colspan="4"><in put type='submit' name=Submit></td>
        </td>
        </tr>
        </table>

        </form>

        This is my Form which takes input of no of columns and data type from user and after that i want to create a table in my database , yes i do need to give choice of primary key .

        Comment

        • yasmine
          New Member
          • Feb 2008
          • 64

          #5
          Please Post ur code within code tags.

          Read POSTING GUIDELINES before u r posting threads.

          Comment

          • Shalini Bhalla
            New Member
            • Dec 2007
            • 190

            #6
            [HTML]
            <form method="GET" action="createt able.php">
            <?
            $i = 0 ;
            for ($i = 0; $i<=$no ; $i++)
            { ?>
            <table width="456">
            <tr>
            <td>Name:</td>
            <td><input type='text' name='Fname[$i]'> <input type='hidden' name='tname' value="$tname" ></td>
            <td>Data Type :</td>
            <td><input type='text' name='Dtype[$i]' /></td>
            </td>
            </tr>
            <tr>
            <td>&nbsp;</td>
            <td colspan="3">&nb sp;</td>
            </td>
            </tr>
            <?
            }

            ?>
            <tr>
            <td colspan="4"><in put type='submit' name=Submit></td>
            </td>
            </tr>
            </table>

            </form>







            [/HTML]




            This is my Form which takes input of no of columns and data type from user and after that i want to create a table in my database , yes i do need to give choice of primary key .

            Comment

            Working...