|
Posted by Funktopia on 11/16/05 20:37
It would be cool if you could post a few more details, especially of
the errors you're getting. What I gather from your post is that you
are having difficulties getting data out of the db and you're not
confident about how your example worked so here's an annotated typical
sample query
//first you connect and select the db
$link = mysql_connect($mysqlserverip, $mysqlusername, $mysqlpassword)
or die("Could not connect");
mysql_select_db($databasename, $link) or die("Could not select
".$databasename);
//then perform your query (your query looked OK xcept you may need to
areviews.artistid in the first list)
$result = mysql_query($query_byartist, $link) or die("Query failed
".$query_byartist);
//now you've got a result set you need to got thru each result. they
way this works can seem a little strange at first. each call to
mysql_fetch_assoc (or mysql_fetch_array etc.) returns the next result
if available or false otherwise
while ($row = mysql_fetch_assoc($result))
{
//now you have an array $row where the each item in the array
represents a field in the db record. For example, to print out the
title of the review you would write
echo $row["atitle"];
//Note that only the field name is used in the index (as opposed to
$row["areviews.atitle"]
}
//finally you should free up all the resources used. Obviously none of
us ever forget this ;-)
mysql_free_result($result);
mysql_close($link);
Hope i've interpreted your problem correctly and that this helps you
work it out.
[Back to original message]
|