show table using select statements

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bimeldip
    New Member
    • Aug 2007
    • 27

    show table using select statements

    Hi,
    I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be able to change field name or data type of field
    But the problem that i'm facing currently is that i am unable to display the list of fields on the html page.
    i'm guessing its because i'm using "show fields from [tablename]" unlike the other page where i used standard select statements.

    So the way i see it...is that i either find a way to display the fields of a table using select statement?
    OR
    i learn a way to manipulate the show statement making sure the list of fields are displayed.
    So far at the phtml page is as below:

    Code: ( html4strict )
    [HTML]<table width='550' style="margin-left:8px;" border='0' cellpadding='0' cellspacing='1' bgcolor='#eeeee e' align='left'>
    <tr height="20">
    <td width="10%" class="TableFie ld">Id</td>
    <td width="10%" class="TableFie ld">Field</td>
    <td width="60%" class="TableFie ld">Data type</td>
    <td width="15%" class="TableFie ld">Action</td>
    </tr>
    <?php
    while ($row = $stmt->fetch()) {
    $id = $row['id'];
    $field_ = $row['field'];
    $type = $row['type'];
    $i = $i + 1;
    ?>
    <?php
    if ($mode == "edit")
    {
    if($id_==$id)
    {
    ?>
    <tr bgcolor='#fffff f'>
    <td width="10%" class="TableFie ld"><?php echo $i; ?></td>
    <td width="60%" class="TableFie ld"><input type="text" id="altertable " class="SInputTB " value="<?php echo $row['field']; ?>"></td>
    <td width="60%" class="TableFie ld"><input type="text" id="altertable " class="SInputTB " value="<?php echo $row['type']; ?>"></td>
    <td width="20%"><a href="javascrip t:save_data(<?p hp echo $id; ?>)">Alter</a>&nbsp;
    <a href="javascrip t:requestInfo(' <?php echo $modulepath; ?>altertable.ph p','login','')" >Cancel</a></td>
    </tr>[/HTML]


    and the php page is as below:

    [PHP]Code: ( php )
    <?php
    $altertable = $_GET['altertable'];
    $field = $_GET['field'];
    $mode = $_GET['mode'];

    $db = new Zend_Db_Adapter _Pdo_Mysql(arra y(
    'username' => 'root',
    'host' => $host,
    'password' => '',
    'dbname' => 'test'
    ));

    if ($mode == "save")
    {
    $data = array(
    'field' => $member


    );
    $n = $db->alter('member' , $data, 'field = "'.$field.' "');
    }

    if ($mode == "delete")
    {
    $n = $db->delete('member ', 'field = "'.$field.' "');
    }

    if ($mode == "add")
    {
    $data = array(
    'field' => $member

    );

    $s=$db->alter('member' , $data, 'field = "'.$field.' "');
    }
    $stmt = $db->query('show fields from member');
    ?>
    <?php require $root.$template path.'altertabl e.phtml'; ?>[/PHP]
Working...