www.webdeveloper.com
Results 1 to 4 of 4

Thread: Problem With 'detail' link

  1. #1
    Join Date
    Nov 2013
    Posts
    1

    Smile Problem With 'detail' link

    Code:
    <?php
    //this is lat4.php
    //array(ID,Date,Time,Title,Explanation)
    $arr[0]=array(764,"11/11/2013","11:25","Accurate","The information must be true, 
    				verifiable, and not deceptive. accurate career information is based 
    				on empirical data can be validated by comparing sources or checking 
     				for internal consistency","Dr.Jonson");
    $arr[1]=array(765,"10/11/2013","11:15","Current","The information must be applicable 
    				 to the present time. keeping information current requires a process 
    				of eliminating the old and adding the new. while some types of 
    				information are more perishable than others. it is generally accepted 
    				that occupation and education information should be reviewed and updated 
    				at least annually to be current.","Prof.Dr.Herman");
    $arr[2]=array(766,"09/11/2013","08:34","Relevant","Relevant information applies to the
    				interests of the individuals who use it for the decisions they are facing. 
    				it should reduce a person's uncertainty about work and education while 
    				facilitating choice and planning. since we live and work in local labor","Mr.Shaid");
    ?>

    Code:
    <html>
    	<body>
    		<?php
    				include("lat4.php");
    				for($i=0;$i<count($arr);$i++){
    					$link="detail.php?id=".$arr[$i][0];
    					$artikel=substr($arr[$i][4],0,159);
    				
    		?>
    		<table border=1>
    			<tr>
    					<td></td>
    					<td width=300>
    					<?php
    					echo $arr[$i][1].",".$arr[$i][2]."<br>".$arr[$i][3];
    					?>
    					</td>
    			</tr>
    			<tr>
    					<td></td>
    					<td>
    					<?php 
    					echo $artikel."...";
    					echo "<a href='$link'>read more</a>";
    					<
    					?>
    					</td>
    			</tr>
    		</table>
    		<?php
    		}
    		?>
    	</body>
    
    </html>
    am newbie in web programming. i just wanna know how to code the 'read more' so i can show the remain text in new page. i have 3 array, but i dont want make 3 pages of HTML code to show the remain text, so i put ID to each array. but how to call them? wish somebody could help me..

  2. #2
    Join Date
    Nov 2013
    Posts
    3
    Just count the text of the variable, and limit it after 200 or so characters.
    Then your link can be to a full article of the same thing.

  3. #3
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,389
    Does it need to remain as a PHP solution?
    Would be easier if you can use a JS solution.

    Something along these lines...
    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    
    <title> Untitled </title>
    
    <script type="text/javascript">
    // this is lat4.php  format is: array(ID,Date,Time,Title,Explanation)
    var msgArray = [
       [764,"11/11/2013","11:25","Accurate",
        "The information must be true, verifiable, and not deceptive. ~~ Accurate career information is based "+
        "on empirical data can be validated by comparing sources or checking for internal consistency",
        "Dr.Jonson"],
       [765,"10/11/2013","11:15","Current",
        "The information must be applicable to the present time. ~~ Keeping information current requires a process "+
        "of eliminating the old and adding the new. while some types of information are more perishable than others. "+
        "it is generally accepted that occupation and education information should be reviewed and updated at least annually to be current.",
        "Prof.Dr.Herman"],
       [766,"09/11/2013","08:34","Relevant",
        "Relevant information applies to the interests of the individuals ~~ who use it for the decisions they are facing. "+
        "it should reduce a person's uncertainty about work and education while facilitating choice and planning. since we live and work in local labor",
        "Mr.Shaid"],
    ];
    </script>
    <style type="text/css">
     .RML { color:red; text-align:right; cursor:pointer; }
    </style>
    
    </head>
    <body>
    
    <table border=1>
     <tr>
      <td id="msgTitle0"></td>
      <td width=300>
       <span id="msgStart0"></span>
       <span id="msgRest0"></span>
       <div id="RML0" class="RML" onclick="toggleMsg(0)"> Read More </div>
      </td>
     </tr>
    
     <tr>
      <td id="msgTitle1"></td>
      <td width=300>
       <span id="msgStart1"></span>
       <span id="msgRest1"></span>
       <div id="RML1" class="RML" onclick="toggleMsg(1)" flag="true"> Read More </div>
      </td>
     </tr>
    
     <tr>
      <td id="msgTitle2"></td>
      <td width=300>
       <span id="msgStart2"></span>
       <span id="msgRest2"></span>
       <div id="RML2" class="RML" onclick="toggleMsg(2)"> Read More </div>
      </td>
     </tr>
    </table>
    
    <script type="text/javascript">
    function toggleMsg(N) {
      var CState = document.getElementById('msgRest'+N);
      if (CState.style.display != "inline") {
        CState.style.display = "inline";
        document.getElementById('RML'+N).innerHTML = 'Read Less';
      } else {
        CState.style.display = "none";
        document.getElementById('RML'+N).innerHTML = 'Read More';
      }
    }
    window.onload = function() {
      var tid, tmp; 
      var tarr = [];
      for (var i=0; i<msgArray.length; i++) {
        tid = 'msgTitle'+i;  document.getElementById(tid).innerHTML = msgArray[i][3];
        tmp = msgArray[i][4];
        tarr = tmp.split('~~ ');
        tid = 'msgStart'+i;  document.getElementById(tid).innerHTML = tarr[0];
        tid = 'msgRest'+i;  document.getElementById(tid).innerHTML = tarr[1]+'<p>Author: '+msgArray[i][5];
        document.getElementById(tid).style.display = 'none';
      }
    }
    </script>
    
    </body>
    </html>
    Last edited by JMRKER; 11-17-2013 at 08:00 PM.

  4. #4
    Join Date
    Mar 2012
    Posts
    1,639
    If I understand the problem correctly, then you do not need PHP or JS to do this. Just split the text into three blocks as follows:

    Code:
    <div style="width:800px;height:600px;">
    <p id="block1">
    blah, blah, blah...
    </p>
    <a href="#block2">continue...</a>
    
    <p id="block2">
    blah, blah, blah...
    </p>
    <a href="#block3">continue...</a>
    
    <p id="block3">
    blah, blah, blah...
    </p>
    <a href="#block1">go top...</a>
    </div>
    Or am I missing something???

    Note: This solution is not suitable for a responsive design, but you have specified three blocks, so I've assumed you are envisaging a classic static page with an arbitrary fixed width and height?
    Last edited by jedaisoul; 11-18-2013 at 02:42 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles