What I am trying to figure out:
I want the npc_name to be linked to a detail page for each name with the url looking something like this:
http://www.url.com/link?=id1. I would prefer for the npc_id to generate in the url statement.
I have a page set up already to hold these results from the database called details.php
database npcsholds:
npc_id
npc_name
npc_loc
npc_level
npc_type
npc_realm
npc_sell
npc_quests
sub_name (for those who submit info)
main query will pull up:
npc_name
npc_loc
npc_level
npc_type
and here is the code for that page:
<?php
$dbh=mysql_connect ("localhost", "myname", "mypassword") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("mydb");
$sql = 'SELECT npc_name , npc_loc , npc_type , npc_level '
. ' FROM npcs '
. ' WHERE 1 '
. ' ORDER BY npc_name ASC LIMIT 0, 30';
$res = mysql_query($sql);
?>
<center><table width=100% border="1" cellpadding="1" cellspacing="1" bordercolorlight="064A33" bordercolordark="064A33" bordercolor="064A33">
<tr>
<td class=th align=center width=25%>Name</td>
<td class=th align=center width=25%>Location</td>
<td class=th align=center width=25%>Min/Max Level</td>
<td class=th align=center width=25%>Type</td>
</tr>
<?php
function myquery ($query) {
$result = mysql_query($query);
if (mysql_errno())
echo "MySQL error ".mysql_errno().": ".mysql_error()."\n<br>When executing:<br>\n$query\n<br>";
return $result;
}
while($npc = mysql_fetch_array($res)) {
$Name=$npc['npc_name'];
$Location=$npc['npc_loc'];
$Level=$npc['npc_level'];
$Type=$npc['npc_type'];
echo "
<TR>
<TD>.$npc['npc_name']."</TD>
<td><font size='1' face='Verdana, Arial, Helvetica, sans-serif'>".$npc['npc_loc']."</font></td>
<td><font size='1' face='Verdana, Arial, Helvetica, sans-serif'>".$npc['npc_level']."</font></td>
<td><font size='1' face='Verdana, Arial, Helvetica, sans-serif'>".$npc['npc_type']."</font></td>
</tr>";
}
?>
</table>
<?php
if ( $GET['results_per_page'] ) {
$results_per_page = $GET['results_per_page'];
} else {
$results_per_page = 30;
}
if ( $GET['offset'] ) {
$offset = $GET['offset'];
} else {
$offset = 0;
}
if ( $GET['total_results'] ) {
$total_results = $GET['total_results'];
} else {
$total_results = 100;
}
if ( $offset < $results_per_page ) {
echo 'Previous';
} else {
echo '<a href="'.$PHP_SELF.'?offset='.($offset-$results_per_page).'&total_results='.$total_results.'&results_per_page='.$results_per_page.'">Previous</a>';
}
for ( $start_result=0, $page=1; $start_result<$total_results; $start_result+=$results_per_page, $page++ ) {
if ( ($offset >= $start_result) && ( $offset < $start_result+$results_per_page ) ) {
echo '<b>'.$page.' <<</b>';
} else {
echo '<a href="'.$PHP_SELF.'?offset='.$start_result.'&total_results='.$total_results.'&results_per_page='.$results_per_page.'">'.$page.'</a>';
}
}
if ( $offset >= $total_results-$results_per_page ) {
echo 'Next';
} else {
echo '<a href="'.$PHP_SELF.'?offset='.($offset+$results_per_page).'&total_results='.$total_results.'">Next</a>';
}
?>
</div>