我是PDO的新手,编写更新查询:
$sql = "UPDATE `users`
SET(`uname` = :uname,
`role` = :role,
`fname` = :fname,
`email` = :email,
`mobile1` = :mobile1,
`mobile2` = :mobile2,
`education` = :education,
`division` = :division,
`district` = :district,
`sub_district` = :sub_district,
`address` = :address,
`looking_for` = :looking)
WHERE `id` = :id";
//$sql = "UPDATE `users` SET(`uname`=?,`role`=?,`fname`=?,`email`=?,`mobile1`=?,`mobile2`=?,`education`=?,`division`=?,`district`=?,`sub_district`=?,`address`=?,`looking_for`=?) WHERE `id`=?";
$st = $conn->prepare($sql);
//$res['sql'] = $st->queryString;
$params = array(
':uname' => $uname,
':role' => $role,
':fname' => $fname,
':email' => $email,
':mobile1' => $mobile1,
':mobile2' => $mobile2,
':education' …Run Code Online (Sandbox Code Playgroud) 我加入行throught一个<table>用foreach.
在某些时候,我希望一个单元格具有基于PHP中计算的百分比的灰色背景.
例如:50%意味着细胞背景的一半是灰色的,其余的将保持空白 33,33%= 1/3的背景等.
我遇到的问题是<td>被任何其他div拉伸的文本,如果我将颜色应用于<td>我将稍后覆盖文本等.
这是代码:
$percent = 1/3; // For example
$percent_friendly = number_format( $percent * 100, 2 ); //This will return 33.33
echo '<td>'.$percent_friendly.' %
<div style="background-color: grey"> // So I want the grey to fill 33.33% of the space
</div>
<div style="background-color: white">
</div>
</td>';
Run Code Online (Sandbox Code Playgroud)
和迄今为止应用的样式:
table {
margin-left:auto;
margin-right:auto;
font-size:18px;
}
table, th, td {
text-align: center;
border: 1px solid black;
position:relative;
}
Run Code Online (Sandbox Code Playgroud)
我必须遗漏一些东西,但CSS真的不是我的东西,任何解释或帮助将不胜感激.
我有一个数组JavaScript和一个字符串:
var pool1 = ['ca','cahier','cartable','carte','cartographe','canape'];
var key1 = 'car';
Run Code Online (Sandbox Code Playgroud)
我想要做的是,从数组中删除所有不包含的值key1.
为此,我写了这个函数:
function searchInPool(key, pool){
for (i = 0; i < pool.length; i++) {
var index = pool[i].indexOf(key);
if (index > -1) {
pool.splice(index, 1);
}
}
return pool;
}
Run Code Online (Sandbox Code Playgroud)
它似乎有效,但最终结果给了我:
["cartable", "carte", "cartographe", "canape"]
Run Code Online (Sandbox Code Playgroud)
它已成功删除ca,cahier但canape不应该在这里,因为它不包含car任何人可以解释我从我的函数中写的东西误解了什么?
预期的最终结果是:
["cartable", "carte", "cartographe"]
非常感谢
我想改变我的阵列,我怎样才能做出这种改变.
Array (
[0] => 53720
[1] => Array(
['Build Quality'] => 1=>10,
2=>9,
3=>7
['Versatality'] => 1=>9,
2=>8,
3=>7
['value'] => 1=>8,
2=>6,
3=>5
)
);
至:
Array (
53720 =>['Build Quality' => [1=>10,
2=>9,
3=>7],
'Versatality' => [1=>9,
2=>8,
3=>7],
'value' => [1=>8,
2=>6,
3=>5]
]
);
function get_array(){
$factor = array([0] => 'Build Quality' [1] => 'Versatality' [2] => 'Value');
$rank = array([0] => 1=>10,2=>9,3=>7 [1] => 1=>9,2=>8,3=>7 [2] => 1=>8,2=>6,3=>5);
$assoc_array = array_combine($factor, $rank);
$post_id = …Run Code Online (Sandbox Code Playgroud) php ×3
arrays ×2
background ×1
css ×1
html ×1
javascript ×1
loops ×1
mysql ×1
pdo ×1
percentage ×1
sql ×1