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? Link to comment https://forums.phpfreaks.com/topic/38919-solved-brain-fart-here-help/ 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. Link to comment https://forums.phpfreaks.com/topic/38919-solved-brain-fart-here-help/#findComment-187164 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 Link to comment https://forums.phpfreaks.com/topic/38919-solved-brain-fart-here-help/#findComment-187166 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 Link to comment https://forums.phpfreaks.com/topic/38919-solved-brain-fart-here-help/#findComment-187172 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'] Link to comment https://forums.phpfreaks.com/topic/38919-solved-brain-fart-here-help/#findComment-187174 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. Link to comment https://forums.phpfreaks.com/topic/38919-solved-brain-fart-here-help/#findComment-187175 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> Link to comment https://forums.phpfreaks.com/topic/38919-solved-brain-fart-here-help/#findComment-187178 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 Link to comment https://forums.phpfreaks.com/topic/38919-solved-brain-fart-here-help/#findComment-187180 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. Link to comment https://forums.phpfreaks.com/topic/38919-solved-brain-fart-here-help/#findComment-187182 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. Link to comment https://forums.phpfreaks.com/topic/38919-solved-brain-fart-here-help/#findComment-187280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.