Forum Moderators: coopster
I have about 13 Classes. and a page like this.
Class 1
Class 2
Class 3
etc.
Now I would like these classes to link to the quests that correspond to the class.
So I have many quests in my db. But all have a class in them but I can not figure out how to link them seeing as I have no unique id for the classes.
Also these two pages are coming from completely different db tables.
I have been trying something like this with no luck.
$results = mysql_query("SELECT * FROM nuke_quest_database where Class=$Class",$link);
then have the link look like this.
print "<b><a href=\"modules.php?name=Quest_Database&file=quest_class&Class=".$myrow['class']."\">".$myrow["class"]."</a></b>";
None of that worked for me so I am back to square one.
Any suggestions?
I never put my query into the mysql_query, I assign it to a variable and then use the variable with the query function like so
$query = "SELECT * FROM nuke_quest_database where Class=" . $Class;
$results = mysql_query($query);
This allows me to echo my query so I can see the constructed query and make sure there are no errors and can be done before I pass it to the query function like so
$query = "SELECT * FROM nuke_quest_database where Class=" . $Class;
echo "<p>query: ",$query;
die();
$results = mysql_query($query);
I also don't use the $link in mysql_query unless I have more than one open connection because the function assumes the last opened connection.
I am assuming that you used a variable with an uppercase like so $Class and that you are properly assigning the value to that variable.
So once we get the results from our query we can loop through them
while ($myrow = mysql_fetch_array($results)) {
echo '<b><a href="modules.php?name=Quest_Database&file=quest_class&Class=', $myrow['class'],'">', $myrow['class'], '</a></b>';
}
so we end up with this little chunk of code
$query = "SELECT * FROM nuke_quest_database where Class=" . $Class;
$results = mysql_query($query);
while ($myrow = mysql_fetch_array($results)) {
echo '<b><a href="modules.php?name=Quest_Database&file=quest_class&Class=', $myrow['class'],'">', $myrow['class'], '</a></b>';
}
assuming that all of the variables have matching cases, because I see some spots that might cause some problems, and all of your variables are being assigned properly along the way and that all of those fields are the right ones, that should work.