Forum Moderators: coopster

Message Too Old, No Replies

How to make link from a variable in PHP?

Please, Help me

         

scepanmali

2:22 am on Mar 19, 2008 (gmt 0)

10+ Year Member



I don't know how to do it! Please, if anyone knows I will be very thankful. I know it in theory but practical...
And how to display the result in the title of the Browser?
Like, Download- and the name of the requested $id!

$sql = mysql_query("SELECT * FROM oblast_metal WHERE ID = '$id'");

while ($row = mysql_fetch_array($sql)) { ?>

<?php

$zajedno=$row['Artist']."- ".$row['Song'];
$id = $_GET['id'];

echo "<font size=3><font color=white>Download </font></font>";

echo "<font size=4><font color=grey>"." ". $zajedno;- How to make this code to link with $row['Link']! Something like:

echo "<a href="$row['Link']>$zajedno</ a>;

Please, help me if anyone knows! Thank You in advance!

}

Habtom

7:31 am on Mar 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want to place the text in the title of the browser, I don't think you have that many options like changing the colors.

<?php
$sql = mysql_query("SELECT link FROM oblast_metal WHERE ID = '$id'");
$title = mysql_fetch_row($sql);
?>
<head>
....
<title><?php echo $title[0]; ?></title>
....
</head>

cameraman

8:47 am on Mar 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, scepanmali!

You almost have it, just a little bit of straightening up:
echo "<a href=\"{$row['Link']}\">$zajedno</a>";

And just from what you pasted and the order it's pasted, you may need to move this line:
$id = $_GET['id'];

up above the $sql line.

penders

12:00 pm on Mar 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



And how to display the result in the title of the Browser?

The text in the title bar of the browser comes from the <title> tag in the resulting HTML document. If you are writing your page with PHP then you can write this as well.

scepanmali

8:49 am on Mar 20, 2008 (gmt 0)

10+ Year Member



It worked, but I need to display a name of artist and song which are
different from "id"! I have separate columns for id, artist, song and link! The code you provide echos only the number of id. But, what I need is to display columns: "Artist", "Song" in the browser. Thank you all for your understanding because I am a beginner and I don't know how to do it! Please, help me! Here is the code:

<?php
$username = "root";
$password = "root";
$hostname = "localhost";

$dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
echo "<br>";
$selected = mysql_select_db("spotovi1", $dbhandle) or die("Could not select DB");

$zajedno=$row['Artist']."- ".$row['Song'];
$row['Artist']=$Artist;
$row['Song']=$Song;
$id= $row['id'];
$id = $_GET['id'];

$sql = mysql_query("SELECT * FROM oblast_metal WHERE ID = '$id'");
$title = mysql_fetch_row($sql);