what i have is a table for songs, in the table is a field with an artist id,
i also have an artist table, with an artist name and an id,
what would be the best way to get the artist name displayed, in a getall_song function, if you guys need any code or extra info let me know,
here is the getall_song() function
Code
extract($args);
if (!isset($startnum) || !is_numeric($startnum)) {
$startnum = 1;
}
if (!isset($numsongs) || !is_numeric($startnum)) {
$numsongs = -1;
}
$items = array();
if (!pnSecAuthAction(0, 'RiddimDB::', '::', ACCESS_OVERVIEW)) {
return $items;
}
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
$songtable = $pntable['riddimdb_song'];
$songcolumn = &$pntable['riddimdb_song_column'];
$artisttable = $pntable['riddimdb_artist'];
$artistcolumn = &$pntable['riddimdb_artist_column'];
$sql = "SELECT $songcolumn[sid],
$songcolumn[rid],
$songcolumn[aid],
$songcolumn[pid],
$songcolumn[cid],
$songcolumn[sname],
$songcolumn[lyric],
$songcolumn[album],
$songcolumn[year],
$songcolumn[label]
FROM $songtable
ORDER BY $songcolumn[sname]";
$result = $dbconn->SelectLimit($sql, $numsongs, $startnum-1);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _GETFAILED);
return false;
}
for (; !$result->EOF; $result->MoveNext()) {
list($sid, $rid, $aid, $pid, $cid, $sname, $lyric, $album, $year, $label) = $result->fields;
if (pnSecAuthAction(0, 'RiddimDB::', "$sname::$sid", ACCESS_OVERVIEW)) {
$items[] = array('sid' => $sid,
'rid' => $rid,
'aid' => $aid,
'pid' => $pid,
'cid' => $cid,
'sname' => $sname,
'lyric' => $lyric,
'album' => $album,
'year' => $year,
'label' => $label);
}
}
$result->Close();
return $items;
if (!isset($startnum) || !is_numeric($startnum)) {
$startnum = 1;
}
if (!isset($numsongs) || !is_numeric($startnum)) {
$numsongs = -1;
}
$items = array();
if (!pnSecAuthAction(0, 'RiddimDB::', '::', ACCESS_OVERVIEW)) {
return $items;
}
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
$songtable = $pntable['riddimdb_song'];
$songcolumn = &$pntable['riddimdb_song_column'];
$artisttable = $pntable['riddimdb_artist'];
$artistcolumn = &$pntable['riddimdb_artist_column'];
$sql = "SELECT $songcolumn[sid],
$songcolumn[rid],
$songcolumn[aid],
$songcolumn[pid],
$songcolumn[cid],
$songcolumn[sname],
$songcolumn[lyric],
$songcolumn[album],
$songcolumn[year],
$songcolumn[label]
FROM $songtable
ORDER BY $songcolumn[sname]";
$result = $dbconn->SelectLimit($sql, $numsongs, $startnum-1);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _GETFAILED);
return false;
}
for (; !$result->EOF; $result->MoveNext()) {
list($sid, $rid, $aid, $pid, $cid, $sname, $lyric, $album, $year, $label) = $result->fields;
if (pnSecAuthAction(0, 'RiddimDB::', "$sname::$sid", ACCESS_OVERVIEW)) {
$items[] = array('sid' => $sid,
'rid' => $rid,
'aid' => $aid,
'pid' => $pid,
'cid' => $cid,
'sname' => $sname,
'lyric' => $lyric,
'album' => $album,
'year' => $year,
'label' => $label);
}
}
$result->Close();
return $items;
