ASP code help to produce output list as url

ASP code below,

Would like to produce the list of output given a url so they can click on the line item and it will play the song.

currently the output just lists the name of the songs.

Is it also possible to have each line of output have a checkbox so they can select which songs they want to play and then it could create a play list for them mysong.m3u that would produce a separate page with just the list of songs they selected.




<%
dim searchWord
searchWord = Request.Querystring("song") 
Set oConn=Server.CreateObject("ADODB.Connection") 

oConn.Open "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=xxxxx;Password=xxxxxxxx;Initial Catalog=Music;Network Library=DBMSSOCN;Data Source=xxx.xxx.xxx.xxx,1433"

strSQL1 = "SELECT dbo.Artists.artistname, dbo.Recordings.RecordingTitle, dbo.Tracks.TrackTitle, dbo.Tracks.TrackFileName FROM  dbo.Artists INNER JOIN dbo.Recordings ON dbo.Artists.artistid = dbo.Recordings.ArtistID INNER JOIN dbo.Tracks ON dbo.Recordings.RecordingID = dbo.Tracks.RecordingID WHERE     (dbo.Artists.artistname = '"& searchWord&"') OR (dbo.Recordings.RecordingTitle = '"& searchWord&"') OR (dbo.Tracks.TrackTitle = '"& searchWord&"')"

Set oRs1=oConn.Execute(strSQL1,lngRecs,1)

if not oRs1.eof then
    do until oRs1.eof
         response.write "<div class=""results"">"&oRs1("artistname")&" "&oRs1("RecordingTitle")&" "&oRs1("TrackTitle")&" "&oRs1("TrackFileName")&"</div>"
    oRs1.movenext
    loop
end if
%>

Open in new window


Any help would be great
LVL 23
Thomas GrassiSystems AdministratorAsked:
Who is Participating?
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
It would be best to start with plain htm, get that to work, then back in your scripting.

For testing try this

This goes on page1.asp
<form method="post" action="page2.asp">
<input type="checkbox" name="mySelections" value="Song 1">
<input type="checkbox" name="mySelections" value="Song 2">
<input type="checkbox" name="mySelections" value="Song 3">
<button type="submit">Submit</button>
</form>

Open in new window

On page2.asp
<%
if request.form<>"" then

response.write "This is what the raw data from the form post looks like<br>"
response.write request.form
response.write "<hr>This is the raw data just from the checkbox's  mySelections"&strSongs&"<br>
response.write "This is data parsed from the checkbox<br>"
strSongs=request.form("mySelections")
arraySongs=split(strSongs,",")
for each song in arraySongs
     response.write song&"<br>"
next
else
response.write "You did not post any data yet"
end if
%>

Open in new window

