Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9071375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:53:43+00:00 2026-06-16T17:53:43+00:00

I am using mysqli queries in php script to pull data from mysql database

  • 0

I am using mysqli queries in php script to pull data from mysql database table and display it on website.

Some of the data includes links, but they are formatted in specific format. The links are formatted as #Link Name#http://www.link.com

So first # sets the name and the second # sets the hyperlink.

I would need my php script to parse this and display as normal hyperlink on a website.

Here is the php scrip:

<?php
include('mysql_connection.php');

$c = mysqlConnect();

$locale = $_GET['locale'];
$last_news_id = $_GET['news_id'];

sendQuery ("set character_set_results='utf8'"); 
sendQuery ("set collation_connection='utf8_general_ci'"); 

if (strcmp($locale,"en") != 0)
    $locale = "en";

$result = sendQuery("SELECT * FROM news WHERE id > ".$last_news_id." and locale = '" . $locale . "' ORDER BY id DESC LIMIT 10");

echo '<table width=\"100%\">';
while($row = mysqli_fetch_array($result, MYSQL_NUM))
{
    echo '<tr><td width=\"100%\"><b>Date: </b>'.$row[2].'</td></tr>';
    echo '<tr><td width=\"100%\">'.nl2br($row[3]).'</td></tr>';
    echo '<tr><td width=\"100%\"><hr style="height: 2px; border: none; background: #515151;"></td></tr>';
}
echo '</table>';

mysqliClose($c);
?>

EDIT: I added the line and it sort of helped with one issue:

echo '<tr><td width=\"100%\">'.preg_replace('/#([^#]*)#.*/', '<a href="$2" target="_blank">$1</a>', $row[3]).'</td></tr>';

It still opens the existing page and not the hyperlink. I guess the $2 should be the hyperlink, the value that goes after second #. However, I’m not totally sure how to code this into php.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:53:44+00:00Added an answer on June 16, 2026 at 5:53 pm

    I assume $row[3] is the data includes links, by using regular expression,

    preg_replace('/#([^#]*)#(.*)/', '<a href="$2">$1</a>', $row[3]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using MySQL and PHP. I'm trying to select 4 random ads from a table.
I'm running two queries in my script room.php . Both are using MySQLi prepared
Using an ajax autosuggest script that queries a mysql database as I enter names.
I have a PHP script that runs very simple queries on a MySQL database
I have a php page that pulls data from a mysql database based on
I have some questions about using MySQLi queries, and related memory management. Suppose I
I'm using my own class for database queries, extending mysqli: class iDatabase extends mysqli
I'm using MySQLi with PHP(5.2.4) MySQL(5.0.51a) on Ubuntu 8.04 LAMP. The relevant Db tables
I have some php code for running a different mySQL queries based on an
I am working on an Asset Database problem using PHP / MySQL. In this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.