2011-06-02 54 views
0

我有一個表單,我從$ GET中獲取上一頁中的值。我想從數據庫中取出3個不同的值並將它們顯示在文本框中。我將如何做到這一點?以下是我從數據庫獲取數據的代碼。如何在php中的數據庫中寫入文本中的文本

<?php 
require_once('config.php'); 
$id = $_GET['id']; 
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); 
if(!$link) { 
     die('Failed to connect to server: ' . mysql_error()); 
} 

//Select database 
$db = mysql_select_db(DB_DATABASE); 
if(!$db) { 
     die("Unable to select database"); 
} 
$query = "select question,price,sequence from questions where status = 1 and qid =".$id; 
//echo $query; 
$result=mysql_query($query); 
if (!$result) { 
    die('Invalid query: ' . mysql_error()); 
} 
$num_rows = mysql_num_rows($result); 
if($num_rows==0) { 
echo '<center><font color="red"><b>No record found!!</b></font></center>'; 
} 
else { 
$row = mysql_fetch_array($result); 
echo $row['question']; 
echo $row['sequence']; 
echo $row['price']; 
} 

?>

感謝
潘卡

+0

* textbox *與每個值的'