Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create href link inside array

Tags:

php

mysql

matomo

Actualy I have to populate table data using php array to my dashboard. The table contains the URL. I need to set href which is used to redirect to the dynamic link.(below is my while loop code). I have tried creating href using below the single line echo php code.It worked and I got the clickable link, but it didn't return data inside the table. It showed the data in the table without any alignment.

echo '<html><head></head><a href="'.$data['link'].'" target="_blank">'.$data['link'].'</a></html>';  

But I want to create href inside array kindly anyone help us.

public function getTemperatures()
{
    $mysql_hostname = "localhost";
    $mysql_user     = "root";
    $mysql_password = "";
    $mysql_database = "new";
    $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Oops some thing went wrong");
    mysql_select_db($mysql_database, $bd) or die("Oops some thing went wrong");// we are now connected to database

    $result = mysql_query("SELECT * FROM website"); // selecting data through mysql_query()
    $pie = mysql_query("select count(*) from website where status = 'Error'");

    while($data = mysql_fetch_array($result))
    {
        //echo '<html><head></head><a href="'.$data['link'].'" target="_blank">'.$data['link'].'</a></html>';
        $temperatures[] = array(
            'label1' => $data['link'],
            'label2' => $data['time'],
            'label3' => $data['os'],
            'label4' => $data['browser'],
            'label5' => $data['status'],
            'label6' => $data['location'],
            array('label6' => $data['widget_load_time'])
        );
    }    
    return DataTable::makeFromIndexedArray($temperatures);
}
like image 845
Baskar .A Avatar asked May 15 '26 14:05

Baskar .A


1 Answers

pls add this line

'label1' => '<a href="'.$data['link'].'" target="_blank">'.$data['link'].'</a>',
like image 116
Baskar .A Avatar answered May 17 '26 03:05

Baskar .A



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!