Lord Potato
Lord Potato

Reputation: 81

PHP, variable wont attach to hyperlink

Im trying to send the patient ID through a hyperlink, tho while it redirects to the correct page it is not sending the information.

<a href="./patientrecord.php?patient_id="<?php $row["patient_id"]?>><?php echo $row["surname"];?></a>

Upvotes: 0

Views: 36

Answers (1)

johnabelardom
johnabelardom

Reputation: 46

Please make sure you are going to echo the variable

Echoing a variable:

<?= $echoable_variable_here ?> // Use <?= ?> tags
or
<?php echo $echoable_variable_here ?> // Use echo inside <?php ?> tags

Edit: You have placed echo outside the href attribute tag

Therefore,

Change this:

<a href="./patientrecord.php?patient_id="<?php $row["patient_id"]?>><?php echo $row["surname"];?></a>

to:

<a href="./patientrecord.php?patient_id=<?php echo $row["patient_id"]?>"><?php echo $row["surname"];?></a>

or to:

<a href="./patientrecord.php?patient_id=<?= $row["patient_id"] ?>"><?php echo $row["surname"];?></a>

Upvotes: 3

Related Questions