我有一个url传递参数使用json_encode每个值如下:
$json = array
(
'countryId' => $_GET['CountryId'],
'productId' => $_GET['ProductId'],
'status' => $_GET['ProductId'],
'opId' => $_GET['OpId']
);
echo json_encode($json);
Run Code Online (Sandbox Code Playgroud)
它的结果如下:
{
"countryId":"84",
"productId":"1",
"status":"0",
"opId":"134"
}
Run Code Online (Sandbox Code Playgroud)
我可以json_decode用来解析每个值以进行进一步的数据处理吗?
谢谢.
如何在不加载的情况下提交时,如何使用jquery检查文本字段是否为空login.php?
<form action="login.php" method="post">
<label>Login Name:</label>
<input type="text" name="email" id="log" />
<label>Password:</label>
<input type="password" name="password" id="pwd" />
<input type="submit" name="submit" value="Login" />
</form>
Run Code Online (Sandbox Code Playgroud)
谢谢.
如何调用以下类方法或函数?
让我说这个params来自url:
$var = filter($_GET['params']);
Run Code Online (Sandbox Code Playgroud)
类:
class Functions{
public function filter($data){
$data = trim(htmlentities(strip_tags($data)));
if(get_magic_quotes_gpc())
$data = stripslashes($data);
$data = mysql_real_escape_string($data);
return $data;
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
我在面板内部使用bootstrap表,如果包含长信息,则在面板外溢出,如何修复?

<div class="col-sm-3" role="complementary">
<div class="panel panel-default">
<div class="panel-body table-responsive">
<table class="table table-bordered table-condensed f11">
<tr>
<td colspan="2" align="center" class="info"><b>Info</b></td>
</tr>
<tr>
<td width="35%"><b>Agent</b></td>
<td width="65%">Luckystar Auto</td>
</tr>
<tr>
<td><b>WhatsApp</b></td>
<td>5412876542</td>
</tr>
<tr>
<td><b>WeChat</b></td>
<td>Luckystar88899</td>
</tr>
<tr>
<td><b>Facebook</b></td>
<td>www.facebook.com/luckystar88899-abcd</td>
</tr>
</table>
</div>
</div>
<div class="panel panel-default">
<div class="panel-body">
<p><div id="map-canvas"></div></p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我使用bootstrap并且在图像上覆盖标题时出现问题,标题div无法放入框中,如下所示:

HTML:
<div class="col-sm-4">
<a href="#">
<img src="images/upload/projects/21/wolf.jpg" class="img-responsive" alt="" />
<div class="desc">
<p class="desc_content">The pack, the basic unit of wolf social life.</p>
</div>
</a>
</div>
<div class="col-sm-4">
<a href="#">
<img src="images/upload/projects/21/cake.png" class="img-responsive" alt="">
<div class="desc">
<p class="desc_content">The pack, the basic unit of wolf social life.</p>
</div>
</a>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
div.desc{
position: absolute;
bottom: 0px;
width: 100%;
background-color: #000;
color: #fff;
opacity: 0.5;
filter: alpha(opacity=50);
}
Run Code Online (Sandbox Code Playgroud)
解:
感谢@himanshu解决了这个问题.
div.desc{
background-color: #000;
bottom: 0;
color: #fff;
left: 0;
opacity: 0.5;
position: …Run Code Online (Sandbox Code Playgroud) 我有一个注册表格,它将插入一个成员表,整理是在utf8_general_ci,我SET NAMES utf8在PHP脚本中使用,好在这里是问题,我不能插入除纯字母以外的字符串,我尝试输入'Hélène'在一个表单字段,在sql查询运行之后,我用我的db表检查,该字段被插入为'H',每当字符串带有特殊字母表(如é, ?后面)时,其余的字母表都不能插入.
有人可以帮忙吗?谢谢.
解:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
mysql_query("SET NAMES utf8");
Run Code Online (Sandbox Code Playgroud)
以上两行是接受数据库输入和网页输出的关键部分.
谢谢大家的建议.
我正在使用CodeIgniter,我有一个带有复选框的表单,允许用户检查并删除他们上传的照片.
在我的控制器中,我if(isset($checked) == 1)用来检查用户是否要删除照片.
$photo_to_table将设置为空并传递给$this->tank_auth->update_user()执行数据库更新,并将照片字段设置为在表中为空.否则,它将保持相同的照片.
但是在我的代码中,无论我是否检查,当我点击UPDATE按钮时,它会不断删除照片,我想知道它为什么会发生?
有人可以通过我的代码并给出建议吗?
控制器:
$user_id = $this->session->userdata('user_id');
$profile = $this->users->get_profile_by_id($user_id);
if(!empty($_FILES['photo']['name']))
{
//image upload process
}
else
{
$checked = $this->input->post('remove');
if(isset($checked) == 1)
{
$photo_to_table = '';
// here will do remove process to delete file in directory
}
else
{
$photo_to_table = $profile->photo;
}
}
if($this->form_validation->run()) { // validation ok
if(!is_null($data = $this->tank_auth->update_user(
$this->form_validation->set_value('name'),
$this->form_validation->set_value('country'),
$this->form_validation->set_value('website'),
$photo_to_table
)))
{
// success
$this->session->set_flashdata('msg', 'Profile has been updated');
redirect(current_url()); …Run Code Online (Sandbox Code Playgroud) 我使用CI创建了一个表单,并有一个原生的form_validation()库来验证每个字段输入,我使用jQuery post来回调输入以检查每个字段是否有效,如果我希望每个错误填充到每个字段form_error()旁边场而不是validation_errors()?
请参考以下内容:
视图:
<script>
$("#btnregister").click(function() {
var parameters = $("#reg_form").serialize();
$.post(baseurl+'pages/registration', parameters, function(data) {
if(data == "ok") {
//show success message
}else{
$("#error").html(data);
}
}, "html");
});
</script>
<div id="error"></div>
<form id="reg_form" method="post">
<p>
<label for="reg_username">Username</label><br />
<input type="text" id="reg_username" name="reg_username" value="<?php echo set_value('reg_username'); ?>">
<?php echo form_error('reg_username'); ?>
</p>
<p>
<label for="reg_email">Email</label><br />
<input type="text" id="reg_email" name="reg_email" value="<?php echo set_value('reg_email'); ?>">
<?php echo form_error('reg_email'); ?>
</p>
<p><input type="button" id="btnregister" value="Register"></p>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
控制器:
public …Run Code Online (Sandbox Code Playgroud) 我在下面的脚本上遇到了一个问题,假设$exp_date是从db中检索的,我想比较到期日和今天的日期来检查会员资格是否仍然存在.
没有什么可以显示但只是Time Expired,代码有什么问题?
从db中的到期列检索的数据设置为varchar(由前同事构建).
$exp_date = "22/01/2014";
$todays_date = date("d/m/Y");
$today = strtotime($todays_date);
$expiration_date = strtotime($exp_date);
echo $expiration_date.' | '.$today.'<br>';
if($expiration_date > $today){
echo 'Still Active';
} else {
echo 'Time Expired';
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
我的表单有以下复选框,我想勾选选项以显示带有选中值的警报,但是当我勾选它时没有任何事情显示警报:
<form id="booking_form">
<input type="checkbox" name="bType[]" id="bType" value="A,200"> Type A - USD200<br>
<input type="checkbox" name="bType[]" id="bType" value="B,150"> Type B - USD150<br>
<input type="checkbox" name="bType[]" id="bType" value="C,100"> Type C - USD100<br>
<input type="checkbox" name="bType[]" id="bType" value="D,50"> Type D - USD50<br>
</form>
Run Code Online (Sandbox Code Playgroud)
我有JQ脚本:
<script>
$("input[type=checkbox]:checked").each ( function() {
alert ( $(this).val() );
});
</script>
Run Code Online (Sandbox Code Playgroud)
请指教,谢谢.
php ×5
checkbox ×2
codeigniter ×2
jquery ×2
class ×1
css ×1
date ×1
datetime ×1
form-submit ×1
function ×1
html-table ×1
json ×1
methods ×1
mysql ×1
strtotime ×1
validation ×1