I'm writing a website for myself right now. I've got a problem that I cannot solve. The website is about buying files with website custom balance. What I want to do is disable buy button if user bought this file b4. I'm trying to check the data inside a while but idk how?? This is what I.
while ($row = $rocket->fetch())
{
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['uploader']; ?></td>
<td><?php echo $row['uploadtime']; ?></td>
<td><button <?php
if ($row['id'] == $row2['file_id']) // <---- Working only for the first since it's not a loop
{
echo "disabled";
}
?>
><a href="download.php?id=<?php echo $row['id']; ?>"></a><?php echo $row['price'] . "D$" ?></button></td>
</tr>
<?php } ?>
I tried to do
$row['id'] == $row2['file_id'];
but eventually it's checking only the first line. Maybe the problem is easily solvable, as a newbie cannot find the solution. There are the queries:
$rocket = $bdd->prepare('SELECT money FROM users WHERE id = ?');
$rocket->execute(array($_SESSION['id']));
$row = $rocket->fetch();
$rocket->closeCursor();
$rocket = $bdd->query('SELECT * FROM files');
$rocket2 = $bdd->prepare('SELECT * FROM user_files WHERE user_id = ?');
$rocket2->execute(array($uid));
$row2 = $rocket2->fetch();
What I want to do is check in every $row, is the $row['file_id'] present.