I have a display_all_groups.php page that display a bootstrap card of all groups created by user. When users click on "View Group" hyperlink it will direct them to view_group.php
Here are my code
session_start();
require_once $_SERVER["DOCUMENT_ROOT"].'/mindspace/Business Services Layer/ManageGroupsController/GroupsController.php';
$std_id = $_SESSION['std_id'];
$group = new ManageGroupsController();
$data = $group->viewGroups($std_id);
?>
<div class="main-panel">
<div class="content-wrapper">
<div class="row">
<div class="col-12 grid-margin stretch-card">
<form method="post">
<?php
foreach($data as $row){
?>
<div class="card-body">
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="../../template/images/banner.png" alt="Card image cap">
<div class="card-body">
<h5 class="card-title"><?=$row['group_name']?></h5>
<p class="card-text"></p>
<a class="btn btn-primary" href="view_group.php?group_id=<?=$row['group_id']?>'">View Group</a>
</div>
</div>
</div>
</form>
<?php } ?>
</div>
</div>
</div>
</div>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
When I try to click on the View Group button, it did not bring me to other page that I want it to. Please help, Im very new to PHP
CodePudding user response:
There is a superfluous single quote near the end, and the array value should probably be echoed properly:
href="view_group.php?group_id=<?=$row['group_id']?>'"
should be
href="view_group.php?group_id=<?php echo $row['group_id']; ?>"
CodePudding user response:
It's hard to say exactly what the problem could be. First I would always check that $data is not empty. Then the keys are named correctly. I don't know the data object.
If everything is correct, then it should work. A small remark: In the link there is still a simple quotation mark. You should delete that too.
<?= $row['group_id']?> >>>>**'**<<<< "