나는 내 데이터베이스의 테이블에서 SELECT
데이터를 가지고 있습니다.이 데이터에는 링크가 있습니다. 내가 원하는 것은 링크를 클릭하면 다른 페이지로 이동하는 대신 div에 해당 데이터를 더 많이로드한다는 것입니다. 각각의 링크는 데이터가 database.Below에서 div
에로드 알고있는에서 id
함께 제공하는 것은 내가 링크를 클릭동일한 페이지에 div에있는 PHP 에코 링크가로드 됨
.pricepop
에 데이터베이스에서 데이터를로드하는
javascript
을 아래의 코드
<div class="pricepop"></div>
<div class="pricetab">
<table class="table">
<thead>
<tr>
<th>COMMODITIES</th>
<th>UNITS</th>
<th>INTERNATIONAL PRICE($)</th>
<th>TERMS</th>
<th>LOCAL PRICE (₦)</th>
<th>AS AT</th>
<th>MARKET</th>
<th>Full Details</th>
</tr>
</thead>
<tbody>
<style>
.table > thead > tr > th, .table > tbody > tr > td {
font-size: 10px !important;
font-family: 'Lato', sans-serif;
font-weight: bold;
}
</style>
<?php
$sql = $db->prepare("SELECT * FROM commodityprices");
$result = $sql->execute();
while ($row = $result->fetchArray(SQLITE3_ASSOC))
{
$id = $row['id'];
$_SESSION['id'] = $id;
$name = $row['name'];
$unit = $row['unit'];
$iprice = $row['iprice'];
$lprice = $row['lprice'];
$irate = $row['irate'];
$lrate = $row['lrate'];
$terms = $row['cterms'];
$asat = date('d/M/Y');
$market = $row['market'];
echo '<tr>
<td>'.$name.'</td>
<td>'.$unit.'</td>';
if ($irate == "Down")
{
echo '
<td style="background: #ef5a66; color: #fff"><i class="fa fa-caret-down"> </i> '.$iprice.'</td>';
}
else
{
echo '
<td style="background: #28bc88; color: #fff"><i class="fa fa-caret-up"> </i> '.$iprice.'</td>';
}
echo '<td>'.$terms.'</td>';
if ($lrate == "Down")
{
echo '
<td style="background: #ef5a66; color: #fff"><i class="fa fa-caret-down"> </i> '.$lprice.'</td>';
}
else
{
echo '
<td style="background: #28bc88; color: #fff"><i class="fa fa-caret-up"> </i> '.$lprice.'</td>';
}
echo '<td>'.$asat.'</td>
<td>'.$market.'</td>
<td><a class="comprice" href="pricedetails.php?id='.$id.'">View more</a></td>
</tr>';
}
?>
</tbody>
</table>
</div>
입니다 다음은
$(document).ready(function() {
$(".comprice").on("click", function (e) {
e.preventDefault();
$(".pricepop").load("pricedetails.php");
});
});
나머지 가격에 대한 자세한 내용을 가져옵니다 pricedetails.php 코드입니다.
<thead>
<tr>
<th>COMMODITIES</th>
<th>TERMS</th>
<th>LOCAL PRICE (₦)</th>
<th>AS AT</th>
<th>MARKET</th>
<th>Price/bag</th>
</tr>
</thead>
<tbody>
<style>
.table > thead > tr > th, .table > tbody > tr > td {
font-size: 10px !important;
font-family: 'Lato', sans-serif;
font-weight: bold;
}
</style>
<?php
$priceId = $_SESSION['id'];
$sql = $db->prepare("SELECT * FROM commodityprices WHERE id = ?");
$sql->bindParam(1, $priceId, SQLITE3_INTEGER);
$result = $sql->execute();
while ($row = $result->fetchArray(SQLITE3_ASSOC))
{
$id = $row['id'];
$name = $row['name'];
$iprice = $row['iprice'];
$lprice = $row['lprice'];
$lrate = $row['lrate'];
$terms = $row['cterms'];
$asat = date('d/M/Y');
$market = $row['market'];
$priceperbags = $row['priceperbags'];
echo '<tr>
<td>'.$name.'</td>';
echo '<td>'.$terms.'</td>';
if ($lrate == "Down")
{
echo '
<td style="background: #ef5a66; color: #fff"><i class="fa fa-caret-down"> </i> '.$lprice.'</td>';
}
else
{
echo '
<td style="background: #28bc88; color: #fff"><i class="fa fa-caret-up"> </i> '.$lprice.'</td>';
}
echo '<td>'.$asat.'</td>
<td>'.$market.'</td>
<td class="comprice">'.$priceperbags.'</td>
</tr>';
}
?>
</tbody>
</table>
</div>
문제는 이제 상관없이 내가 에코 php
데이터에서 클릭 링크의 .pricepop
에 표시되는 데이터는 세부 echo
링크 마지막 것입니다.
링크를 클릭하면 해당 링크의 id
에서 가져온 세부 정보가 echo
이고 .pricepop
에 표시되는 문제를 해결할 수 있습니다.
감사하지만 어떻게이 문제를 해결 스크롤 무한 수 있습니다 여기에
은 예입니다? – diagold