<script type="text/javascript" src="prototype.js"></script>
<script>
function reload(form){
var val = $("seltab");alert(val);
}</script>
echo "<form method = post name = f1 action = '' >";
echo "<select id = seltab onchange = 'reload(this.form)'>";
$querysel = "SELECT title_id,author FROM authors NATURAL JOIN books";
$result1 = mysql_query($querysel) ;
while($rowID = mysql_fetch_assoc($result1))
{
$TitleID = $rowID['title_id'];
$author = $rowID['author'];
print "<option value =$TitleID>$author\n";
print "</option>";
}
print "</select>";
Run Code Online (Sandbox Code Playgroud) 这是user.php:
include("databse.php");//retrieving successfully first name and lastname from databse file into user.php
class user
{
public $first_name;
public $last_name;
public static function full_name()
{
if(isset($this->first_name) && isset($this->last_name))
{
return $this->first_name . " " . $this->last_name;
}
else
{
return "";
}
}
}
Run Code Online (Sandbox Code Playgroud)
其他php文件,index.php:
include(databse.php);
include(user.php);
$record = user::find_by_id(1);
$object = new user();
$object->id = $record['id'];
$object->username = $record['username'];
$object->password = $record['password'];
$object->first_name = $record['first_name'];
$object->last_name = $record['last_name'];
// echo $object->full_name();
echo $object->id;// successfully print the id
echo $object->username;//success fully …Run Code Online (Sandbox Code Playgroud)