Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to create a Hyperlink using MYSQL data to be passed into a url

Posted on 2011-03-09
4
Medium Priority
?
447 Views
Last Modified: 2012-05-11
Hi Experts,

What im trying to do is

Make some data from mysql into a hyperlink so when the hyperlink is pressed sends the hyperlink for example "0777777777" into the array and would then direct onto the next page.

so the url once the link is clicked would be something like

http://localhost/billing.php?val=07777777777
how would i make the 077777777 retrieved from the database into a link which sets as a variable?
this is what ive got so far. see attached

Many thanks for your help


<?php 
error_reporting(E_ALL);
include 'myphp.php';
$val = $_GET['val'];
$sql = "SELECT * FROM customer_details WHERE customer_name = '" . $val . "'";
$result = mysql_query($sql) or die(mysql_error() . " IN $sql"); 
$rs = mysql_query($sql);

while($row = mysql_fetch_array($rs))
{
   echo"<table>";
   echo "<tr><td>Customer:</td><td>".$row['customer_name']."</td></tr>";
   echo "<tr><td>Mobile Number:</td><td>".$row['mobile_number']."</td></tr>";
   echo"</table>";
}
   ?>

Open in new window

0
Comment
Question by:NeoAshura
  • 3
4 Comments
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 35082580
Try this:

<?php
error_reporting(E_ALL);
include 'myphp.php';
$val = $_GET['val'];
$sql = "SELECT * FROM customer_details WHERE customer_name = '" . $val . "'";
$result = mysql_query($sql) or die(mysql_error() . " IN $sql");
$rs = mysql_query($sql);

while($row = mysql_fetch_array($rs))
{
   echo"<table>";
   echo "<tr><td>Customer:</td><td>".$row['customer_name']."</td></tr>";
   echo "<tr><td>Mobile Number:</td><td><a href=\"billing.php?val=".$row['mobile_number'].">".$row['mobile_number']."</a></td></tr>";
   echo"</table>";
}
   ?>
0
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 2000 total points
ID: 35082597
I think I missed one \"

echo "<tr><td>Mobile Number:</td><td><a href=\"billing.php?val=".$row['mobile_number']."\">".$row['mobile_number']."</a></td></tr>";
0
 
LVL 6

Author Comment

by:NeoAshura
ID: 35082679
again you are a legend, 10/10
0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 35082700
Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to dynamically set the form action using jQuery.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question