小编Ser*_*gio的帖子

PHP数组和选择列表

我想使用php数组进行HTML选择列表.在这种情况下,它将是国家列表,但在下拉列表中列出的国家名称旁边,我需要作为每个国家/地区短国家/地区代码的值.

我目前使用的php数组如下:

$wcr=array(
'Angola',
'Antigua & Barbuda',
'Armenia', 
'Austria',
'Azerbaijan', 
 .....
 );
Run Code Online (Sandbox Code Playgroud)

使用此数组的PHP页面:

<select name="country"><option selected value=""> --------- 
<? $p=1;asort($wcr);reset($wcr);
while (list ($p, $val) = each ($wcr)) {
echo '<option value="'.$p.'">'.$val;
} ?>
</select>
Run Code Online (Sandbox Code Playgroud)

该值应该是短国家/地区代码(类似'ES','美国','AN',...)而不是我现在拥有的数字作为此表单中的值.如果有可能的话,我会在同一个PHP数组中写一些简短的国家代码.

我怎样才能做到这一点?

php

8
推荐指数
2
解决办法
8万
查看次数

PHP小数点

是否可以用PHP将小数点数舍入到最接近的.5,如下所示:

number | round
----------------
 1.29  |  1.50
 2.03  |  2.00
 1.43  |  1.50
 1.13  |  1.00
11.38  | 11.50
Run Code Online (Sandbox Code Playgroud)

我尝试过:

$rnd= round($number,2);
Run Code Online (Sandbox Code Playgroud)

但我得到的小数就像上面"数字"栏中的小数字一样.

php rounding

7
推荐指数
1
解决办法
7496
查看次数

如何创建Jquery外部文件?

我想为表单创建外部JS文件,并使用AJAX发布该数据.

简化的HTML看起来像:

<form action="" id="message" name="message" method="post">
<input name="message_subject" type="text"  id="message_subject" class="message_wall" />
<textarea cols="50" rows="5" id="message_text" class="message_wall"></textarea>
<button type="submit" id="mess" class="mess">send</button>
Run Code Online (Sandbox Code Playgroud)

我目前用于此表单的Jquery:

$("form#message").submit(function() {
  var message_subject = $(".message_subject").attr('value').replace(/\n/g,"<br/>").replace(/\n\n+/g, '<br /><br />').replace(/(\<\/?)script/g,"$1noscript");
  var message_text= $(".message_text").attr('value').replace(/\n/g,"<br/>").replace(/\n\n+/g, '<br /><br />').replace(/(\<\/?)script/g,"$1noscript");
  $.ajax({
    type: "POST",
    url: "mess/somefile.php",
    contentType: "application/x-www-form-urlencoded;charset=ISO-8859-2",
    data: "message_subject="+ message_subject + "&message_text=" + message_text,
    success: function(){
      $(".message_field").html('Thanks!');
    }
  });
  return false;
});
Run Code Online (Sandbox Code Playgroud)

我可以将此Jquery代码放入外部JS文件中,然后调用如下:

$(document).ready(function(){
  myexternalfunction();
});
Run Code Online (Sandbox Code Playgroud)

jquery

5
推荐指数
1
解决办法
4万
查看次数

Mysql更新值

我在数据库中使用了两个表.第一个表看起来像这样:

   id    |   msg_id   |     user   |   date   
-------------------------------------------------
   01    |    122     |    user 1  | 2011-04-01
   02    |    453     |    user 2  | 2011-04-03
   03    |    124     |    user 3  | 2011-04-05
Run Code Online (Sandbox Code Playgroud)

第二个表看起来像这样:

       id    |   msg_id   |     status   | 
   ----------------------------------------
       01    |      0     |       1      | 
       02    |      0     |       1      | 
       03    |     124    |       1      | 
Run Code Online (Sandbox Code Playgroud)

我想根据第一个表中的msg_id记录更新第二个表中"0"值("msg_id"列)的所有行.是否可以使用单个查询执行此操作?

结果应如下所示:

       id    |   msg_id   |     status   | 
   ----------------------------------------
       01    |    122     |       1      | 
       02    |    453     |       1      | …
Run Code Online (Sandbox Code Playgroud)

mysql

5
推荐指数
1
解决办法
1014
查看次数

在CentOS上安装ffmpeg-php

