Categories > TinyButStrong general >

As it would be the code below using tinybutstrong

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Romulo
Date: 2005-11-11
Time: 21:46

As it would be the code below using tinybutstrong

<?

$db = mysql_connect("localhost","user","password") or die(mysql_error() );
      mysql_select_db("table",$db);
     
$ret = mysql_query("show tables");

while ($row = mysql_fetch_row($ret))
{
  echo "Tabela: <b>{$row[0]}</b><br>";
  $ret1 = mysql_query("show fields from `{$row[0]}`");

  while ($row1 = mysql_fetch_array($ret1))
   {
    echo "<b>{$row1["Field"]}</b> - {$row1["Type"]}<br>";
   }
  
  echo "<br>";
}
By: Skrol29
Date: 2005-11-13
Time: 23:05

Re: As it would be the code below using tinybutstrong

Hello,

You can do it using blocks and subblocks.
The problem is that the "show tables" command returns a single columns with a variable name.
You can workaround the problem by preparing the column name before the main block merge.

PHP:
// Tric to merge simple fields using a SQL statement
$TBS->MergeBlock('db',$db,'SELECT DATABASE() AS dbname');

// Merge main block
$TBS->MergeBlock('tbl',$db;'SHOW TABLES');

// Merge subblocks
$TBS->MergeBlock('fld',$db;'SHOW COLUMNS IN %p1%');

HTML:
[tbl;block=begin]
  Table: <b>[tbl.Tables_in_[db.dbname]]</b> <br>
  [fld;block=begin;p1='[tbl.Tables_in_[db.dbname]]';]
    <b>[fld.Field]</b> - [fld.Type]<br>
  [fld;block=end]
  <br>
[tbl.block=end]
By: Romulo
Date: 2005-11-14
Time: 20:35

Re: As it would be the code below using tinybutstrong

I couldnĀ“t make it work using this code.
Please help.
By: Romulo
Date: 2005-11-14
Time: 20:42

error

Parse error: parse error in c:\inetpub\wwwroot\sistema\campos.php on line 15
By: Pirjo Posio
Date: 2005-11-15
Time: 02:28

Re: error

If the line 15 in your php-file is like this
echo "<b>{$row1["Field"]}</b> - {$row1["Type"]}<br>";

change the ...["Field"]... into ...['Field']... and ...["Type"]... into ['Type']...
That should help.