گرفتن width و height و ذخیره آن در sql
این رو از تاپیک دیگه به اینجا منتقل می کنم که بحث با عنوان هم خونی پیدا کنه
نقل قول:
ببینید شما اول یه چیزی رو مشخص کنید. شما یک فایل php دارید که خروجی جاوا اسکرپت میده؟
یا اینکه یک فایل با پسوند js دارید که میخواید متغیر php داخلش داشده باشید؟
اگر گزنه اول هست باید کد php رو توی تاپیک قرار میدادید اگر گزینه دوم هست پس این دستورات php توی فایل جاوا اسکرپت چکار میکنند؟!
اگر هم چند تا سوال جدا از هم هست پس چرا همه توی این تاپیک جمع شدن؟ :دی
فایلی به نام get_resolution.php داریم که طول و عرض اسکرین را در کوکی ذخیره می کند:
[PHP]<?
/************************************************** ************************************
Originally from http://www.phpbuddy.com/article.php?id=8
Author: Ranjit Kumar (Cheif Editor phpbuddy.com)
Modified by: Ying Zhang (Dodo) http://pure-essence.net
Two main modifications:
1. To check currently saved screen resolution cookie
2. To allow inclusion by other php files
In order to use this file in another php file, use:
$callget_res_page_name = $REQUEST_URI;
$GLOBALS[callget_res_page_name] = $callget_res_page_name;
include("get_resolution.php");
echo $screen_width." is your screen width and ".$screen_height." is your screen height.";
************************************************** ***************************************/
?>
<script language="javascript">
<!--
function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_res="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
if (document.cookie){
location = '<?=$GLOBALS[callget_res_page_name]?>';
}
}
function checkRes(width, height) {
if(width != screen.width || height != screen.height) {
writeCookie();
} else {
return true;
}
}
//-->
</script>
<?
if(isset($HTTP_COOKIE_VARS["users_res"])) {
$screen_res = $HTTP_COOKIE_VARS["users_res"];
$screen_res_tmp = explode("x", $screen_res);
$screen_width = $screen_res_tmp[0];
$screen_height = $screen_res_tmp[1];
?>
<script language="javascript">
<!--
checkRes(<?=$screen_width?>, <?=$screen_height?>);
//-->
</script>
<?
}
else //means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();
//-->
</script>
<?
}
?>[/PHP]و در نهایت قاعدتا باید با این یکی کد بتونیم طول و عرض را نمایش دهیم
[PHP]<?php
$callget_res_page_name = $REQUEST_URI;
$GLOBALS[callget_res_page_name] = $callget_res_page_name;
include("get_resolution.php");
echo $screen_width." is your screen width and ".$screen_height." is your screen height.";
?>
[/PHP]برای این از کوکی استفاده می کنم چون می خوام طول و عرض را ذخیره کنم
همچنین نمی خوام از window.location استفاده کنم و طول و عرض در آدرس بار نمایش پیدا کند * اون یکی سئوال هم که از شما درباره ورودی اطلاعات به اسکریپت و ارسال آن به گوگل مپ پرسیدم به کجا رسید؟
شما فرمودید که کد را کامل بگذارم اما پس از ارسال تاپیک هنوز جوابی ندادید؟!
کد:
http://forum.p30world.com/showpost.php?p=5223036&postcount=6