我正在尝试在服务器(CentOS)上安装ffmpeg-php但在"make"命令之后我收到一个错误:

  from /usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c:40:
  /usr/include/bits/stat.h:91: error: field 'st_atim' has incomplete type
  /usr/include/bits/stat.h:92: error: field 'st_mtim' has incomplete type
  /usr/include/bits/stat.h:93: error: field 'st_ctim' has incomplete type
  In file included from /usr/local/include/php/main/php_streams.h:28,
             from /usr/local/include/php/main/php.h:400,
             from /usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c:40:
  /usr/include/sys/stat.h:367: error: array type has incomplete element type
  /usr/include/sys/stat.h:374: error: array type has incomplete element type
  In file included from /usr/local/include/php/main/php.h:406,
             from /usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c:40:



/usr/local/include/php/TSRM/tsrm_virtual_cwd.h:218: error: expected specifier-qualifier-list before 'time_t'
/usr/local/include/php/TSRM/tsrm_virtual_cwd.h:246: error: expected declaration specifiers or '...' before 'time_t'
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c: In function 'zm_startup_ffmpeg':
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c:94: warning: implicit declaration of …
Run Code Online (Sandbox Code Playgroud)

ffmpeg ffmpeg-php

5
推荐指数
1
解决办法
2007
查看次数

$ .getJSON和PHP文件

是否可以隐藏*.php文件的名称

$(document).ready(function(){
$.getJSON("getdata.php", function(returned_data) { 
    if(returned_data === "1") {
        $("div#wall").html('user has no subscription');
        $("#message_wall").attr("disabled", "disabled");
        return false;
    }
});
Run Code Online (Sandbox Code Playgroud)

});

因为该jquery代码将在页面的源代码中可见,我不希望某些恶意访问者尝试使用它.

php jquery

4
推荐指数
1
解决办法
1152
查看次数

jQuery圆函数

如何使用jQuery舍入数字?

如果数字是3168我想打印它为32.或者如果数字是5233,结果应该是52.

我怎样才能做到这一点?我应该使用这个Math.round功能吗?

javascript jquery

4
推荐指数
2
解决办法
5万
查看次数

Jquery在同一页面的另一个DIV中加载DIV

HTML:

<div class="someclass" rel="first">text 1</div>
<div class="someclass" rel="second">text 2</div></div></div>
<div class="info_ly">here is some text</div>
<div class="first" > the first DIV </div>
<div class="second" > the second DIV </div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.first{ display:none}
.second{ display:none}
Run Code Online (Sandbox Code Playgroud)

jQuery的:

$(".someclass").click(function() {  
$(".info_ly").html($(this).attr('rel'));
});
Run Code Online (Sandbox Code Playgroud)

我想调用并在"info_ly"DIV中加载"rel"DIV.

使用这个Jquery代码,我在"info_ly"DIV中只获得文本"first"或"second".

如何在"info_ly"DIV中加载带有"first"类或DIV类和"second"类的DIV?

jquery

2
推荐指数
1
解决办法
1万
查看次数

Jquery单选按钮检查

我想检查是否有选择的单选按钮,如果没有选择打印一些警报消息.

html代码是:

<form action="" id="form" name="form" method="post">
<input type="radio" id="form_rd" name="form_rd" value="1"> 1
<input type="radio" id="form_rd" name="form_rd" value="2"> 2
<input type="radio" id="form_rd" name="form_rd" value="3"> 3
<button type="submit">send</button>
</form>
Run Code Online (Sandbox Code Playgroud)

我用来检查的Jquery:

$("form#form").submit(function() {
if (!$("#form_rd").attr('checked')) {alert("not checked");return false;}
})
Run Code Online (Sandbox Code Playgroud)

这个jquery代码不起作用.这个单选按钮检查有什么更好的解决方案?

jquery

2
推荐指数
1
解决办法
3467
查看次数

jQuery显示图像问题

我有PHP页面,用户可以上传照片(使用Ajax和PHP脚本).上传后的照片(拇指)会在上传DIV下载字段后显示.

然后,在点击发送按钮后,我想在留言板的同一页面上克隆那个DIV,其他消息有或没有上传的照片.

当我尝试这样做时:

var pht = $("#photos").clone().addClass('p_pht');
Run Code Online (Sandbox Code Playgroud)

并尝试显示发送的照片以下发送消息:

$("div#wall").append('<div class=msg>'+ message +'</div><div class=n_pht>'+ pht +'</div>');
Run Code Online (Sandbox Code Playgroud)

我得到jQuery错误消息"[object Object]"在照片应该显示的位置.

我究竟做错了什么?

jquery

1
推荐指数
1
解决办法
82
查看次数

标签 统计

jquery ×6

php ×3

ffmpeg ×1

ffmpeg-php ×1

javascript ×1

mysql ×1

rounding ×1