output not outputting correctly...

sublimer's picture

They have: 41 posts

Joined: Aug 2006

the first problem area is located at the recent videos section on

http://www.sublimestylee.com/site.php

it should say

Slightly Stoopid - Live at The Bohemian (Seattle Washington - 8/29/00)...
Slightly Stoopid - Live at The Ritz (North Carolina - 9/5/01)...

and the links for them should have a valid id value...

my query is...
$sql = "SELECT DISTINCT bootname FROM downloads WHERE filetype='boots' ORDER BY id DESC LIMIT 7";

if i change the above to
$sql = "SELECT * FROM downloads WHERE filetype='boots' ORDER BY id DESC LIMIT 7";

the output will display the band name followed by the boot name with the correct id on the link, but it displays all the songs in the boot where i just want it to display the boot itself to represent all the songs.

the other problem is on this page...
http://www.sublimestylee.com/pages/links.php

the first set of links are not generated, but the links under Bands on Sublime Stylee should be auto generated from the url's submitted when i add new files.

It recongizes that there should be two links one for the band Pepper and one for Slightly Stoopid by displaying the arrows but it won't output the band name or the band's url.

my query is...
$sql = "SELECT DISTINCT artisturl FROM downloads ORDER BY artist";

Thanks for the help!
-drew
:roll:

Busy's picture

He has: 6,151 posts

Joined: May 2001

I'm a little confused with 'boot', 'boots' and 'bootname'

When you say it should just display the 'boot' is that like artist or group?

The SELECT DISTINCT bootname and SELECT * are two very different queries, the first will list all the bootnames in bootname once (wont get duplicates of same name), where as the second will list everything where filetype='boots' (name, address, favorite drink ... whatever you have in the db rows).

Ok I think I get it, you have artist and boot (song title?) in different fields in your database, in which case you will need to do something like SELECT DISTINCT artist, bootname but then you'll still be missing the id etc as what you list is what you get. So you'll either have to do the works: SELECT DISTINCT id, artist, bootname (and whatever else you are using) but giving it to much could mess up how DISTINCT works so a JOIN might be easier. But to use a join you need to be using two rows

The above kind of makes sense to your first problem but doesn't relate to well with the second bit of the first, must be showing my age as I have no idea what the 'boot' is lol. Back in my day ... dang now i feel really old. Bring back the grammer phone Wink

You also have some issues with your output html, your including some files with html heading tags (html, head, title ..) which shouldn't be there, view source on the pages and see what I mean.

sublimer's picture

They have: 41 posts

Joined: Aug 2006

haha yea i know i have some random tags and all in there.

a boot is short for bootleg which is a live recording of a live show generally done by sneaking in a sound recording device.

i know the difference between my queries i just need to find a happy medium between the two.

if i do SELECT DISTINCT bootname, artist all it displays is a - if i remember correctly.

lets say this is my input for a new boot

Band 1 - Bootname - Songname 1 - id1
Band 1 - Bootname - Songname 2 - id2
Band 1 - Bootname - Songname 3 - id3
Band 1 - Bootname - Songname 4 - id4

the output on the homepage under recent boots should just be

Band 1 - Bootname

haha i just had a brainfart. i posted that at like 2 in the morning last night. i dont need the id, i just havent changed where the link goes to yet. so i dont care about its id on the homepage.

that means all i need is for it to display the artist name before the bootname. All i need is the artistname variable to work and im good!

heres my query code and my loop/display code...

<?php
$sql
= \"SELECT DISTINCT bootname FROM downloads WHERE filetype='boots' ORDER BY id DESC LIMIT 7\";

$result = mysql_query( $sql );
if (!
$result) {
  echo(\"<P>Error performing query: \" .
       mysql_error() . \"</P>\");
  exit();
}

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

    echo substr(\"<img src=\\"
http://www.sublimestylee.com/page_images/arrow.gif\\"><a href=\\"http://www.sublimestylee.com/pages/boots_list.php?artist=$artist&bootname=\" . $row[\"bootname\"] . \"\\">\" . $row[\"artistname\"] . \" - \" . $row[\"bootname\"] . \"\", 0, 243);
   
echo(\"...</a>&nbsp;<br>\");
}
?>

all i need is the artistname to work and it will display correctly and link correctly.

thanks
-drew

Busy's picture

He has: 6,151 posts

Joined: May 2001

Try something like:

SELECT artistname, DISTINCT bootname FROM ...

not sure if you can have it before the distinct or not, have never done it personally, worth a shot thou

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

Just a suggestion on a change on your code to output the links.

<?php
$dispLine
= $row['artistname'] . \" - \" . $row['bootname'];
   
if (strlen(
$dispLine)>65)
 
$dispLine = substr($dispLine,0,62) . \"...\";

echo \"<img src=\\"
http://www.sublimestylee.com/page_images/arrow.gif\\">\";
echo \"<a href=\\"http://www.sublimestylee.com/pages/boots_list.php?artist=$artist&bootname=\" . urlencode($row['bootname']) . \"\\">\";
echo $dispLine;
echo \
"</a>&nbsp;<br>\";
?>

The way you have the code, if you ever change the location/name of your arrow.gif image, or the url for the links, you have to update the length in the substr() call. The way I have it you can freely change those without affecting the display length.

Additionally, on the way you have it, the longer the "bootname" you have, the shorter text you will have displayed, this is becasue the bootname is part of the URL in your link, which pushes out where your displayed text starts. (actually, if you have a bootname that was over 88 charaters in length, you wouldn't see any text displayed at all.)

In my version, I used a length of 65 as the maximum characters to display. Note that my substr line allows for the three dots to be part of the maximum 65 displayed. Your code always showed the thre dots even if the full titles were displayed.

Lastly, I encoded the information that is being used in the link, just general good practice to do this.

Again, this is just a suggestion, your code will basically work fine, this is jsut a better method of cutting off long lines and making the code more readable and easier to manage.

-Greg

sublimer's picture

They have: 41 posts

Joined: Aug 2006

thanks alot! i was going to make it so the ... would only be displayed on those cut off, but you took it all one step further!

i will add the code right now!

thanks alot!
-drew

sublimer's picture

They have: 41 posts

Joined: Aug 2006

the code works great!

i just changed 2 of the variables because i posted them wrong by accident i.e. $artistname should have just been $artist which caused me to start this thread in the first place.

thanks again Greg K
-drew

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.