Home > front end >  How to create an Href using a MySQL column VARCHAR/TEXT
How to create an Href using a MySQL column VARCHAR/TEXT

Time:04-14

I am currently trying to link a "courseName" variable from mySQL table into an a href ="" code because I don't want each clickable link to go to the same sight.

<a href = "#">'.$record['courseName'].'</a>

This is my current line of html code. I need to replace the # with .$record['courseURL'] but I can't find a way to do it. Is there anyone who can help or push me in the right direction?

CodePudding user response:

If I understand you correctly, you are trying to do this.

For example, let your $record['courseName'] variable be 'course.php'.

$record['courseName'] = 'main.php';

Your "a" tag should look something like this.

echo '<a href ='. $record['courseName'].'>'.$record['courseName'].'</a>';

CodePudding user response:

You can just print the course url into href attribute. Try:

  <a href="<?php echo $record['courseURL']; ?>">
     <?php echo $record['courseName']; ?>
  </a>
  • Related