0

I'm trying to get to grips with this create view thingy, but can't see it.

This creats my view

mysql_query("CREATE VIEW list AS 
   SELECT AlbumId,Title FROM album,
   LEFT JOIN artist ON album.artistId = artist.ArtistId ORDER BY album.Title")or die ("no dice pal   ".mysql_error());

that works, and creats it fine. But when I run the query

  <table class='tables' align='center' border='1'>
  <tr>
  <th>ID</th><th>Album</th><th>Artist</th>
  </tr>
  <?php
  mysql_set_charset('utf8');
  $list=mysql_query("SELECT * FROM list");
   while($row=mysql_fetch_array($list)){
   $alb=$row['AlbumId'];
   $title=$row['Title'];
   $art=$row['Name'];

  echo"<tr>
      <td>".$alb."</td><td>".$title."</td><td>".$art."</td>
      </tr>";
   }

?>
  </table>

the last column in the table 'Artist' is blank, what am I missing here guys, aside from a few million brain cells?

3
Contributors
3
Replies
16
Views
4 Years
Discussion Span
Last Post by TonyG_cyprus
1

There is no error except that you are not getting Name.So $row['Name'] is empty.

Change the above to this(i am assuming the field "artist name" as "Name" in Database).

mysql_query("CREATE VIEW list AS 
SELECT AlbumId,Title,Name FROM album, 
LEFT JOIN artist ON album.artistId = artist.ArtistId ORDER BY album.Title")or die ("no dice pal ".mysql_error());
0

Thanks guys, I know this is something I should have learnt long since, but I've been lazy.....

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.