Xtremer360 Posted September 26, 2010 Share Posted September 26, 2010 I decided to redo the individual roster page I have on my site and came up with this. <?php if(isset($_GET['username']) && $_GET['username'] != '') { $username = $_GET['username']; $query = "SELECT bio.username AS username, bio.charactername AS charactername, bio.id AS id, bio.style_id AS style FROM `efed_bio` AS bio ON bio.id = ebw.bio_id WHERE bio.username = '$username'"; if(!$result = mysql_query($query)) while ($row = mysql_fetch_assoc($result)) { $fieldarray=array('id','username','charactername','style'); foreach ($fieldarray as $fieldlabel) { if (isset($row[$fieldlabel])) { $$fieldlabel=$row[$fieldlabel]; $$fieldlabel=cleanquerydata($$fieldlabel); } } } } ?> <h1><?php echo $charactername; ?>'s Biography</h1> <?php echo getBioMenu($style,$username); ?> <? //If the GET page variable is biography, display the biography page if ($page == 'biography') { echo getBiopgrahy($style,$id); } //Or if the GET page variable is gallery, display the gallery page elseif ($page == 'gallery') { echo getGallery($style,$id); } //If the GET page variable is news, display the news page elseif ($page == 'news') { echo getNews($$id); } //If the GET page variable is segments, display the segments page elseif ($page == 'segments') { echo getBioSegments($id,S); } //If the GET page variable is matches, display the matches page elseif ($page == 'matches') { echo getBioSegments($id,M); } elseif ($page == 'chronology') { echo getChronology($id); } //Otherwise display the bio else { echo getBio($style,$id); } ?> The list of characters are listed here: http://kansasoutlawwrestling.com/roster An example of someone's individual roster page is located here: http://kansasoutlawwrestling.com/bio?username=oriel Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/ Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 Your query is hosed, you are using ON syntax (which is used for table JOINS) on a single table. Try taking out: ON bio.id = ebw.bio_id And see if it works. PS. getBioMenu() is not a function in your build. Make sure you have spelt the function name right. Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115708 Share on other sites More sharing options...
Xtremer360 Posted September 26, 2010 Author Share Posted September 26, 2010 Well that took care of that first issue now I have to figure out why its not returning the correct row. Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115709 Share on other sites More sharing options...
Xtremer360 Posted September 26, 2010 Author Share Posted September 26, 2010 Here's the function which is included through php in a different file with all my other functions. function getBioMenu() { ?> <div class="mwtabsdiv"> <a href="<? echo $siteurl; ?>/bio.php?username=<? echo $username; ?>" class="mwtabslink">Biography</a> <a href="<? echo $siteurl; ?>/bio.php?username=<? echo $username; ?>/gallery" class="mwtabslink">Gallery</a> <a href="<? echo $siteurl; ?>/bio.php?username=<? echo $username; ?>/news" class="mwtabslink">News</a> <a href="<? echo $siteurl; ?>/bio.php?username=<? echo $username; ?>/segments" class="mwtabslink">Segments</a> <a href="<? echo $siteurl; ?>/bio.php?username=<? echo $username; ?>/matches" class="mwtabslink">Matches</a> <a href="<? echo $siteurl; ?>/bio.php?username=<? echo $username; ?>/chronology" class="mwtabslink">Chronology</a> </div> <? } Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115711 Share on other sites More sharing options...
Xtremer360 Posted September 26, 2010 Author Share Posted September 26, 2010 Nevermind on the getBioMenu part that was figured out however I'm still having trouble figuring out why its not returning the same charactername. Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115715 Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 It seems that it is picking up getBioMenu() now. But not getHistory(); Nor $charactername,$type,$style,$page,$site_url, or $username. You need to make sure those variables are available to your page. Either through an include, or declaring. Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115716 Share on other sites More sharing options...
Xtremer360 Posted September 26, 2010 Author Share Posted September 26, 2010 I thought that's what the AS is for or for what I have in the fieldarray? Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115720 Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 Replace the top block with: <?php if(isset($_GET['username']) && $_GET['username'] != '') { $username = $_GET['username']; $query = "SELECT bio.username AS username, bio.charactername AS charactername, bio.id AS id, bio.style_id AS style FROM `efed_bio` AS bio ON bio.id = ebw.bio_id WHERE bio.username = '$username'"; $result = mysql_query($query); if(mysql_num_rows($result) > 0) { $row = mysql_fetch_assoc($result); $row = array_map('cleanquerydata',$row); extract($row); } ?> Un-tested, so make sure you make a backup of your current script. Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115726 Share on other sites More sharing options...
Xtremer360 Posted September 26, 2010 Author Share Posted September 26, 2010 Produced and unexpected end. Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115728 Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 Sorry, add an extra bracket ( } ) on the end of what I just gave you. Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115729 Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 Your query is failing Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115730 Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 Change your query to: $result = mysql_query($query) or die($query . '<br />' . mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115732 Share on other sites More sharing options...
Xtremer360 Posted September 26, 2010 Author Share Posted September 26, 2010 Yeah I was about to type that. I don't have any idea why it's failing. I passed it as a variable from the roster list and I have it grabbing the username but its not going anywhere after that for some reason. Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115733 Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 Your query should be: $query = "SELECT username, charactername, id, style_id AS style FROM `efed_bio` WHERE bio.username = '$username'"; Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115734 Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 sorry screwed up, typing fast. bio.username = '$username' should be username = '$username' (remove the bio. ) Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115736 Share on other sites More sharing options...
Xtremer360 Posted September 26, 2010 Author Share Posted September 26, 2010 I still don't know why I have those page notice errors though Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115737 Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 I noticed this: /If the GET page variable is biography, display the biography page So you need to define a page in your URL. Your function getBioMenu should look something like: function getBioMenu($siteurl,$username) { ?> <div class="mwtabsdiv"> <a href="<? echo $siteurl; ?>/bio.php?username=<? echo $username; ?>" class="mwtabslink">Biography</a> <a href="<? echo $siteurl; ?>/bio.php?page=gallery&username=<? echo $username; ?>/gallery" class="mwtabslink">Gallery</a> <a href="<? echo $siteurl; ?>/bio.php?page=news&username=<? echo $username; ?>/news" class="mwtabslink">News</a> <a href="<? echo $siteurl; ?>/bio.php?page=segments&username=<? echo $username; ?>/segments" class="mwtabslink">Segments</a> <a href="<? echo $siteurl; ?>/bio.php?page=matches&username=<? echo $username; ?>/matches" class="mwtabslink">Matches</a> <a href="<? echo $siteurl; ?>/bio.php?page=chronology&username=<? echo $username; ?>/chronology" class="mwtabslink">Chronology</a> </div> <? } Then change: <?php echo getBioMenu($style,$username); ?> //To: <?php echo getBioMenu('http://kansasoutlawwrestling.com',$username); ?> Then at the top of the page, put this line of code: $page = (isset($_GET['page'])) ? strip_tags($_GET['page']) : NULL; After all of that, check to make sure your getHistory() function is available to the script. As a last measure to help insure database integrity. $username = $_GET['username']; //Should be: $username = mysql_real_escape_string($_GET['username']); Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115741 Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 You are missing a bunch of functions that you are calling. You need to make sure that function list has a path to your script (with includes). Everything seems to be working up to a point. The getBioMenu function is still a little hosed, as it isn't accepting the username, and the path is a little off(as your site is using mod_rewrite). function getBioMenu($siteurl,$username) { ?> <div class="mwtabsdiv"> <a href="<? echo $siteurl; ?>/bio?username=<? echo $username; ?>" class="mwtabslink">Biography</a> <a href="<? echo $siteurl; ?>/bio?page=gallery&username=<? echo $username; ?>/gallery" class="mwtabslink">Gallery</a> <a href="<? echo $siteurl; ?>/bio?page=news&username=<? echo $username; ?>/news" class="mwtabslink">News</a> <a href="<? echo $siteurl; ?>/bio?page=segments&username=<? echo $username; ?>/segments" class="mwtabslink">Segments</a> <a href="<? echo $siteurl; ?>/bio?page=matches&username=<? echo $username; ?>/matches" class="mwtabslink">Matches</a> <a href="<? echo $siteurl; ?>/bio?page=chronology&username=<? echo $username; ?>/chronology" class="mwtabslink">Chronology</a> </div> <? } Your main script should look something like: <?php $page = (isset($_GET['page'])) ? strip_tags($_GET['page']) : NULL; if(isset($_GET['username']) && $_GET['username'] != '') { $username = mysql_real_escape_string($_GET['username']); $query = "SELECT username, charactername, id, style_id AS style FROM `efed_bio` WHERE bio.username = '$username'"; $result = mysql_query($query); if(mysql_num_rows($result) > 0) { $row = mysql_fetch_assoc($result); $row = array_map('cleanquerydata',$row); extract($row,EXTR_SKIP); } } ?> <h1><?php echo $charactername; ?>'s Biography</h1> <?php echo getBioMenu('http://kansasoutlawwrestling.com',$username); //***NOTE***Make sure the functions below Exist in the scope of this script: //If the GET page variable is biography, display the biography page switch($page) { case 'biography': echo getBiopgrahy($style,$id); break; case 'gallery': echo getGallery($style,$id); break; case 'news': echo getNews($$id); break; case 'segments': echo getBioSegments($id,S); break; case 'matches': echo getBioSegments($id,M); break; case 'chronology': echo getChronology($id); break; default: echo getBio($style,$id); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115751 Share on other sites More sharing options...
Xtremer360 Posted September 26, 2010 Author Share Posted September 26, 2010 So I can't have: <?php $page = (isset($_GET['page'])) ? strip_tags($_GET['page']) : NULL; if(isset($_GET['username']) && $_GET['username'] != '') { $username = $_GET['username']; $query = "SELECT bio.username AS username, bio.posername AS posername, bio.charactername AS charactername, bio.id AS id, bio.style_id AS style FROM `efed_bio` AS bio WHERE bio.username = '$username'"; $result = mysql_query($query); if(mysql_num_rows($result) > 0) { $row = mysql_fetch_assoc($result); $row = array_map('cleanquerydata',$row); extract($row); } } ?> <div id="bio"> <h1><?php echo $charactername; ?>'s Biography</h1> <?php echo getBioMenu($username); ?> <?php if(file_exists('images/fullshots/' . $posername . '.png')){ echo '<img class="fullshot" src="images/fullshots/' . $posername . '.png" />'; } else{ echo '<img class="fullshot" src="images/fullshots/default.png" />'; } ?> <? //Or if the GET page variable is gallery, display the gallery page if ($page == 'gallery') { echo getGallery($style,$id); } //If the GET page variable is news, display the news page elseif ($page == 'news') { echo getNews($$id); } //If the GET page variable is segments, display the segments page elseif ($page == 'segments') { echo getBioSegments($id,S); } //If the GET page variable is matches, display the matches page elseif ($page == 'matches') { echo getBioSegments($id,M); } elseif ($page == 'chronology') { echo getChronology($id); } //Otherwise display the bio else { echo getBio($style,$id); } ?> And here's the functions: function getBioMenu($username) { ?> <div class="mwtabsdiv"> <a href="/bio.php?username=<? echo $username; ?>" class="mwtabslink">Biography</a> <a href="/bio.php?page=gallery&username=<? echo $username; ?>" class="mwtabslink">Gallery</a> <a href="/bio.php?page=news&username=<? echo $username; ?>" class="mwtabslink">News</a> <a href="/bio.php?page=segments&username=<? echo $username; ?>" class="mwtabslink">Segments</a> <a href="/bio.php?page=matches&username=<? echo $username; ?>" class="mwtabslink">Matches</a> <a href="/bio.php?page=chronology&username=<? echo $username; ?>" class="mwtabslink">Chronology</a> </div> <? } function getBio($username) { $username=mysql_real_escape_string($username); ?> <h2>Personal</h2> <? if ($style=='singles') { ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowa"> <td class="biotableheadingb">Nicknames:</td> <td class="biotabledatab"><?php if (strlen ($nicknames) < 1) { print "N/A"; } else { print "$nicknames";}?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">Height:</td> <td class="biotabledatab"><?php echo $height; ?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Weight:</td> <td class="biotabledatab"><?php echo $weight; ?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">Hometown:</td> <td class="biotabledatab"><?php echo $hometown; ?></td> </tr> </table> <? } ?> <? if ($style=='tagteam') { ?> <? } ?> <? if ($style=='manager') { ?> <? } ?> <? if ($style=='referee') { ?> <? } ?> <? if ($style=='staff') { ?> <? } ?> <? if ($style=='stable') { ?> <? } ?> <h2>History</h2> <? echo getHistory($id); ?> <h2>Quotes</h2> <? echo getQuotes($id); ?> <h2>Wrestling</h2> <? echo getWrestling($id); ?> </div> <? } function getGallery($id) { $id=mysql_real_escape_string($id); ?> <table class="biotable" cellspacing="0px"> <tr class="biotablerowa"> <td class="biotableheadingb">Headshot Image</td> <td class="biotabledatab"><?php if(file_exists('images/headshots/' . $posername . '.jpg')){ echo '<img src="/backstage/images/headshots/' . $posername . '.jpg" alt="" />'; } else { echo 'No Image Uploaded'; } ?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Roleplay Image</td> <td class="biotabledatab"><?php if(file_exists('images/lp/' . $posername . '.jpg')){ echo '<img src="/backstage/images/lp/' . $posername . '.jpg" alt="" />'; } else { echo 'No Image Uploaded'; } ?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">Titantron Image</td> <td class="biotabledatab"><?php if(file_exists('images/titantron/' . $posername . '.jpg')){ echo '<img src="/backstage/images/titantron/' . $posername . '.jpg" alt="" />'; } else { echo 'No Image Uploaded'; } ?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Champion Image</td> <td class="biotabledatab"><?php if(file_exists('images/champions/' . $posername . '.jpg')){ echo '<img src="/backstage/images/champions/' . $posername . '.jpg" alt="" />'; } else { echo 'No Image Uploaded'; } ?></td> </tr> </table> <?php } function getHistory($id) { $id=mysql_real_escape_string($id); ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowb"> <td class="biotableheadingb">KOW Titles:</td> <td class="biotabledatab"><?php if (strlen ($kowtitles) < 1) { print "N/A"; } else { print "$kowtitles";}?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">KOW Awards:</td> <td class="biotabledatab"><?php if (strlen ($kowawards) < 1) { print "N/A"; } else { print "$kowawards";}?></td> </tr> </table> <?php } function getQuotes($id) { $id=mysql_real_escape_string($id); ?> <ul id="quotes"> <?php if(count($quotes) > 0){ for($i = 0; $i < count($quotes); $i++){ echo "<li>".$quotes[$i]."</li>"; } } else{ echo '<li>This wrestler has no quotes.</li>'; } ?> </ul> <?php } function getWrestling($id) { $id=mysql_real_escape_string($id); ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowb"> <td class="biotableheadingb">Manager/Valet:</td> <td class="biotabledatab"><?php if (strlen ($manager) < 1) { print "N/A"; } else { print "$manager";}?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Finisher:</td> <td class="biotabledatab"><?php if (strlen ($finisher) < 1) { print "N/A"; } else { print "$finisher";}?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Setup:</td> <td class="biotabledatab"><?php if (strlen ($setup) < 1) { print "N/A"; } else { print "$setup";}?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Entrance Music:</td> <td class="biotabledatab"><?php if (strlen ($music) < 1) { print "N/A"; } else { print "$music";}?></td> </tr> </table> <?php } Problem is after it gets the username in the getBio function I need to take that username and match it up in the db table and see what style it is. Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115754 Share on other sites More sharing options...
Xtremer360 Posted September 26, 2010 Author Share Posted September 26, 2010 http://kansasoutlawwrestling.com/bio?username=cruz Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115755 Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 OK, all looks like it is on the right track. 1. remove ".php" from all the links in the getBioMenu() function. 2. All variables that are in functions, must have them passed to the function through an argument, by declaring them inside the function, or by declaring them global, http://www.php.net/manual/en/language.functions.php 3. Alot of the functions have only one argument, yet you are passing them two arguments. At this point, I think your page is OK, you need to work on the functions. Problem is after it gets the username in the getBio function I need to take that username and match it up in the db table and see what style it is. Or, you could just pass the variable $row as an argument to getBio() as it contains the data from the user you are looking at currently. If you set your query as: $query = "SELECT * FROM `efed_bio` AS bio WHERE bio.username = '$username'"; Then you will get everything from that user, putting it to the functions as the full array($row), you can extract it inside the function, and have all of your variables that you need to work with. EX: function getBio($arr) { echo 'My style is ' . $arr['style']; //or extract($arr); echo 'My style is ' . $style; } //calling the function: getBio($row); I hope that makes sense to you. Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115760 Share on other sites More sharing options...
Xtremer360 Posted September 26, 2010 Author Share Posted September 26, 2010 Well I changed the .php issue in the links and changed the getBio function to have $row and it went to heck after that. So basically it all stems off that initial query which I need to include styles.name and have an Inner/Left Join I still don't understand the difference so that bio.styles.id = styles.id. Also need to add to the query that some of the data comes from the efed_list_styles table. Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115780 Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 Post your database table structures for those two tables. I'll get the query sorted out, and re-write the getBio function for you. Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115831 Share on other sites More sharing options...
Xtremer360 Posted September 26, 2010 Author Share Posted September 26, 2010 efed_list_styles Table- id, name efed_bio Table- id, charactername, username, posername, style_id Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115849 Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 How are you getting: $nickname, $height, $weight,$hometown? Quote Link to comment https://forums.phpfreaks.com/topic/214403-not-showing-anything/#findComment-1115957 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.