Re: combobox end print table



On 7 Mar, 16:38, SrSilveira <srsilve...@xxxxxxxxx> wrote:
ok.... but, there is some error message?
you can try echo var_dump($dbhandle) and the select_db var...

On Mar 7, 12:39 pm, lid...@xxxxxxxxx wrote:



On 7 Mar, 14:41, SrSilveira <srsilve...@xxxxxxxxx> wrote:

Hy, try this way...
when the user select on the drop down, the form will submit to the
page...
on the page you just must to set the name
$sql="SELECT * FROM ".$_POST['colori'];

<?php
// your code...
session_start();
set_time_limit(0);
error_reporting(E_ALL);
//complete "stationsqlexpress" with your particular case
$SERVER = "stationsqlexpress";
$ADMIN_NAME = "sa";
//complete pass with your pass
$ADMIN_PASS = "pass";
//complete database witht the name of database you whant to
// connect to
$DATABASE = "database";
$Conexion = mssql_connect($SERVER, $ADMIN_NAME, $ADMIN_PASS)
or die ("Can't connect to Microsoft SQL Server");
mssql_select_db($DATABASE, $Conexion)
or die ("Can't connect to Database");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html;
charset=windows-1250">
  <meta name="generator" content="">
  <title></title>
  </head>
  <body>
<form name="modulo">
<select name="colori" onchange="SelectPost()">
<option value=""></option>
<option value="ROSSO">ROSSO</option>
<option value="GIALLO">GIALLO</option>
<option value="VERDE">VERDE</option>
<option value="BLU">BLU</option>
</select>
</form>

<?

// $_REQUEST because i don't know the method (post or get) I would be
//use method post (what in need to modify?)
// - this way:
$table = $_POST['colori'];
// i think this will print the code...
// i just changed the table name....
$sql="SELECT * FROM ".$table;
$oggetto = $mssql->runquery($sql);  //i need to modify something in
//this line?????
// -you do not must to modify... run the page and see the error
// message
$mssql->closeDb();
print ($oggetto);
?>
 </body>
</html>

Thank you a lot for the Help
Later I will do a test, because i have another problem to resolve
before,
I don't understand why, but i have a problem with the connection to db
mssql

I believe that the code is right but doesn't work (now I try to
understand Why, and after try with the select!

<?php
$myServer = "a";
$myUser = "I";
$myPass = "I";
$myDB = "7";

//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
  or die("Couldn't connect to SQL Server on $myServer");

//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
  or die("Couldn't open database $myDB");
  ?>- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -

I just found a problem with a connections now start with the
test! :-)
.



Relevant Pages