Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/214403-not-showing-anything/
Share on other sites

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.

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>
<?
}

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.

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.

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']);

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);
}
?>

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.

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.