Arabian coder
أيلول 09, 2010, 01:58:13 *
أهلا, زائر. الرجاء الدخول أو التسجيل
هل فقدت بريد التنشيط؟

تسجيل الدخول باسم المستخدم، كلمة المرور و مدة الجلسة
أخبار: SMF - Just Installed!
 
   بداية   تعليمات بحث دخول تسجيل  
صفحات: 1 [2]
  طباعة  
الكاتب موضوع: نظام محاسبي  (شوهد 2120 مرات)
saed
شبـة عضــو

رسائل: 10


مشاهدة الملف الشخصى البريد
« رد #15 في: أيار 23, 2009, 02:07:36 »

هذه دالة الفنكشن الذي يعرض المعلومات الموجودة بقاعدة البيانات علي شكل جدول يضهر للمستخدم ولكن يوجد  بهذه الدالة عدة اخطاء ونعرضها هنا للنقاش
شفرة: (php)
function show_table($tableName)
{ // function to show the database table
     $con=db_connect();
     $result= mysql_query("SELECT * FROM $tableName",$con);
echo"<table border='3'>
<tr>
<th>Acc_Id</th>
<th>Acc_Title</th>
<th>Acc_Type</th>
<th>Acc_Categorey</th>
<th>Acc_Environment</th>
<th>Acc_Parent</th>
<th>Acc_Comment</th>
<th>Balance_Debit</th>
<th>Balance_Credit</th>
<th>&nbsp;</th>
</tr>";
$i=1;
while($row = mysql_fetch_array($result))
  {
  if($i%2==0)
  echo '<tr class="even">';
  else
  echo '<tr class="odd">';
  echo "<td>" . $row['Account_Id'] . "</td>";
  echo "<td>" . $row['Account_Title'] . "</td>";
  echo "<td>" . $row['Account_Type'] . "</td>";
  echo "<td>" . $row['Account_Categorey'] . "</td>";
  echo "<td>" . $row['Account_Environment'] . "</td>";
  echo "<td>" . $row['Account_Parent'] . "</td>";
  echo "<td>" . $row['Account_Comment'] . "</td>";
  echo "<td>" . $row['Balance_Debit'] . "</td>";
  echo "<td>" . $row['Balance_Credit'] . "</td>";
  echo '<td><a href="?action=update_record&account_id='. $row['Account_Id'] .'">Edit</a>&nbsp;';
  echo '<a href="?action=delete_record&account_id='. $row['Account_Id'] .'">Delete</a></td>';
  echo "</tr>";
  $i++;
  }
echo '</table>';
echo'<a href="?action=order_record">Order Record</a>&nbsp;';
echo'<a href="?action=find_record">Find Record</a>';
mysql_close($con);
} [flash=200,200][size=14pt][size=14pt][/size][/size][/flash]
سجل
الفـ العربي ـارس
Global Moderator
عضــو نشيط
*****
رسائل: 153


مشاهدة الملف الشخصى
« رد #16 في: أيار 23, 2009, 02:51:35 »

