Greaser9780 Posted February 17, 2007 Share Posted February 17, 2007 <? session_start(); include('db.php'); $clan_id=$_GET['clan_id']; $sql = "SELECT clan_name, wins, losses, logo, message, clan_id FROM bhdsingle where clan_id = '$clan_id'"; $res = mysql_query($sql) or die(mysql_error()); while($r=mysql_fetch_array($res)) { //getting each variable from the table $clan_name=$r["clan_name"]; $message=$r["message"]; $logo=$r["logo"]; $wins=$r["wins"]; $losses=$r["losses"]; echo "$clan_name"; } ?> Why does it not echo? Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 17, 2007 Share Posted February 17, 2007 The recordset is empty? Try adding "echo mysql_num_rows($res);" just before the while loop. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 17, 2007 Share Posted February 17, 2007 Are you sure you are retrieving at least one row? Put in some debug statements: <?php session_start(); include('db.php'); $clan_id=$_GET['clan_id']; $sql = "SELECT clan_name, wins, losses, logo, message, clan_id FROM bhdsingle where clan_id = '$clan_id'"; echo '<pre>$sql = ' . $sql . '</pre>' ; //debug $res = mysql_query($sql) or die(mysql_error()); echo 'Number of rows found: ' . mysql_num_rows($res) . '<br>'; //debug while($r=mysql_fetch_assoc($res)) { echo '<pre>$r: ' . print_r($r,true) . '</pre>'; //debug //getting each variable from the table $clan_name=$r["clan_name"]; $message=$r["message"]; $logo=$r["logo"]; $wins=$r["wins"]; $losses=$r["losses"]; echo $clan_name . '<br>'; } ?> Ken Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Author Share Posted February 17, 2007 I got the following: $sql = SELECT clan_name, wins, losses, logo, message, clan_id FROM bhdsingle where clan_id = '' Number of rows found: 0 Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 17, 2007 Share Posted February 17, 2007 Well, there's your problem. Clan ID is not getting passed to the page. At least not through $_GET['clan_id'] Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Author Share Posted February 17, 2007 How do I fix that? I am fresh to dynamic links. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Author Share Posted February 17, 2007 Here is the code for my link: <a href=\"stats.php?id=".$row['clan_id']."\">".$row["clan_name"]."</a> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 17, 2007 Share Posted February 17, 2007 The script receives the clan_id in the URL parameter "id", not "clan_id", so use: <?php $clan_id=$_GET['id']; ?> Ken Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Author Share Posted February 17, 2007 That was the ticket. I figured I was supposed to plug in my type of ID. TYVM Mr.SUPER cool guru guy. Any clues on where I can find more info on this type of thing. Going to be doing alot of these. Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 17, 2007 Share Posted February 17, 2007 I would suggest sticking to "clan_id" and changing your link to match since it is more specific. You can find all the information you need at www.php.net or in the many tutorials offered here and other places online. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.