I have a simple database with first, last, age and bio fields. It is working fine but I would like to change the first name field so when user add firstname, it shows hyperlink on front-end.
URL = http://inamelookuptest.com/info/default.aspx?first_name=First_Name
So what I am trying to accomplish is when someone adds their first name under first field e.g, Scot. When it adds it to DB, it shows Scot but as a hyperlink so when they click, it goes to this URL:
URL = http://inamelookuptest.com/info/default.aspx?first_name=Scot
I did google search and got some idea but it was breaking my code. Here is my code:
Add.php
<?php
require 'conx.php';
$data = json_decode(file_get_contents("php://input"));
$fn = $data->fn;
$ln = $data->ln;
$age = $data->age;
$bio = $data->bio;
$result = $db->query("INSERT INTO users(firstname,lastname,age,bio) values('$fn','$ln','$age','$bio')");
I tried this but it broke adding new items functionality:
$result = $db->query("INSERT INTO users(firstname,lastname,age,bio) values('<a href="http://inamelookuptest.com/info/default.aspx?first_name= + $fn">'$fn'</a>','$ln','$age','$bio')");
Edit:
<tbody ng-init="getall()">
<tr ng-repeat="d in names | filter:search">
<td>{{ d.uid }}</td>
<td>{{ d.Firstname }}</td>
<td>{{ d.Lastname }}</td>
<td>{{ d.Age }}</td>
<td>{{ d.Bio }}</td>
I added link to firstname as below but I am getting unexpected url:
<td> <a href="http://inamelookuptest.com/info/default.aspx?first_name='{{ d.Firstname }}'"> {{ d.Firstname }} </a></td>
All items are now hyperlinked but when I hover on Scot I see this:
http://inamelookuptest.com/info/default.aspx?first_name=%27scot%27
Edit 2:
I figured it out:
<td> <a href="http://inamelookuptest.com/info/default.aspx?first_name={{ d.Firstname }}"> {{ d.Firstname }} </a></td>
Thanks all!!