هذه دالة الفنكشن الذي يعرض المعلومات الموجودة بقاعدة البيانات علي شكل جدول يضهر للمستخدم ولكن يوجد  بهذه الدالة عدة اخطاء ونعرضها هنا للنقاش
شفرة: (php)
function show_table($tableName)
{ // function to show the database table
     $con=db_connect();
     $result= mysql_query("SELECT * FROM $tableName",$con);
echo"<table border='3'>
<tr>
<th>Acc_Id</th>
<th>Acc_Title</th>
<th>Acc_Type</th>
<th>Acc_Categorey</th>
<th>Acc_Environment</th>
<th>Acc_Parent</th>
<th>Acc_Comment</th>
<th>Balance_Debit</th>
<th>Balance_Credit</th>
<th>&nbsp;</th>
</tr>";

لم لا نستخرج اسماء الحقول من قاعدة البيانات نفسها ؟؟
شفرة: (php)
$fields_count = mysql_num_fields($result); // getting field's count
$result_html = '<table> <tr>';
for($i = 0; $i < $fields_count; $i++) {
   $result_html .= '<td>' . mysql_field_name($result, $i) . '</td>';
}
$result_html . = '</tr> </table>';
الكود السابق يستخرج من الجدول اسماء الحقول ويضعها في متغير اسمه $result_html

شفرة: (php)
$i=1;
while($row = mysql_fetch_array($result))
  {
  if($i%2==0)
  echo '<tr class="even">';
  else
  echo '<tr class="odd">';
  echo "<td>" . $row['Account_Id'] . "</td>";
  echo "<td>" . $row['Account_Title'] . "</td>";
  echo "<td>" . $row['Account_Type'] . "</td>";
  echo "<td>" . $row['Account_Categorey'] . "</td>";
  echo "<td>" . $row['Account_Environment'] . "</td>";
  echo "<td>" . $row['Account_Parent'] . "</td>";
  echo "<td>" . $row['Account_Comment'] . "</td>";
  echo "<td>" . $row['Balance_Debit'] . "</td>";
  echo "<td>" . $row['Balance_Credit'] . "</td>";
  echo '<td><a href="?action=update_record&account_id='. $row['Account_Id'] .'">Edit</a>&nbsp;';
  echo '<a href="?action=delete_record&account_id='. $row['Account_Id'] .'">Delete</a></td>';
  echo "</tr>";
  $i++;
  }
echo '</table>';


نستطيع وبنفس الطريقة السابقة ان نضع الكود عوضاً عن اسماء الحقول .. تذكر بأنك تستطيع استخدام رقم المفتاح او مسماه .. بمعنى اخر
شفرة: (php)
$row['account_id'] = $row[0] !!

شفرة: (php)
echo'<a href="?action=order_record">Order Record</a>&nbsp;';
echo'<a href="?action=find_record">Find Record</a>';
mysql_close($con);
}


اتمنى ان تكون الأجابة مفيدة!
سجل
saed
شبـة عضــو

رسائل: 10


مشاهدة الملف الشخصى البريد
« رد #17 في: أيار 24, 2009, 09:05:13 »

شكرا على هذه الاجابه المفيدة حيث اصبح الكود صحيحا كما يلي
شفرة: (php)
function show_table($tableName)
{ // function to show the database table
     $con=db_connect();
     $result= mysql_query("SELECT * FROM $tableName",$con);
$fields_count = mysql_num_fields($result); // getting field's count
$result_html = '<table> <tr>';
for($i = 0; $i < $fields_count-1; $i++)
{   
$result_html .= '<td>' . mysql_field_name($result, $i) . '</td>';}
$result_html .= '</tr>';

$s=1;
while($row = mysql_fetch_array($result))
{  if($s%2==0)
 $result_html .= '<tr class="even">';
  else  $result_html .=  '<tr class="odd">';
 $result_html .= '<td>' . $row['Account_Id'] . '</td>';
 $result_html .= '<td>' . $row['Account_Title'] . '</td>';
 $result_html .= '<td>'. $row['Account_Type'] . '</td>';
 $result_html .= '<td>'. $row['Account_Categorey'] . '</td>';
 $result_html .= '<td>' . $row['Account_Environment'] . '</td>';
 $result_html .= '<td>'. $row['Account_Parent'] . '</td>'; 
 $result_html .= '<td>' . $row['Account_Comment'] . '</td>'; 
 $result_html .= '<td>' . $row['Balance_Debit'] . '</td>';
 $result_html .= '<td>' . $row['Balance_Credit'] . '</td>';
 $result_html .= '<td><a href="?action=update_record&account_id='. $row['Account_Id'] .'">Edit</a>&nbsp;'; 
$result_html .= '<a href="?action=delete_record&account_id='. $row['Account_Id'] .'">Delete</a></td>';
 $result_html .= '</tr>';
   $s++;  }
    $result_html .=  '</table>';
 $result_html .= '<a href="?action=order_record">Order Record</a>&nbsp;';
 $result_html .= '<a href="?action=find_record">Find Record</a>';
mysql_close($con);
return  $result_html;
}
سجل
saed
شبـة عضــو

رسائل: 10


مشاهدة الملف الشخصى البريد
« رد #18 في: أيار 24, 2009, 09:15:49 »

