hey everyone,
actually i am creating a website in which data is queried from mysql. in mysql table one of the attributes is in form of hyperlink. When i am displaying the result it is in normal text but i want a hyperlink as the result is displayed so please help me.
Example
<?php
echo "Please enter a genename";
$Genename = mysql_real_escape_string($_POST['name']);
$ID= mysql_query("SELECT ID FROM database.nodefinal WHERE Genename='$Genename'");
$ID = mysql_result($ID, 0);
echo "gene ID= $ID";
?>

but id is a webaddress so i want the result such that when i click on the id i can reach the webpage to which it is linked.

Recommended Answers

All 8 Replies

Hm this might not be what you're looking for but have you thought about using HTML for that? ;)

For example: <a href="[specify a link]">[specify a title]</a>
Which could become: <a href="website.com/page.php?id=$id">CLICK HERE</a>

Please enclose your code in Code tag so it is in proper format to read.

By the way,as per your problem,just use anchor tag of html with href as the data from database

<?php
echo "Please enter a genename";
$Genename = mysql_real_escape_string($_POST['name']);
$ID= mysql_query("SELECT ID FROM database.nodefinal WHERE Genename='$Genename'");
$ID = mysql_result($ID, 0);
echo "gene ID=<a href='$ID'>$ID</a>";//assuming $ID is some URL like http://google.com
?>

Pls am having a kind of difficulty just like Daniel Claff's. I have designed many offline web pages that is picture based. I want to create a single search page that can query any of the web pages as i search for its name on that single search page. Thanks

@Pdprince, please don't hijack someone elses thread, start your own, also post some code that you have been working on so we can help.

this is the code i used
<form method="get" action="search.php">
<label> Search For: </label>
<input type="text" name="" style="query" />
<input type="submit" name="submit" value="Start search" />
<b style="color:black;background-color:#99ff99"><input type="reset" value="Reset"</b>
<b style="color:white;background-color:#886800"></form>
<?php
$db_host="Host Name";
$db_username="Username used to access database";
$db_name="Database u created for site";
$db_tb_name="Name of the table u created in site database";
//a script that will do <b style="color:white;background-color:#00aa00">search</b> task
// leave the below fields as it is except while loop, which will display results on screen
mysql_connect("$db_host","$db_username");
mysql_select_db("$db_name");
<b style="color:black;background-color:#a0ffff">query</b>=mysql_real_escape_string($_GET['<b style="color:black;background-color:#a0ffff">query</b>']);
$query_for_result=mysql_query("SELECT * FROM $db_tb_name WHERE *
$db_tb_atr_name like '%".$<b style="color:black;background-color:#a0ffff">query</b>."%'");
echo "<h2><b style="color:white;background-color:#00aa00">Search</b> Results</h2><ol>";
while($data_fetch=mysql_fetch_array($query_for_result))

echo "<li>";
echo substr($data_fetch[$db_tb_atr_name], 0,160);
echo "</li><hr/>";

echo "</ol>";
mysql_close();
?>
I hope i can get the assistance. Thanks

What exactly is is that you are asking, pdprince? And could you please start a new thread for your problem in which you describe your problem and ask your question? :) That way we can keep each thread limited to one specific question.

how pitty of you Pdprince please create a new discussion theread NOW! and I can give you hints once you do my command

I would repair minitaurus' suggestion

$web_link="yoursite.com"
$selectIDs="select * from ID";
$queryIDs=mysql_query($selectIds) or die(mysql_error()));
while($fetchIDs=mysql_fetch_array($queryIDs)){
<a href="<?php echo $web_link."?=".$ID; ?>">
}

it will release all links that will having different Id's

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.