من کد کامل رو در این جا می گذارم.
شاید در کدهای من اشکالی وجود داشته باشه که من ازش سر در نمیارم.
تعداد فایل های من شامل 3 فایل است.
فایل اول: ارتباط با دیتابیس به نام config.php
<?php
function db_connect()
{
$Msg_Not_Connect = 'ارتباط با بانک اطلاعاتي برقرار نشد.';
$Sql_Hostname = 'localhost';
$DB_Username = 'root';
$DB_Password = '';
$DB_Name = 'books';
$Result = new mysqli($Sql_Hostname, $DB_Username, $DB_Password, $DB_Name);
if (!$Result)
{
throw new Exception($Msg_Not_Connect);
}
else
{
return $Result;
}
}
?>
فایل دوم: توابع مورد نیاز به نام function.php
<?php
require_once('config.php');
//----->
function Main_Page()
{
?>
<form method="POST" action="index.php">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" dir="rtl">
<tr>
<td width="40%" dir="rtl">
<p dir="rtl" align="center">شماره کتاب:
<input type="text" name="txt_book_id" dir="rtl" size="5" /></p>
<p dir="rtl" align="center">
<input type="submit" value="ارسال" name="sub_book_id"></p>
</td>
<td width="73%" dir="rtl">
</td>
</tr>
</table>
</form>
<?php
}
//----->
function Book_Details($Book_ID)
{
$BookName_Array = Get_BookName_From_BooksTable($Book_ID);
$User_ID = $BookName_Array[0]['user_id'];
$FullName_Array = Get_FullName_From_MembersTable($User_ID);
?>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" dir="rtl">
<tr>
<td width="40%" dir="rtl">
<p dir="rtl">نام کتاب: <?php echo $BookName_Array[0]['book_name'];?></p>
</td>
<td width="60%" dir="rtl">
<p dir="rtl">نام تحويل گيرنده: <?php echo $FullName_Array[0]['name_lastname'];?> فرم
<p dir="rtl">تاريخ دريافت کتاب: <?php echo $BookName_Array[0]['receive_date'];?> فرم
</td>
</tr>
</table>
<?php
}
//---->
function Get_BookName_From_BooksTable($Book_ID)
{
$Conn = db_connect();
mysql_query('SET NAMES \'utf8\'');
mysql_set_charset('utf8');
$Query = "select * from books where book_id='$Book_ID'";
$Result = $Conn->query($Query);
if (!$Result)
return false;
if ($Result->num_rows>0)
{
$Num_Results = $Result->num_rows;
for ($i = 0; $i < $Num_Results; $i++)
{
$Temp_Array[$i] = $Result->fetch_assoc();
}
/* $Result->free();
$Conn->close(); */
return $Temp_Array;
}
else
{
/* $Result->free();
$Conn->close(); */
return $Temp_Array;
}
}
//---->
function Get_FullName_From_MembersTable($User_ID)
{
$Conn = db_connect();
mysql_query('SET NAMES \'utf8\'');
mysql_set_charset('utf8');
$Query = "select * from members where member_id='$User_ID'";
$Result = $Conn->query($Query);
if (!$Result)
return false;
if ($Result->num_rows>0)
{
$Num_Results = $Result->num_rows;
for ($i = 0; $i < $Num_Results; $i++)
{
$Temp_Array[$i] = $Result->fetch_assoc();
}
/* $Result->free();
$Conn->close(); */
return $Temp_Array;
}
else
{
/* $Result->free();
$Conn->close(); */
return $Temp_Array;
}
}
?>
فایل سوم: فایل اصلی یا ایندکس اصلی به نام index.php
<html>
<head>
<meta http-equiv="Content-Language" content="fa">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>اطلاعات کتاب</title>
</head>
<body style="font-family: Tahoma; font-size: 10pt">
<?php
require_once('function.php');
$Book_ID = $_POST['txt_book_id'];
if ($Book_ID != '' && $Book_ID > 0)
{
Book_Details($Book_ID);
exit;
}
else
{
Main_Page();
exit;
}
?>
</body>
</html>
امیدوارم کسی بتونه راهنمایی کنه.
با تقدیم احترام
صداقت