Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

MySQL results as links

Featured Replies

Hi, im currently creating a database that stores lyrics of artists.... im doing this to learn myself the searching side of things.

 

ive got the search working so it returns the results they are looking for, for whateva song.... but im wondering how i would go about making a link out of those search results so that when they click on them it will take them to the lyrics for that song.

 

i cant find any tutorials or guides to help.

 

i have 3 pages. index.php, search.php, and submit.php.

 

submit.php - they can submit the artist, title and lyrics

search.php - displays the results from submitted entries

index.php - currently has the search form on so people can search for lyrics, when clicking the submit button on the search, it goes to the "search.php" to display the results...... the results display as "artist - title" - i would like that linked to goto that songs lyrics

 

i hope this makes sense.... and thanks in advanced

--------------------

Page 1

--------------------

1. selec * from ...

2. echo... (<a href="/?link=222&stuff=hello")

--------------------

Page 2

--------------------

3. get ($ab = $_GET['link']; $ac = $_GET['stuff']; )

4. select * from...

  • Author

hmm im not understanding that mike sorry. is page one the search page? and page 2 the search result?

--------------------

Page 1

--------------------

1. selec * from ...

2. echo... (<a href="/?link=222&stuff=hello")

--------------------

Page 2

--------------------

3. get ($ab = $_GET['link']; $ac = $_GET['stuff']; )

4. select * from...

 

Hi gays

<a href=" lyrics page.php">search result</a>

the point is on any given page you can create links with extra data on the end (a cheat to the form submit method GET).

 

on a seccond page you can detect these variable and display different contents as aproptiate.

 

for example typing hello in a search in google.co.uk has the same effect as <a href="http://www.google.co.uk/?q=hello">

 

In genral the GET method should be left alone as it causes "dirty urls" which is bad for users and SEO.

 

(There are some circumstances where you will need to use the get method ie a search. The GET method is required here as there could be billions of different search result pages each with different data, which need to be bookmarkable)

ok so lets have a new page, lets say lyrics.php on this page we have at the top

 

if(isset($_GET['id'])&& is_numeric($_GET['id'])){
$song_id = $_GET['id'];
}else{
header('Location: ./search.php');
}

if(isset($song_id)){
$lyrics = mysql_fetch_array(mysql_query("SELECT * FROM lyrics WHERE id='$song_id'");

echo $lyrics['title'];
echo $lyrics['artist'];
echo $lyrics['content'];
}

 

 

so the above code will get the lyrics etc if a id has been given in the url otherwise it takes you to the search page to find a song.

 

so on your search results you would link to lyrics.php?id=XX replace the XX with a numeric id.

  • Author

ok this is what i have so far.

is it possible you could work with what i got to help me understand? just im not understanding a few things you guys have posted so far, and i really appretiate the help, so im sorry for bein dumb lol

 

my database has tables of artist, title, lyrics... and a couple others

 

this is my search form on index.php...

 

<form action="search.php" method="post">
<input type="text" name="search" size="30" value="Search Lyrics" />
<input type="submit" value="Submit" />
</form>

 

and this is what is on the search.php

 

<?

$host = "localhost";
$user = "x"; 
$pass = "x";

mysql_connect($host,$user,$pass) or die(mysql_error());

mysql_select_db("db267553604") or die(mysql_error());

$search=$_POST["search"];


$result = mysql_query("SELECT * FROM lyricsdatabase WHERE artist LIKE '%$search%' OR title LIKE '%$search%'");

while ($row  = mysql_fetch_array($result))
{

$artist=$row["artist"];
$title=$row["title"];

echo "<br />$artist - $title<br />";
}

?>

  • Author

i do yeah, the tables include.......

 

ID,artist,title,lyricbody,email,ip

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.