الموضوع: لمحترفي Mysql
عرض مشاركة واحدة
عضو نشيط جدا
تاريخ التسجيل: Sep 2006-
#5 (permalink)  

أنا عادة أستخدم الطريقة التالية التي تعلمتها من الشيفرة البرمجية التي يولدها برنامج PHPMaker أرجو ن تعجبك، فهي تولد كود واضح وبسيط للاستعلام:

كود PHP:
    include_once ('adodb_lite/adodb.inc.php');
    
    
// create an object instance
    // configure library for a MySQL connection
    
$db NewADOConnection(DBTYPE);
    
    
// open connection to database
    
$db->pconnect(HOSTUSERPASSDB) or die('Unable to connect!');
    
    
$x_alias   htmlspecialchars(@$_POST['x_alias']);
    
$x_email   htmlspecialchars(@$_POST['x_email']);
    
$x_content htmlspecialchars(@$_POST['x_content']);

        
// Get record ID
        
$fieldList['`page_id`'] = $x_id;

        
// phone number
        
$theValue $x_alias;
        
$theValue = ($theValue != '') ? " '" $theValue "'" "' '";
        
$fieldList['`alias`']   = $theValue;

        
// shipping name
        
$theValue $x_email;
        
$theValue = ($theValue != '') ? " '" $theValue "'" "' '";
        
$fieldList['`email`']   = $theValue;

        
// shipping address
        
$theValue $x_content;
        
$theValue = ($theValue != '') ? " '" $theValue "'" "' '";
        
$fieldList['`content`'] = $theValue;

        
// insert into database
        
$strsql 'INSERT INTO `interactive` (';
        
$strsql .= implode(','array_keys($fieldList));
        
$strsql .= ') VALUES (';
        
$strsql .= implode(','array_values($fieldList));
        
$strsql .= ')';

        
$db->Execute($strsql) or die("Error in query: $strsql. " $db->ErrorMsg()); 






__________________
خالد الشمعة - Khaled Al-Shamaa
PHP, MySQL and Arabic language
DNSerror غير متواجد حالياً   قديم 14-02-2008, 03:00 PM
رد مع اقتباس