Jump to content

[SOLVED] The disappearing bio


bateman

Recommended Posts

I run a php driven site and for most things I get by on my own (no small thanks to the people at this site about 2 years ago). Anyways I'm trying to figure out how to make the text from the bio (which is pulled from the database) to disappear after the first page. If your not sure what I'm talking about go to http://celebdb.outerregion.net/show.php?id=82

 

An example of what I want is http://celebdb.outerregion.net/showtmp.php?id=82&pg=2 but with a link to expand the bio if they like.

Link to comment
https://forums.phpfreaks.com/topic/133070-solved-the-disappearing-bio/
Share on other sites

I've put in extra spaces here for ease of finding the code.

<html>  
<?php require_once('connections/local.php'); ?>
<?php
mysql_select_db($database_local, $local);
//if(isset($_REQUEST['id']))
{
$query = mysql_query("SELECT * FROM mixed WHERE id = \"$_GET[id]\"");
$row = mysql_fetch_assoc(mysql_query('SELECT * FROM `mixed`'));
$result = mysql_fetch_assoc($query);
// etc
{  
      

  
} }
?>
<head>
<title>Outerregion Celebrity Database Version 2</title>
<meta name="author" content="Earl Bateman">
<meta http-equiv="Content-Language" content="en" />
<meta name="description" content="Outerregion Celebrity Database is a recreation and expansion of Mikes Celebrity Picture Page which was closed down 2 years ago. Now with more then just pictures we include biographies, Birthdays, and in many cases full birth names."></head> 
<meta name="keywords" content="" />
<meta http-equiv="Expires" content="0" />
<meta name="Resource-Type" content="document" />
<meta name="Distribution" content="global" />
<meta name="Robots" content="index, follow" />
<meta name="Revisit-After" content="21 days" />
<meta name="Rating" content="general" /> 
<link rel="stylesheet" type="text/css" href="menu.css" media="screen" />  
</head>
<body bgcolor="#a3a9a9" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">

<!--Header-->
<table width=945 border=0 align=center cellpadding=0 cellspacing=0 summary="">
<tr>
	<td width=944 height=119 background="images/top.jpg"> </td>
</tr>
<tr>
	<td height=40 width=900 background="images/menu.jpg" align="right" valign=top><?php include("menu.php"); ?></td>
</tr>
<tr>
	<td background="images/content.jpg" align=center valign=middle>
        <table border="0" summary="" width="900">
<tr>
<td><table border="0" summary="">
<tr>
<td width="230"> <B><?= $result['Name']; ?></B></td>
<td>D.O.B.: <?= $result['dob']; ?>
<br>
</td>
<td>Height: <?= $result['Height']; ?></td></tr> 
<tr>




<td colspan="3"><hr color="c0c0c0">Bio:<br><?= $result['Bio']; ?></td></tr>
<tr>





<td colspan="5"><hr color="c0c0c0">Photos:<BR><?php include("$_GET[id]/gallery.php");?></td>	</tr>
</table></table>
        </td>
</tr>
<tr>
	<td width=944 height=44 background="images/bottom.jpg" align=center valign=middle colspan="3"><?php include("footer.php"); ?></td>
</tr>
</table>

</body>
</html>

This may work (untested):

 

function shortString($bio, $len = 100){
     $strs = explode(" ",$bio);
     $str = array();
     // Create shot bio
     for($i=0;$i<$len;$i++){
          $str[0] .= $strs[$i].' ';
     }
     // Create leftover bio
     for($j=$i;$j<count($strs)-$i;$j++){   // This line may need to be checked
          $str[1] .= $strs[$j].' ';
     }
     return $str;
}
if(!isset($_GET['pg']) || $_GET['pg'] < 2){
     // Display All Bio
}else{
     echo '<script type="text/javascript">
     function showMore(display){
          var dis = document.getElementById(\'more\');
          if(display == \'more\'){
               dis.style.display = \'block\';
          }else if(display == \'less\'){
               dis.style.display = \'none\';
          }
     }</script>';
     $strs = shortString($row['bio']);
     echo $strs[0];
     echo '<a href="javascript:showMore(\'more\');">Show More</a>';
     echo '<div id="more" style="display:none;">'.$strs[1].'</div>';
}

Replace the current JavaScript with this:

 

<script type="text/javascript">
function showMore(display){
     var dis = document.getElementById(\'more\');
     var full = document.getElementById(\'full\');
     if(display == \'more\'){
          dis.style.display = \'block\';
          full.href = "javascript:showMore(\'less\')";
     }else if(display == \'less\'){
          dis.style.display = \'none\';
          full.href = "javascript:showMore(\'more\')";
     }
     
}</script>

 

And change The Show More link to this:

 

echo '<a href="javascript:showMore(\'more\');" id="full">Show More</a>';

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.