0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
how do you normally play the files? where are that paths to the file stored?
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Your checkbox would probably look like this

 response.write "<div class=""results""><input type=""checkbox"" name=""selectItem"" value="""&oRs1("TrackFileName")&"""> "&oRs1("artistname")&" "&oRs1("RecordingTitle")&" "&oRs1("TrackTitle")&" "&oRs1("TrackFileName")&"</div>"

Open in new window


Then your output would be a comma separated text string.  To see for your self, do a
response.write request.form("selectItem")

Open in new window


Take a look at how forms work to start with http://www.w3schools.com/html/html_forms.asp
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
To parse the response of a comma delimited field, you will create an array and loop through it.

dim PlayList 
PlayList = request.form("selectItem")
arrPlayList = split(PlayList,",")

For each item in arrPlayList
    response.write Item &"<br>"
    ' Or play song
next

Open in new window

http://www.w3schools.com/vbscript/func_split.asp
0
 
Thomas GrassiSystems AdministratorAuthor Commented:
Scott

Thanks for replying
Sorry for the delay back long day at work today.

I put the checkbox code it and now it displays a check box that's great.
You second Posting with the array where do I place that code

<%
dim searchWord
searchWord = Request.Querystring("song") 
Set oConn=Server.CreateObject("ADODB.Connection") 

oConn.Open "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=xxxxx;Password=xxxxxxxx;Initial Catalog=Music;Network Library=DBMSSOCN;Data Source=xxx.xxx.xxx.xxx,1433"

strSQL1 = "SELECT dbo.Artists.artistname, dbo.Recordings.RecordingTitle, dbo.Tracks.TrackTitle, dbo.Tracks.TrackFileName FROM  dbo.Artists INNER JOIN dbo.Recordings ON dbo.Artists.artistid = dbo.Recordings.ArtistID INNER JOIN dbo.Tracks ON dbo.Recordings.RecordingID = dbo.Tracks.RecordingID WHERE     (dbo.Artists.artistname Like '"& searchWord&"') OR (dbo.Recordings.RecordingTitle Like '"& searchWord&"') OR (dbo.Tracks.TrackTitle Like '"& searchWord&"')"

Set oRs1=oConn.Execute(strSQL1,lngRecs,1)

if not oRs1.eof then
    do until oRs1.eof
       response.write "<div class=""results""><input type=""checkbox"" name=""selectItem"" value="""&oRs1("TrackFileName")&"""> "&oRs1("artistname")&" "&oRs1("RecordingTitle")&" "&oRs1("TrackTitle")&" "&oRs1("TrackFileName")&"</div>"
    oRs1.movenext
    loop
end if
%>

Open in new window


Thanks in advance
0
 
Thomas GrassiSystems AdministratorAuthor Commented:
Big Monty:

The music gets played on any media player, works on Computer IE, Firefox Chrome, Safari, on iPad iPhone Android etc.

www.tomsmp3.com   check it out.

The files are on a drive connected to the web server using IIS 6.0
The all are in a sql database from which I can run the query from.

Working on fine turning the query.

Thanks in advance
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
You are going to place the checkbox's in a form.  When the submit button is used, the form data for the check box's will be a comma delimited string.  

You would place the array on the page you are submitting the data to.
0
 
Thomas GrassiSystems AdministratorAuthor Commented:
Scott little confused about where this goes.

You are talking about the ASP Code that I listed above correct?

I tried adding it after the end if but that did not work

You suggestion?
0
 
Thomas GrassiSystems AdministratorAuthor Commented:
Scott

Tested the above code and it worked.

Now working on getting that code into my asp code.

Thanks for the help will post results later
0
 
Thomas GrassiSystems AdministratorAuthor Commented:
Scott

Back to my scripting and seem to not be able to incorporate your code from above.

Try placing the form in my asp code but every time I tested the page I got http 500

Removed the code now page works.

How can I add the submit function to mode code below?

<%
dim searchWord
dim strFont1
dim strFont2
searchWord = Request.Querystring("song") 
strFont1 = "<font style=""font-size: 20px; color: #ff0000; font-family:verdana"">"
strFont2 = "<font style=""font-size: 16px; color: #000000; font-family:verdana"">"

Set oConn=Server.CreateObject("ADODB.Connection") 

oConn.Open "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=xxxxxxxxxxxx;Password=xxxxxxxxxxxxxx;Initial Catalog=Music;Network Library=DBMSSOCN;Data Source=xxx.xxx.xxx.xxx,1433"

strSQL1 = "SELECT dbo.Artists.artistname, dbo.Recordings.RecordingTitle, dbo.Tracks.TrackTitle, dbo.Tracks.TrackFileName FROM  dbo.Artists INNER JOIN dbo.Recordings ON dbo.Artists.artistid = dbo.Recordings.ArtistID INNER JOIN dbo.Tracks ON dbo.Recordings.RecordingID = dbo.Tracks.RecordingID WHERE     (dbo.Artists.artistname Like '%"& searchWord&"%') OR (dbo.Recordings.RecordingTitle Like '%"& searchWord&"%') OR (dbo.Tracks.TrackTitle Like '%"& searchWord&"%')"

Set oRs1=oConn.Execute(strSQL1,lngRecs,1)

Response.Write strFont1 & "Select Songs you Wish to Add to Your Playlist then click on Submit button<br />"
Response.Write "<br />"

if not oRs1.eof then
    do until oRs1.eof
       response.write strFont2 & "<div class=""results""><input type=""checkbox"" name=""selectItem"" value="""&oRs1("TrackFileName")&"""> "&oRs1("artistname")&" "&oRs1("RecordingTitle")&" "&oRs1("TrackTitle")&" "&oRs1("TrackFileName")&"</div>"
    oRs1.movenext
    loop
end if

%>

Open in new window


I am working on page2.asp which will be music3.asp

The above code is music2.asp
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Try turning on errors / sending to the browser http://www.iis.net/learn/application-frameworks/running-classic-asp-applications-on-iis-7-and-iis-8/classic-asp-script-error-messages-no-longer-shown-in-web-browser-by-default

If you don't have access to this, you will have to ask your host to do it for you.

The 500 errors are generic.  By turning on asp errors, you will get the line number and possible issue.
0
 
Thomas GrassiSystems AdministratorAuthor Commented:
Scott

Thanks this is for IIS 7 and IIS 8

I am using IIS 6 and I found this
http://www.reedolsen.com/show-errors-for-classic-asp-pages-in-iis-6/

I do have that setting on

But I got the Submit button added and working sorta

Making progress Will post more later.
0
 
Thomas GrassiSystems AdministratorAuthor Commented:
Scoot Good new got the Page working now

Check it out

When you select the songs from the search output the new page created lists only the songs you check off

Now I need to convert that out to a URL so they can click on it to play it

any thoughts?
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
On http://www.tomsmp3.com/page2.asp I end up with

M:\Music\MP3MusicAlbums\Guess Who\Billboard Top 100 - 1970\02-Billboard Top 100 - 1970-03 No Sugar Tonight.mp3

You need a simple link http://www.w3schools.com/html/html_links.asp

<a href="M:\Music\MP3MusicAlbums\Guess Who\Billboard Top 100 - 1970\02-Billboard Top 100 - 1970-03 No Sugar Tonight.mp3">No Sugar Tonight</a>

Open in new window

0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Actually, the link has to be relative to your domain.

<a href="M:\Music\MP3MusicAlbums\Guess Who\Billboard Top 100 - 1970\02-Billboard Top 100 - 1970-03 No Sugar Tonight.mp3">No Sugar Tonight</a>

<a href="www.tomsmp3.com/folder/folder/something.mp3">Something</a>

Open in new window


You probably actually need to access the mp3 via file system object if it is outside of the domain. That would be another question though.
0
 
Thomas GrassiSystems AdministratorAuthor Commented:
Scott

Can not get the url to work in page2.asp

<%
if request.form<>"" then

strSongs=request.form("selectItem")
arraySongs=split(strSongs,",")
for each song in arraySongs
   response.write <a href="song&"> </a>
   next
else
response.write "You did not post any data yet<br>"
end if
%>
 <input type="button" value="BACK!"onClick="history.back();">

Open in new window


Any thoughts

Also I just saw your last post:

If you look at the results of page2.asp

It is in the correct format just need to make it a url output line.

Then I have a routine that will convert the path but I need the url created first.
0
 
Thomas GrassiSystems AdministratorAuthor Commented:
Scott,

Closing this going to open new one for the url issue

thanks
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
for each song in arraySongs
   response.write "<a href=""&song&"">"&song&"</a>"
next

Open in new window

0
 
Thomas GrassiSystems AdministratorAuthor Commented:
Scott,

Got the url but it is all on one line how do I break <br> the line between each entry

output looks like this
M:\Music\MP3MusicAlbums\ZZ Top\Eliminator\09-Eliminator-Dirty Dog.mp3 M:\Music\MP3MusicAlbums\ZZ Top\Eliminator\10-Eliminator-If I Could Only Flag Her Down.mp3 M:\Music\MP3MusicAlbums\ZZ Top\Eliminator\11-Eliminator-Bad Girl.mp3 M:\Music\MP3MusicAlbums\ZZ Top\Greatest Hits\01-Greatest Hits-Gimme All Your Lovin'.mp3

check the site out
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
for each song in arraySongs
   response.write "<a href=""&song&"">"&song&"</a><br>"
next

Open in new window


or

response.write "<ul>"
for each song in arraySongs
   response.write "<li><a href=""&song&"">"&song&"</a></li>"
next
response.write "</ul>"

Open in new window

0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
If you go the li method, add this to your css

li{list-style:none;}

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.