بالنسبة لاظهار المعلومات بداخل الفورم الذي يقوم بعملية التعديل بجدول قاعدة البيانات . هذة دالة الفورم الذي يظهر للمستخدم عندما يضغط على تعدبل بالجدول الذي يظهر للمستخدم المعلومات الموجودة بقاعدة البيانات وبهذا الفورم نريد ان يحتوي على المعلومات المراد تعديلها
شفرة: (php)
function account_update_record()
 {
   return '<form name="form_update_record" id="form_update_record_id" method="post" action="">
  <fieldset>
   <ul>
   <li>
   <dl>
    <dd><label for="Account_Id">Account_Id:</label></dd>
<dd><input type="text" name="Account_Id" id="Account_Id_id" /></dd>
    </dl>
<dl>
    <dd><label for="Account_Title">Account_Title:</label></dd>
    <dd><input type="text" name="Account_Title" id="Account_Title_id" /></dd>
    </dl>
<dl>
    <dd><label for="Account_Type">Account_Type:</label></dd>
    <dd><select name="Account_Type" id="Account_Type_id"></dd>
    <dd><option value="primary">primary</option></dd>
<dd><option value="subsidiary">subsidiary</option></dd>
<dd></select></dd>
</dl>
<dl>
<dd><label for="Account_Categorey">Account_Categorey:</label></dd>
    <dd><select name="Account_Categorey" id="Account_Categorey_id"></dd>
    <dd><option value="balance">balance</option></dd>
<dd><option value="profit & loss">profit & loss</option></dd>
<dd></select></dd>
</dl>
<dl>
<dd><label for="Account_Environment">Account_Environment:</label></dd>
    <dd><select name="Account_Environment" id="Account_Environment_id"></dd>
    <dd><option value="debit">debit</option></dd>
<dd><option value="credit">credit</option></dd>
<dd></select></dd>
</dl>
<dl>
<dd><label for="Account_Parent">Account_Parent:</label></dd>
    <dd><input type="text" name="Account_Parent" id="Account_Parent_id" /></dd>
</dl>
<dl>
<dd><label for="Account_Comment">Account_Comment:</label></dd>
    <dd><textarea cols="20" rows="5" name="Account_Comment" id="Account_Comment_id" ></textarea></dd>
</dl>
<dl>
<dd><label for="Balance_Debit">Balance_Debit:</label></dd>
    <dd><input type="text" name="Balance_Debit" id="Balance_Debit_id" /></dd>
</dl>
<dl>
<dd><label for="Balance_Credit">Balance_Credit:</label></dd>
    <dd><input type="text" name="Balance_Credit" id="Balance_Credit_id" /></dd>
    </dl>
</li>
</ul>
  </fieldset>
  <input type="submit" name="update_record" value="SAVE" id="update_record_id" />
  <input type="hidden" name="update_record_account" id="update_record_account_id" value="updated" />
  <input type="hidden" name="Account_code" id="Account_code_id" value="' . $_GET['account_id'].'"/>
  </form>';
  }
سجل
saed
شبـة عضــو

رسائل: 10


مشاهدة الملف الشخصى البريد
« رد #19 في: أيار 24, 2009, 10:12:17 »

اقترح ان نرسل المعلومات مع الفورم عن طريق اظهارها امام اسم كل فيلد وليد بداخل المنطقه اللتي نكتب بداخلها قيمه الفيلد لانه عندما نعطي value للفيلد هكذا مثلا <input type="text" name="Account_Title" id="Account_Title_id" value="'.$value[1].'"/> بذلك سوف يرسل الفورم هذه القيمة ولا يقوم بعملية التعديل. ويمكن مشاهدة الفورم على الموقع عقدة لتضح العملية. وهذا الكود التالي
شفرة: (php)
function account_update_record()
 {
    $con=db_connect();
  $result = mysql_query("SELECT * FROM char_of_account WHERE Account_Id='". $_GET['account_id'] ."'",$con);
 
$s=1;
while($row = mysql_fetch_array($result))

 $value[0]=$row['Account_Id'];
 $value[1]=$row['Account_Title'] ;
 $value[2]=$row['Account_Type'] ;
 $value[3]=$row['Account_Categorey'] ;
 $value[4]=$row['Account_Environment'] ;
 $value[5]=$row['Account_Parent'] ; 
 $value[6]=$row['Account_Comment'] ; 
 $value[7]=$row['Balance_Debit'] ;
 $value[8]=$row['Balance_Credit'] ;}
  mysql_close($con);
    return '<form name="form_update_record" id="form_update_record_id" method="post" action="">
  <fieldset>
   <ul>
   <li>
   <dl>
    <dd><label for="Account_Id">Account_Id:</label></dd>
