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:
Expand|Select|Wrap|Line Numbers
- <table width='550' style="margin-left:8px;" border='0' cellpadding='0' cellspacing='1' bgcolor='#eeeeee' align='left'>
- <tr height="20">
- <td width="10%" class="TableField">Id</td>
- <td width="10%" class="TableField">Field</td>
- <td width="60%" class="TableField">Data type</td>
- <td width="15%" class="TableField">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='#ffffff'>
- <td width="10%" class="TableField"><?php echo $i; ?></td>
- <td width="60%" class="TableField"><input type="text" id="altertable" class="SInputTB" value="<?php echo $row['field']; ?>"></td>
- <td width="60%" class="TableField"><input type="text" id="altertable" class="SInputTB" value="<?php echo $row['type']; ?>"></td>
- <td width="20%"><a href="javascript:save_data(<?php echo $id; ?>)">Alter</a>
- <a href="javascript:requestInfo('<?php echo $modulepath; ?>altertable.php','login','')">Cancel</a></td>
- </tr>
Expand|Select|Wrap|Line Numbers
- <?php
- $altertable = $_GET['altertable'];
- $field = $_GET['field'];
- $mode = $_GET['mode'];
- $db = new Zend_Db_Adapter_Pdo_Mysql(array(
- '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.$templatepath.'altertable.phtml'; ?>