It is probably a screw up on my part in the code but I dont see where or get why. Maybe a more awake set of eyes can help out...

First part pulls up fine thanks to a bit of help from people here.

main.php

include('connect.php');

$result = mysql_query("SELECT art_name , art_id FROM artist WHERE 1 ORDER BY art_name ASC");

if ($result)
{
  for ($i=0; $i < mysql_num_rows($result); $i +=2)
  {
    $row = mysql_fetch_array($result);
    echo "<tr>";
    echo "<td align=center><a href='details.php?id=". $row['art_id']."' target='main'>" . $row['art_name'] . "</a></td>";
    if ((mysql_num_rows($result) % 2) == 0)
    {
      $row = mysql_fetch_array($result);
      echo "<td align=center><a href='details.php?id=". $row['art_id']."' target='main'>" . $row['art_name'] . "</a></td>";
    }
    echo "</tr>";
  }
}

details.php (this is the query pulling up empty)

include('../connect.php');

$id = $_GET['art_id'];

$sql = mysql_query("SELECT track.*, artist.* , album.* FROM track , artist, album WHERE artist.art_id = album.art_id AND album.art_id = track.art_id AND id ='$id'");
if (!$result = mysql_query($sql)) {    
print "Invalid query ($sql) : " . mysql_error();
exit;
}
while($row = mysql_fetch_array($sql)) { echo "<tr>"; echo "<td align=center>" . $row['alb_name'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align=center>" . $row['alb_year'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align=center>" . $row['track_title'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align=center>" . $row['track_volume'] . "</td>"; echo "</tr>"; }

I also did it this way and pulled up the same error

include('../connect.php');

$id = $_GET['art_id'];

$sql = mysql_query("SELECT track.*, artist.* , album.* FROM track , artist, album WHERE id ='$id'");
if (!$result = mysql_query($sql)) {    
print "Invalid query ($sql) : " . mysql_error();
exit;
}
while($row = mysql_fetch_array($sql)) { echo "<tr>"; echo "<td align=center>" . $row['alb_name'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align=center>" . $row['alb_year'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align=center>" . $row['track_title'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align=center>" . $row['track_volume'] . "</td>"; echo "</tr>"; }

    $sql = mysql_query("SELECT track., artist. , album.* FROM track , artist, album WHERE artist.art_id = album.art_id AND album.art_id = track.art_id AND id ='$id'");
    if (!$result = mysql_query($sql))

    Take a look at this:
    mysql_query($sql)) is the same as
    mysql_query(mysql_query("SELECT ..."))

    Instead of if (!$result = mysql_query($sql))
    use mysql_num_rows when got a select statement.
    if (mysql_num_rows($result) > 0)

    Use [MAN]mysql_affected_rows/MAN when you use INSERT UPDATE and DELETE

      changed code to this on the details.php
      pulls up this error:

      Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/designo/public_html/musiclib/test/details.php on line 15

      $id = $_GET['art_id'];
      include('connect.php'); 
      
      
      $sql = mysql_query("SELECT track.*, artist.* , album.* FROM track , artist, album WHERE artist.art_id = album.art_id AND album.art_id = track.art_id AND id ='$id'");
      
      <!-- Line 15 is the following line -->
      if (mysql_num_rows($result) > 0) 
      while($row = mysql_fetch_array($result)) { 
      echo "<tr>";
          echo "<td align=center>" . $row['alb_name'] . "</td>";
          echo "</tr>";
          echo "<tr>";
          echo "<td align=center>" . $row['alb_year'] . "</td>";
          echo "</tr>";
          echo "<tr>";
          echo "<td align=center>" . $row['track_title'] . "</td>";
          echo "</tr>";
          echo "<tr>";
          echo "<td align=center>" . $row['track_volume'] . "</td>";
          echo "</tr>";
        }
      

      Will check back on this a bit later, as for now I need some much needed zzzz's. This project is pushing me to throw my hands up and say screw it. (least til I learn better php skills)

        Insert:
        echo mysql_error();
        after: $sql = ...
        to see what causing the error.

          this is the error I am getting after adding the
          echo mysql_error();

          Unknown column 'id' in 'where clause'
          Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/designo/public_html/musiclib/test/details.php on line 17

          I gather in my code I need to change id but I am not sure what to change it to.

          How this is pulling is via the art_id, which leads to the albums of said artist and what tracks are on the albums.

          Line 17

          if (mysql_num_rows($result) > 0) 

            $sql = mysql_query("SELECT track., artist. , album.* FROM track , artist, album WHERE artist.art_id = album.art_id AND album.art_id = track.art_id AND id ='$id'");

            It's the id that causing the problem, that field don't exist.

              Would it be
              art_name instead of ID since that is what the art_id relates to?

                4 days later

                Ok, I finally got the details page to pull up with the info I am asking it to retrieve. Now the problem is it is adding them about 20 times a piece, ie...

                Track Title - Track Time - Volume
                Track Title - Track Time - Volume
                Track Title - Track Time - Volume
                Track Title - Track Time - Volume
                Track Title 2 - Track Time - Volume
                Track Title 2 - Track Time - Volume
                Track Title 2 - Track Time - Volume
                Track Title 2 - Track Time - Volume

                so on and so forth.. pretty sure that gives the jest of the problem so onto the code.

                details.php

                $id = $_GET['art_id'];
                include('connect.php'); 
                
                
                $result = mysql_query("SELECT track.*, artist.* FROM track , artist WHERE 1 AND track.art_id='$id' ORDER BY track_title ASC");
                echo mysql_error(); 
                
                if (mysql_num_rows($result)) 
                while($row = mysql_fetch_array($result)) { 
                echo "<table width=100% class=outside>";
                    echo "<tr>";
                    echo "<td>" . $row['track_title'] . " (" . $row['track_time'] . ")</td>";
                    echo "<td align=right>" . $row['track_volume'] . "</td>";
                    echo "</tr>";
                echo "</table>";
                  }

                Thanks ahead of time for any help given.

                  Write a Reply...