<dd><input type="text" name="Account_Id" id="Account_Id_id" value="' . $_GET['account_id'].'"/></dd>
    </dl>
<dl>
    <dd><label for="Account_Title">Account_Title:"'.$value[1].'"</label></dd>
    <dd><input type="text" name="Account_Title" id="Account_Title_id"/></dd>
    </dl>
<dl>
    <dd><label for="Account_Type">Account_Type:"'.$value[2].'"</label></dd>
    <dd><select name="Account_Type" id="Account_Type_id" ></dd>
    <dd><option value="primary">primary</option></dd>
<dd><option value="subsidiary">subsidiary</option></dd>
<dd></select></dd>
</dl>
<dl>
<dd><label for="Account_Categorey">Account_Categorey:"'.$value[3].'"</label></dd>
    <dd><select name="Account_Categorey" id="Account_Categorey_id"></dd>
    <dd><option value="balance">balance</option></dd>
<dd><option value="profit & loss">profit & loss</option></dd>
<dd></select></dd>
</dl>
<dl>
<dd><label for="Account_Environment">Account_Environment:"'.$value[4].'"</label></dd>
    <dd><select name="Account_Environment" id="Account_Environment_id"></dd>
    <dd><option value="debit">debit</option></dd>
<dd><option value="credit">credit</option></dd>
<dd></select></dd>
</dl>
<dl>
<dd><label for="Account_Parent">Account_Parent:"'.$value[5].'"</label></dd>
    <dd><input type="text" name="Account_Parent" id="Account_Parent_id" /></dd>
</dl>
<dl>
<dd><label for="Account_Comment">Account_Comment:"'.$value[6].'"</label></dd><br/>
    <dd><textarea cols="20" rows="5" name="Account_Comment" id="Account_Comment_id" ></textarea></dd>
</dl>
<dl>
<dd><label for="Balance_Debit">Balance_Debit:"'.$value[7].'"</label></dd>
    <dd><input type="text" name="Balance_Debit" id="Balance_Debit_id" /></dd>
</dl>
<dl>
<dd><label for="Balance_Credit">Balance_Credit:"'.$value[8].'"</label></dd>
    <dd><input type="text" name="Balance_Credit" id="Balance_Credit_id" /></dd>
    </dl>
</li>
</ul>
  </fieldset>
  <input type="submit" name="update_record" value="SAVE" id="update_record_id" />
  <input type="hidden" name="update_record_account" id="update_record_account_id" value="updated" />
  <input type="hidden" name="Account_code" id="Account_code_id" value="' . $_GET['account_id'].'"/>
  </form>';
  }
سجل
renan
مستكشــف

رسائل: 3


مشاهدة الملف الشخصى
« رد #20 في: أيار 25, 2009, 05:48:00 »

