Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- echo '<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">';
- // The column names need to be renamed to their proper names
- $table="col2desc";
- // Read the mapping table
- $query = "select fieldname,realfieldname from $table";
- // query
- $result=mysql_query($query);
- // push all the data into an array
- while ( $row = mysql_fetch_assoc($result) )
- {
- $name = $row['fieldname'];
- $desc = $row['realfieldname'];
- $mapping["$name"] = $desc;
- }
- echo '
- <thead>
- <tr>
- ';
- $table = "books";
- $query = "show columns from $table";
- $result = mysql_query($query);
- while ( $row = mysql_fetch_assoc($result) )
- {
- $fieldname = $row['Field'];
- if ( $fieldname == 'id' ) continue;
- # and map the field name to the description
- if (array_key_exists("$fieldname", $mapping))
- {
- $desc = $mapping["$fieldname"];
- }
- else
- {
- $desc = $fieldname;
- }
- echo "<th>$desc</th>";
- }
- echo '
- </tr>
- </thead>
- <tbody>
- ';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement