Login   Register  
PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Felippe Piazza  >  Query 2 Array  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: HTML Example
Class: Query 2 Array
Extract MySQL query results into arrays
Author: By
Last change:
Date: 2005-08-16 07:00
Size: 1,294 bytes
 

Contents

Class file image Download
<head>
</head>

<body>
<?php
require("sql_class.inc");

$database $_POST["database"];
$query $_POST["query"];
$server $_POST["server"];
$user $_POST["user"];
$pass $_POST["pass"];

?>


<form action="index.php" method="post">
Server: <input type="text" value="<?php print $server;?>" name="server"><br>
User: <input type="text" value="<?php print $user;?>" name="user"><br>
Pass: <input type="password" value="<?php print $pass;?>" name="pass"><br>

Database: <input type="text" value="<?php print $database;?>" name="database"><br>

Query: <textarea name="query" cols=50 rows=10><?php print $query?></textarea><br>

<input type="submit" value="Gerar Query">
</form>






<?

if ($server != "" && $user != "" && $pass != "" && $query != "" && $database != "")
{

    
$table = new sql_query;

    
$table->set_vars("$server","$user","$pass","$database");

    
$table->query("$query");

    
$table->tableindex();
    
$table->tablemount();

    print 
"<table border=1><tr>\n";


    foreach (
$table->columns as $coluna)
    {
        print 
"<td><b>$coluna</b></td>";
    }
    
    print 
"</tr>";


    foreach (
$table->result as $row
    {
        print 
"<tr>\n";
        foreach(
$table->columns as $column
        {
            
$field_result $row->$column;
            print 
"<td>$field_result &nbsp</td>";
        }
        print 
"</tr>\n";
    }
    print 
"</table>" ;
}
?>