السلام عليكم ورحمة الله وبركاته
الداتا بيس للسندات القيد
شفرة: (sql)
CREATE TABLE `bond` (
  `id_bond` int(11) unsigned NOT NULL auto_increment,
  `from_Account` int(11) unsigned default NULL COMMENT 'fk Account_id',
  `to_Account` int(11) unsigned default NULL COMMENT 'fk Account_id',
  `type_bond` varbinary(30) default NULL,
  `amount` decimal(10,2) unsigned default '0.00',
  `flag` int(11) unsigned default '0',
  PRIMARY KEY  (`id_bond`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
« آخر تحرير: أيار 25, 2009, 11:07:22 بواسطة renan » سجل
renan
مستكشــف

رسائل: 3


مشاهدة الملف الشخصى
« رد #21 في: أيار 25, 2009, 08:55:35 »

form of bond

شفرة: (sql)
<?php
function bond_create_form()
 {
   return 
'
<form name="form_create_bond" id="form_create_bond_id" method="post" action="">
  <fieldset>
   <legend>Insert_record</legend>
   <ul>
   <li>
   <dl>
    <dd><label for="id_bond">id_bond:</label></dd>
    <dd><input type="text" name="id_bond" id="id_bond_id" /></dd>
    </dl>
<dl>
    <dd><label for="from_Account">from_Account:</label></dd>
    <dd><input type="text" name="from_Account" id="from_Account_id" /></dd>
    </dl>
<dl>
    <dd><label for="to_Account">to_Account:</label></dd>
    <dd><select name="to_Account" id="to_Account_id" /></dd>
    
</dl>
<dl>
<dd><label for="type_bond">type_bond:</label></dd>
    <dd><select name="type_bond" id="type_bond_id" /></dd>
    
    </dl>
<dl>
<dd><label for="amount">amount:</label></dd>
    <dd><select name="amount" id="amount /"></dd>
    </dl>



</li>
</ul>
  </fieldset>
  <input type="submit" name="insert_record" value="Insert" id="insert_record_id" />
  <input type="reset" name="Reset" id="Reset_id"/>
  <input type="hidden" name="submit_create_bond" id="submit_create_id_bond" value="submited" />
  </form>'
;
  }
  
 function 
bond_update_record()
 {
   return 
'<form name="form_update_record" id="form_update_record_id" method="post" action="">
  <fieldset>
   <ul>
   <li>
   <dl>
    <dd><label for="id_bond">id_bond:</label></dd>
<dd><input type="text" name="id_bond" id="id_bond_id" /></dd>
    </dl>
<dl>
    <dd><label for="to_Accoun">to_Accoun:</label></dd>
    <dd><input type="text" name="to_Accoun" id="to_Accoun_id" /></dd>
    </dl>
<dl>
    <dd><label for="from_Account">from_Account:</label></dd>
    <dd><select name="from_Account" id="from_Account_id /"></dd>
    
 </dl>
<dl>
<dd><label for="type_bond">type_bond:</label></dd>
    <dd><select name="type_bond" id="type_bond_id" /></dd>
    
</dl>
<dl>
<dd><label for="amount">amount:</label></dd>
    <dd><select name="amount" id="amount_id"></dd>
    
</dl>
</li>
</ul>
  </fieldset>
  <input type="submit" name="update_record" value="SAVE" id="update_record_id" />
  <input type="hidden" name="update_record_bond" id="update_record_bond_id" value="updated" />
  <input type="hidden" name="bond_code" id="bond_code_id" value="' 
$_GET['id_bond'].'"/>
  </form>'
;
  }


  
   function 
bond_find_record()
  {
  return 
' <h2>HELP:</h2>SELECT THE FIELD NAME AND ITS VALUE TO SHOW THE ALL RECORD IN ITS ROW.
<form name="form_find_record" id="form_find_record_id" method="post" action="">
  <fieldset>
   <legend>Find_Record</legend>
   <ul>
   <li>
   <dl>
    <dd><label for="id_bond">id_bond:</label></dd>
<dd><input type="text" name="id_bond" id="id_bond_id" /></dd>
    </dl>
</li>
</ul>
</fieldset>
  <input type="submit" name="find_record" value="Find" id="find_record_id" />
  <input type="hidden" name="find_record_bond" id="find_record_bond_id" value="finded" />
  
  </form>'
;
  }
  
  function 
bond_order_record()
  {
  return 
' <form name="form_order_record" id="form_order_record_id" method="post" action="">
  
   <ul>
   <li>
   <dl>
   <dd>SELECT FIELD TO ORDER:</dd>
    <dd><select name="Table_Field" id="Table_Field_id"></dd>
<dd><option value="id_bond">id_bond</option></dd>
<dd><option value="from_Account">from_Account</option></dd>
<dd><option value="to_Account">to_Account</option></dd>

<dd><option value="type_bond">type_bond</option></dd>
<dd><option value="amount">amount</option></dd>

<dd></select></dd>
</dl>
</li>
</ul>
 
  
  <input type="submit" name="order_record" value="ORDER" id="order_record_id" />
  <input type="hidden" name="order_record_bond" id="order_record_bond_id" value="ordered" />
 </form> '
;
 
  }
  
?>
سجل
renan
مستكشــف

رسائل: 3


مشاهدة الملف الشخصى
« رد #22 في: حزيران 02, 2009, 08:01:10 »

  Billing table contains the billing invoice number, which is a primary key to the field,And the date of the invoice,And also of the total bill,It contains the number of the supplier and the fact that a foreign key



شفرة: (sql)
CREATE TABLE `billing` (
  `Billing_Id` int(11) unsigned NOT NULL,
  `User_code` enum('Customer','Supplier') NOT NULL,
  `date` date NOT NULL,
  `Total_Invoice` int(50) unsigned NOT NULL,
  `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `Process` enum('sales','purches') NOT NULL,
  PRIMARY KEY  (`Billing_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

 
Brant contains the types of item No. It is a main field, and the name of the item and the quantity of any product is the quantity of each item and the price of our Class Unit
شفرة: (sql)
CREATE TABLE `brands` (
  `Brands_Id` int(11) unsigned NOT NULL auto_increment,
  `Brands_Name` varchar(50) NOT NULL,
  `Quantity` int(11) unsigned NOT NULL,
  `Unit _Price` decimal(10,2) unsigned NOT NULL,
  PRIMARY KEY  (`Brands_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


 
Custtomer table contains the customer number and customer information on the client-page, place the name of the client and phone number and any company continued

شفرة: (sql)
CREATE TABLE `customer` (
  `Customer_Id` int(11) unsigned NOT NULL auto_increment,
  `Customer_Fname` varchar(50) NOT NULL,
  `Customer_Lname` varchar(50) NOT NULL,
  `Customer_Adress` varchar(100) NOT NULL,
  `Customer_phone` int(50) unsigned NOT NULL,
  `name_Com_Admin` varchar(100) NOT NULL,
  PRIMARY KEY  (`Customer_Id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;


Suppliers table contains the suppliers of information on the supplier Supplier-page number, name and location and Phone number and postal code

شفرة: (sql)
REATE TABLE `suppliers` (
  `Suppliers_Id` int(11) unsigned NOT NULL auto_increment,
  `Suppliers_Name` varchar(50) NOT NULL,
  `Suppliers_Address` varchar(50) NOT NULL,
  `Phone` varchar(15) NOT NULL,
  `Country` varchar(50) NOT NULL,
  `PostalCode` varchar(15) NOT NULL,
  PRIMARY KEY  (`Suppliers_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1

 Terms of billing table containing invoice number p, which is a key and type the item number and quantity of the item and the price per unit of product


شفرة: (sql)
CREATE TABLE `terms of billing` (
  `Billing_Id` int(11) unsigned NOT NULL,
  `Brands_Id` int(11) unsigned NOT NULL COMMENT 'FK',
  `Quantity` int(50) unsigned NOT NULL,
  `Unit _Price` decimal(10,2) unsigned NOT NULL,
  PRIMARY KEY  (`Billing_Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
« آخر تحرير: حزيران 08, 2009, 02:14:35 بواسطة renan » سجل
saed
شبـة عضــو

رسائل: 10


مشاهدة الملف الشخصى البريد
« رد #23 في: حزيران 21, 2009, 11:49:26 »

هذه الدالة تعمل فورم لجداول قاعدة البيانات وتاخذ متغيرين احدهما تحوي الفيلد المراد عرضها من جدول قاعدة البيانات والاخر يحتوي على معلومات استثنائية تعرض بداخل فيلد معين
شفرة: (php)
function from_from_table($strSQL, $exceptions) {
// Can be as easy as this function's parameters.. only two ...
// Shall we try ?
$con=db_connect();
if($con && !empty($strSQL)) {
$result = mysql_query("$strSQL");
if($result) {
$update_mode = false; /* this is to indicate if the operaton is update
of course the difference between update or not is that the input fields has the values in it */
if(strpos(strtolower($strSQL),'where',0) && mysql_num_rows($result) == 1) {
// update goes here
$update_mode = true;
} // checking if strSQL contains WHERE clause AND rows count is 1 << SO IT IS UPDATE >>
$row = mysql_fetch_array($result);
$count = mysql_num_fields($result);
$fields = '';
$onTriger = 'class="onblur" onfocus="this.className=\'onfocus\'" onblur="this.className=\'onblur\'"';
for ($i=0; $i < $count ; $i++ )

    $value = ($update_mode == true ? $row[$i] : '');
$fname = mysql_field_name($result, $i);
$ftype = mysql_field_type($result, $i);
$fsize = mysql_field_len($result, $i);
$fflag = mysql_field_flags($result, $i);

switch ($ftype) {
case 'string' :
if($fflag =='enum'|| $fflag =='set')    {
// for enum fields
//
$options= get_enum(mysql_field_table($result, $i), $fname);//get the enum values from db table
$field_intput1='';
                if($update_mode == true)  {
$field_intput1 .='<option  value="'.$value.'" selected="selected">'.$value.'</option>';
                                    }
                if($update_mode == false)   {
            $field_intput1 .='<option  value="" selected="selected">SELECT</option>';
                             }
                for($j=0; $j < sizeof($options);$j++)    {
           $field_intput1 .= '<option ' . $onTriger . ' value="'.$options[$j].'" >'.$options[$j].'</option>';
                                                        }

               $field_intput = '<select name="%1$s" id="%1$s_id">'.$field_intput1 .'</select>';
                                                                     }
               else {
                  $field_intput = '<input ' . $onTriger . ' type="text" value="'.$value.'"
   size="%3$s" maxlength="%3$s" name="%1$s" id="%1$s_id" />';
                     }
                break;

case 'int':
   if($fname=='Account_Id'&&$update_mode == true)   {
$field_intput = '<input ' . $onTriger . ' readonly type="text" value="'.$value.'"
  size="%3$s" maxlength="%3$s" name="%1$s" id="%1$s_id" />';
                                                              }
           else {
                 $field_intput = '<input ' . $onTriger . ' type="text" value="'.$value.'"
size="%3$s" maxlength="%3$s" name="%1$s" id="%1$s_id" />';
       }
   break;

case 'real':
     $field_intput = '<input ' . $onTriger . ' type="text" value="'.$value.'"
size="%3$s" maxlength="%3$s" name="%1$s" id="%1$s_id" />';
   break;
   
case 'blob':
                  $field_intput = '<textarea ' . $onTriger . ' cols="30" rows="5"
  name="%1$s" id="%1$s_id">'.$value.'</textarea>';
       break;
   
case 'date' :
            if($update_mode == false)   {
   $field_intput_d='';
               $year_now=date("Y");       
               $field_intput_d .='<dl><dd><select name="year" id="year_id"></dd><dd>
   <option  value="" selected="selected">yyyy</option></dd>';
               for($y=2008;$y <= $year_now;$y++)    {
                   $field_intput_d .='<dd><option value="'.$y.'">'.$y.'</option></dd>';
                                                    }
               $field_intput_d .='<dd></select></dd>';
   $field_intput_d .='<dd><select name="month" id="month_id"></dd><dd>
   <option value="" selected="selected">mm</option></dd>';
   for($m=1;$m <= 12;$m++) {
                  $field_intput_d .='<dd><option value="'.$m.'">'.$m.'</option></dd>';
                            }
              $field_intput_d .='<dd></select></dd>';
  $field_intput_d .='<dd><select name="day" id="day_id"></dd><dd>
  <option value="" selected="selected">dd</option></dd>';
              for($d=01;$d <= 30;$d++) {
      $field_intput_d .='<dd><option value="'.$d.'">'.$d.'</option></dd>';
                             }
              $field_intput_d .='<dd></select></dd></dl>';
              $field_intput =$field_intput_d;
                                   }
           else  
        $field_intput = '<input ' . $onTriger . ' type="text" value="'.$value.'"
size="%3$s" maxlength="%3$s" name="%1$s" id="%1$s_id" />';
       break;

    case 'timestamp' :
        if($update_mode == false)  {
  $time=date("Y-m-d H:i:s");
              $field_intput = '<input ' . $onTriger . ' type="text" value="'.$time.'"
  size="%3$s" maxlength="%3$s" name="%1$s" id="%1$s_id" />';
                                          }
           else
          $field_intput = '<input ' . $onTriger . ' type="text" value="'.$value.'"
  size="%3$s" maxlength="%3$s" name="%1$s" id="%1$s_id" />';
       break;

     }//swirch end
$field = sprintf('<dl class="row"><dt><label for="%1$s_id">%2$s</label></dt>
<dd>' . $field_intput . '</dd>  </dl>', $fname, t($fname), $fsize, $ftype);
    $fields.= $field;

}// end........for

} // checking on result
} // checking on SQL string
mysql_close($con);
return $fields;
}// function....... end
سجل
صفحات: 1 [2]
  طباعة  
 
انتقل إلى:  

مدعوم بواسطة MySQL مدعوم بواسطة PHP Powered by SMF 1.1.10 | SMF © 2006-2008, Simple Machines LLC XHTML 1.0 صالح! CSS صالح!