Witam
Nie jestem specem w kwestii PHP a potrzebuję edytować kod mojej strony prywatnego serwera gry.
Kod ma za zadanie wyświetlenie danych z bazy danych MSSQL w tabeli.
Zgodnie z moją wiedzą o php wszystko powinno działać. Tak niestety nie jest.
kod, który edytowałem:
<table class="nk-table">
<tbody>
<tr>
<th>Item Name</th>
<th>Data End</th>
<th>Price</th>
<th>Image</th>
</tr>
<?php
$testowe = $userProfile["CharacterId"];
$testowe1 = $conn->prepare("SELECT * FROM BazaarItem BI INNER JOIN ItemInstance ItemI ON BI.ItemInstanceId = ItemI.Id INNER JOIN Item i ON ItemI.ItemVNum = i.VNum WHERE BI.SellerId = ?");
$testowe1->execute($testowe);
while($testowe2 = $testowe1->fetch()):
?>
<tr>
<td><?= $testowe2["Name"]?></td>
<td><?= date('d/m/Y H:i:s',strtotime('+'.$testowe2["Duration"].'hour', strtotime($testowe2["DateStart"]))) ?></td>
<td><?= $testowe2["Price"] ?></td>
<td><img src="assets/images/item<?= $testowe2["VNum"] ?>.png"></td>
</tr>
<?php
endwhile;
?>
</tbody>
</table>
<div class="nk-gap-1"></div>
a następnie źródło strony po wgraniu na serwer (tylko część strony, której dotyczy ten kod):
<table class="nk-table">
<tbody>
<tr>
<th>Item Name</th>
<th>Data End</th>
<th>Price</th>
<th>Image</th>
</tr>
</tbody>
</table>
<div class="nk-gap-1"></div>
krótki opis (używałem tak głupich nazw, gdyż jest to tylko test kodu):
*$userProfile["CharacterId"] -> działa prawidłowo. Sprawdzałem i przyjmuje wartość, która jest w dalszej części kodu potrzebna.
- W tabeli BazaarItem znajdują się itemy, które są aktualnie wystawione na pewnego rodzaju market (uznajmy to za sklep w grze, w którym przedmioty wystawiają gracze, a nie administracja serwera)
Nie proszę o edycję kodu i podanie mi wszystkiego na tacy.
Proszę zaś o zerknięcie na kod i podpowiedź, czy taki tok rozumowania ma w ogóle sens.
dodam, że w innej części strony (panelu administratora) mam kod, który działa na podobnej zasadzie (tak, na ten moment działa). Różnica jest taka, iż tam należy podać CharacterId a kod następnie wszystko prawidłowo wypisuje. Tutaj zaś CharacterId znajduje się w $userProfile["CharacterId"]
kod:
<div id="accordion-1-2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="accordion-1-2-heading">
<form action="adminpanel.php" method="post" class="nk-form nk-form-style-1">
<div class="input-group">
<input type="text" name="PlayerCharacterId" class="form-control" placeholder="Recherchez un joueur (CharacterId)">
<button class="nk-btn nk-btn-color-main-1">
<span class="fa fa-search"></span>
</button>
</div>
</form>
<div class="nk-gap-1"></div>
<?php
if($_POST["PlayerCharacterId"]):
$req = $conn->prepare("SELECT * FROM Character WHERE CharacterId = ?");
$req->execute([$_POST["PlayerCharacterId"]]);
$CharacterTable = $req->fetch();
?>
<table class="nk-table">
<thead>
<tr>
<th colspan="4">Nosbasar Infos <?= $CharacterTable["Name"] ?></th>
</tr>
</thead>
<tbody>
<tr>
<th>Item Name</th>
<th>Data End</th>
<th>Price</th>
<th>Image</th>
</tr>
<?php
$req1 = $conn->prepare("SELECT * FROM BazaarItem BI INNER JOIN ItemInstance ItemI ON BI.ItemInstanceId = ItemI.Id INNER JOIN Item i ON ItemI.ItemVNum = i.VNum WHERE BI.SellerId = ?");
$req1->execute([$_POST["PlayerCharacterId"]]);
while($result1 = $req1->fetch()):
?>
<tr>
<td><?= $result1["Name"] ?></td>
<td><?= date('d/m/Y H:i:s',strtotime('+'.$result1["Duration"].'hour', strtotime($result1["DateStart"]))) ?></td>
<td><?= $result1["Price"] ?></td>
<td><img src="assets/images/item<?= $result1["VNum"] ?>.png"></td>
</tr>
<?php
endwhile;
?>
</tbody>
</table>
<div class="nk-gap-1"></div>
<?php
endif;
?>
</div>
</div>
Z góry dziękuję za sugestie i pozdrawiam