adding data to a database with PHP

Associate
Joined
6 Mar 2009
Posts
495
Im trying to add some data to a database and cant seem to get it to work. Here is what i have so far. Any suggestions or advice please??

//are we adding a new track to the 'selected tracks' list
if (isset($_GET["action"]) && $_GET["action"]=="addTrack") {
$trackID=$_GET["trackID"];

INSERT INTO selectedtracks VALUES(trackID);

$dbQuery ="select id, trackID from selectedtracks";
$dbResult=mysql_query($dbQuery);
echo mysql_num_rows($dbResult)."\n";}
 
Ok thanks. Got a little further now but getting another error. Error at this line - $dbResult=mysql_query($dbquery); saying that $dbResult is undefined!!

$dbQuery="insert into selectedtracks values (null , $trackID)";
$dbDisplayResult=mysql_query($dbQuery);

// now retrieve the artist name and song title for every entry in the
// selectedTracks table. Return the tracks/artists in an
// unordered list with a suitable heading e.g.

$dbQuery="SELECT tracks.title, artists.name
from tracks, artists, selectedtracks
where selectedtracks.trackid=tracks.id
and tracks.artistid=artists.id";

$dbResult=mysql_query($dbquery);
while ($dbRow=mysql_fetch_array($dbResult)) {
echo "<ul>".$dbRow["title"]."^".$dbRow["name"]."\n </ul>";
}
 
Back
Top Bottom