bateman Posted November 17, 2008 Share Posted November 17, 2008 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 More sharing options...
laPistola Posted November 17, 2008 Share Posted November 17, 2008 very easy to do but we need to see your code Link to comment https://forums.phpfreaks.com/topic/133070-solved-the-disappearing-bio/#findComment-692020 Share on other sites More sharing options...
bateman Posted November 17, 2008 Author Share Posted November 17, 2008 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> Link to comment https://forums.phpfreaks.com/topic/133070-solved-the-disappearing-bio/#findComment-692023 Share on other sites More sharing options...
The Little Guy Posted November 17, 2008 Share Posted November 17, 2008 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>'; } Link to comment https://forums.phpfreaks.com/topic/133070-solved-the-disappearing-bio/#findComment-692032 Share on other sites More sharing options...
bateman Posted November 17, 2008 Author Share Posted November 17, 2008 well it partially works. Looking to see if I can fix it on my own, thank you. If you want to see what it's doing click on the second link in my first post (showtmp) Link to comment https://forums.phpfreaks.com/topic/133070-solved-the-disappearing-bio/#findComment-692045 Share on other sites More sharing options...
The Little Guy Posted November 17, 2008 Share Posted November 17, 2008 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>'; Link to comment https://forums.phpfreaks.com/topic/133070-solved-the-disappearing-bio/#findComment-692052 Share on other sites More sharing options...
bateman Posted November 17, 2008 Author Share Posted November 17, 2008 I actually got it working without having to change all that. I'm simply gonna change my menu to include page &pg=1 (not hard with replace). Thank you for your help I did change it after I made this post and now I see why you said it. Thank you again. Link to comment https://forums.phpfreaks.com/topic/133070-solved-the-disappearing-bio/#findComment-692054 Share on other sites More sharing options...
The Little Guy Posted November 17, 2008 Share Posted November 17, 2008 Your Welcome. Link to comment https://forums.phpfreaks.com/topic/133070-solved-the-disappearing-bio/#findComment-692061 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.