我通过ajax获取特定的产品项列表,方法是将它们的唯一ID传递给服务器.现在每个产品都有自己的一组属性,我必须在页面上显示产品图像.当我通过jquery设置值时,只打印了数组中的最后一个值.以下是我的编码文件.
images.php
while($fetch = mysql_fetch_array($result))
{
?>
<div class="col-sm-4">
<div class="thumbnail">
<a class="productitemid" href="productpurchase.php?id=<?php echo $fetch['itemID'];?>"><img class="img-responsive productimage" src="uploadedfiles\<?php echo $fetch['imageURL'];?>" alt="<?php echo $fetch['imageURL'];?>" /></a>
<div class="text-center productitemname" style="font-weight:bold;"><?php echo $fetch['itemName']; ?></div>
<div class="badge col-sm-offset-1 productprice"><?php echo $fetch['price']; ?></div>
<span class="col-md-offset-7"><a class="productitemid btn btn-success" href="productpurchase.php?id=<?php echo $fetch['itemID'];?>">BUY</a></span>
</div>
</div>
<?php
}
Run Code Online (Sandbox Code Playgroud)
js文件
$(document).ready(function(){
$('.menProdCatgry').on('click',function(){
$.ajax({
type: "post",
url: "getselectedproducts.php",
data:{
"prodId" : $('.menProdCatgry').attr('prodCatId')
},
dataType: "json",
success: function(data){
console.log(data);
$.each(data, function(){
var getprodId = this.prodId;
var getimageURL = this.imageURL;
var …Run Code Online (Sandbox Code Playgroud) 我刚开始在 php 中学习 OOPS。我写了一个简单的程序来实现继承。当不在对象上下文中时,我收到 $this 的致命错误。谁能解释一下这个错误,这是什么意思?这是我的代码:
<?php
class human{
public $gender;
public function _construct($gender)
{
$this->gender=$gender;
echo $this->get_gender();
}
public function get_gender()
{
return $this->gender;
}
}
class person extends human{
public $name;
public $surname;
public static function set_name($name)
{
$this->name=$name;
}
public static function set_surname($surname)
{
$this->surname=$surname;
}
public static function get_name()
{
return $this->name;
}
public static function get_surname()
{
return $this->surname;
}
}
$john = new person('male');
$john->set_name('John');
$john->set_surname('Williams');
echo $john->get_name().' '.$john->get_surname().'is a '.$john->get_gender();
?>
Run Code Online (Sandbox Code Playgroud) 我从sql server获取季度记录.这些记录就像每年每个季度的总借记和贷记.在我的SQL查询中,我已经制作了季度,并且年份是动态的,您可以在代码中看到.
public List<QuarterlyExpenseList> GetExpenseDataQuarterly(string Id, string Year)
{
string SQL = "select aspnetusers.username, SUM(case when Expense.Type='credit' and (Expense.Date>='@year-01-01' and Expense.Date<='@year-03-31') then Expense.Amount else 0 end) as QuarterOneCredits,";
SQL += " SUM(case when Expense.Type='credit' and (Expense.Date>='@year-04-01' and Expense.Date<='@year-06-30') then Expense.Amount else 0 end) as QuarterTwoCredits,";
SQL += " SUM(case when Expense.Type='credit' and (Expense.Date>='@year-07-01' and Expense.Date<='@year-09-30') then Expense.Amount else 0 end) as QuarterThreeCredits,";
SQL += " SUM(case when Expense.Type='credit' and (Expense.Date>='@year-10-01' and Expense.Date<='@year-12-31') then Expense.Amount else 0 end) as QuarterFourCredits,";
SQL …Run Code Online (Sandbox Code Playgroud) 我正在阅读有关脚本语言和编程语言之间的区别,有一点是,脚本语言在客户端计算机上运行,而诸如c#,vb,java和php等编程语言则在服务器计算机上运行。但是php被认为是一种脚本语言。现在,这令人困惑!我们通常使用php编写在服务器上运行的代码,那么php如何成为脚本语言?
php ×3
arrays ×1
c# ×1
dom ×1
dynamic-html ×1
fatal-error ×1
inheritance ×1
jquery ×1
oop ×1
scripting ×1
sql ×1