|
 |
|
ขอถามวิธีเก็บค่าแบบ Array ลงฐานข้อมูล ว่าต้องทำยังไงค่ะ |
|
 |
|
|
 |
 |
|
สวัสดีค่ะ พอดีนู๋ได้ code นี้มาจากเว็บ http://www.jquerytips.com/
แล้วสงสัยว่าถ้าเกิดว่าจะเก็บนำข้อมูล $response นี้เก็บต่อในฐานข้อมูลต้องทำอย่างไรค่ะ
ข้อมูลที่ว่า มันอยู่ในรูปแบบของ array ค่ะ ต้องทำยังไงค่ะ
ช่วยด้วยนะค่ะ
ขอบคุณค่ะ
Code (PHP)
<?php
require('facebook.php');
$facebook = new Facebook(array(
'appId' => 'YOUR_FACEBBOK_APP_ID',
'secret' => 'YOUR_FACeBOOK_APP_SECRET',
'cookie' => true,
));
$action = (isset($_GET['action'])) ? $_GET['action'] : false;
if ($action == 'save')
{
$signed_request = $_POST['signed_request'];
$response = $facebook->parseSignedRequest($signed_request);
echo "<pre>" . print_r($response, true) . "</pre>" . "n";
exit(0);
}
$custom_fields = array(
array('name' => 'name'),
array('name' => 'email'),
array('name' => 'location'),
array('name' => 'gender'),
array('name' => 'birthday'),
array('name' => 'password', 'view' => 'not_prefilled'),
array(
'name' => 'like',
'description' => 'Do yout like this plugin?',
'type' => 'checkbox',
'default' => 'checked'
),
array(
'name' => 'phone',
'description' => 'Phone Number',
'type' => 'text'
),
array(
'name' => 'anniversary',
'description' => 'Anniversary',
'type' => 'date'
),
array(
'name' => 'captain',
'description' => 'Best Captain',
'type' => 'select',
'options' => array(
'P' => 'Jean-Luc Picard',
'K' => 'James T. Kirk'
)
),
array(
'name' => 'force',
'description' => 'Which side?',
'type' => 'select',
'options' => array(
'jedi' => 'Jedi',
'sith' => 'Sith'
),
'default' => 'sith'
),
array(
'name' => 'live',
'description' => 'Best Place to Live',
'type' => 'typeahead',
'categories' => array('city', 'country', 'state_province')
),
array('name' => 'captcha')
);
$custom_fields_json = json_encode($custom_fields);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>Facebook Registration Tool</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<style type="text/css">
body {
font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<fb:registration
fields='<?php echo $custom_fields_json; ?>'
redirect-uri="http://www.osdev.com/APIs/facebook/facebook-tools/registration.php?action=save"
width="530">
</fb:registration>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" >
FB.init({
appId : '<?php echo $facebook->getAppId(); ?>',
status : true,
cookie : true,
xfbml : true
});
</script>
</body>
</html>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2011-06-30 10:59:32 |
By :
นิว |
View :
1104 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาค่า $custom_fields_json เก็บลง DB ได้เลย พอตอนจะเรียกดูเนี่ย ค่อย json_decode() ออก เท่านี้ก็เรียบร้อย
|
 |
 |
 |
 |
Date :
2011-06-30 15:21:37 |
By :
x3dev |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
serialize();
|
 |
 |
 |
 |
Date :
2011-06-30 15:42:20 |
By :
pjgunner.com |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พอจะมีตัวอย่างโค้ดรึเปล่าค่ะ
งง จริงๆ ค่ะ ไม่รู้เรื่อง array เลยค่ะ แล้วนู๋ต้องสร้าง ฟิวใน sql ยังไงหรอค่ะ งง
ขอบคุณล่วงหน้ามากๆๆ ค่ะ
|
 |
 |
 |
 |
Date :
2011-07-02 14:17:01 |
By :
นิว |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|