<?php // insert a new record $tpl = new MSDTemplate(); $tpl->set_filenames(array('show' => './tpl/sqlbrowser/sql_record_insert_inputmask.tpl')); $sqledit = "SHOW FIELDS FROM `{$tablename}`"; $res = MSD_query($sqledit); $num = mysql_numrows($res); $feldnamen = ""; for ($x = 0; $x < $num; $x++) { $row = mysql_fetch_object($res); $feldnamen .= $row->Field . '|'; $tpl->assign_block_vars('ROW', array('CLASS' => $x % 2 ? 1 : 2, 'FIELD_NAME' => $row->Field, 'FIELD_ID' => correct_post_index($row->Field))); $type = strtoupper($row->Type); if (strtoupper($row->Null) == 'YES') { //field is nullable $tpl->assign_block_vars('ROW.IS_NULLABLE', array()); } if (in_array($type, array('BLOB', 'TEXT'))) { $tpl->assign_block_vars('ROW.IS_TEXTAREA', array()); } else { $tpl->assign_block_vars('ROW.IS_TEXTINPUT', array()); } } $tpl->assign_vars(array('HIDDEN_FIELDS' => FormHiddenParams(), 'FIELDNAMES' => substr($feldnamen, 0, strlen($feldnamen) - 1), 'SQL_STATEMENT' => my_quotes($sql['sql_statement']))); $tpl->pparse('show');
$tpl = new MSDTemplate(); $tpl->set_filenames(array('show' => './tpl/sqlbrowser/sql_record_update_inputmask.tpl')); $target = $mode == "searchedit" ? '?mode=searchedit' : '?mode=update'; // jump back to search hit list after saving $fields = getExtendedFieldInfo($db, $tablename); $sqledit = "SELECT * FROM `{$tablename}` WHERE " . $recordkey; $res = MSD_query($sqledit); $record = mysqli_fetch_array($res, MYSQLI_ASSOC); // get the record $num = sizeof($record); // get the nr of fields of the record // iterate fields $x = 0; $fieldnames = ''; foreach ($record as $field => $fieldvalue) { $fieldnames .= $field . '|'; $tpl->assign_block_vars('ROW', array('CLASS' => $x % 2 ? 1 : 2, 'FIELD_NAME' => $field, 'FIELD_VALUE' => my_quotes($fieldvalue), 'FIELD_ID' => correct_post_index($field))); if ('YES' == $fields[$field]['null']) { //field is nullable - precheck checkbox if value is null $tpl->assign_block_vars('ROW.IS_NULLABLE', array('NULL_CHECKED' => is_null($fieldvalue) ? ' checked="checked"' : '')); } $type = strtoupper($fields[$field]['type']); if (in_array($type, array('BLOB', 'TEXT'))) { $tpl->assign_block_vars('ROW.IS_TEXTAREA', array()); } else { $tpl->assign_block_vars('ROW.IS_TEXTINPUT', array()); } $x++; } $tpl->assign_vars(array('HIDDEN_FIELDS' => FormHiddenParams(), 'FIELDNAMES' => substr($fieldnames, 0, strlen($fieldnames) - 1), 'SQL_STATEMENT' => my_quotes($sql['sql_statement']), 'RECORDKEY' => my_quotes($recordkey), 'TARGET' => $target)); $tpl->pparse('show');
for ($x = 0; $x < $num; $x++) { $row = mysql_fetch_row($res); $feldnamen .= $row[0] . '|'; $aus .= '<tr><td>' . $row[0] . '</td><td>'; $type = strtoupper($row[1]); if ($type == 'BLOB' || $type == 'TEXT') { $aus .= '<textarea cols="60" rows="4" name="' . $row[0] . '">' . $row[4] . '</textarea>'; } else { $aus .= '<input type="text" class="text" size="60" name="' . $row[0] . '" value="' . $row[4] . '">'; } $aus .= '</td>'; $aus .= '<td> </td></tr>'; //'.$str->type.' } $aus .= '<tr><td colspan="3" align="right"><input type="hidden" name="feldnamen" value="' . substr($feldnamen, 0, strlen($feldnamen) - 1) . '"><input class="SQLbutton" type="submit" name="insert" value="insert"> <input class="SQLbutton" type="reset" name="reset" value="reset"> <input class="SQLbutton" type="submit" name="cancel" value="cancel insert"></td></tr>'; $aus .= '</table>' . FormHiddenParams() . '<input type="hidden" name="sql_statement" value="' . urlencode($sql['sql_statement']) . '"></form></div>'; } } if ($context == 0) { //Data-View echo $aus . '<h4>' . ($showtables == 1 ? $lang['sql_tableview'] : $lang['sql_dataview']) . '</h4><p>'; if ($showtables == 0) { $p = 'sql.php?sql_statement=' . urlencode($sql['sql_statement']) . '&db=' . $db . '&tablename=' . $tablename . '&dbid=' . $dbid . '&limitstart=' . $limitstart . '&order=' . $order . '&orderdir=' . $orderdir . '&tdc=' . $tdcompact; echo '<a href="' . $p . '&mode=new">' . $lang['sql_recordnew'] . '</a> '; echo '<a href="sql.php?db=' . $db . '&dbid=' . $dbid . '&tablename=' . $tablename . '&context=2">Tabellenstruktur bearbeiten</a>'; } else { $p = 'sql.php?db=' . $db . '&dbid=' . $dbid . '&context=2'; echo '<a href="' . $p . '">' . $lang['sql_tablenew'] . '</a>'; } //Statuszeile echo '</p><p> ' . ExtractTablenameFromSQL($sql['sql_statement']) . '</p><p align="left">';