2016-10-12 11 views
-2

여기 내가 echo $description, 나는 이것에서 하나의 단락 있어요. 50 단어 만 보여주고 싶습니다. 그 후, 더 많은 링크를 보여주고 싶습니다. 그리고 그들이 클릭 한 후에, 남은 단어를 보여주고 더 적은 버튼을 보여주고 싶습니다. 더 적은 링크 표시를 클릭하면 다시 50 단어 만 보여줍니다. 어떻게해야합니까?자세히보기 및 표시 덜 PHP에서 (아니 자바 스크립트)

<?php 
    $sql =mysql_query("SELECT desc_metearial FROM requirement_form WHERE status!='1'"); 
    while($row=mysql_fetch_assoc($sql)){ 
     ?> 

    <p class="comment more"> 
    <?php 
    echo $description= $row['desc_metearial'];// here i am got one paragraph 
    ?> 
    </p> 
    <?php 
    } 
?> 
+1

에서 버그를 발견 사람들은 Read more/less를 클릭한다. – Epodax

+0

jquery는 코드를 업데이트하는 데 어떻게 사용합니까? –

+0

2 페이지를 사용할 수 있습니까? 2 개는 긴 버전의 링크가있는 짧은 버전과 짧은 버전의 링크가있는 짧은 버전을 보여줍니다. 매우 쉬울 것입니다. – kerry

답변

0

질문 한 페이지 솔루션을 제공하기 위해 편집, 미안 또한 새로 고침/페이지마다 제출하려는 경우가 아니면 당신은 자바 스크립트 또는 jQuery를 필요로 이전 버전

onepagetext.php

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head> 

<body> 

<?php 
$full_string= 'Initially when my view loads, it should display the first question and answer. When press the next button I need to pass next value to the model and get the second question and answer, and if next button is clicked again it should display the third question and answer. The next button should be clickable until the last question appears. I have the following code:'; 

$legend = 'Show less'; 
$length= 'long'; 
if (isset($_POST['formsubmitted'])) { 
    if ($_POST["length"] == 'short'){ 
    echo $full_string; 
    $length = 'long'; 
    $legend = 'Show less'; 
    } 
    if ($_POST["length"] == 'long'){ 
     //echo $full_string; 
     $full_string_array = explode(' ', $full_string); 
     $short_string_array = array_slice($full_string_array, 0, 10); 
     $short_string = implode($short_string_array,' '); 
     echo $short_string;   
     $length = 'short'; 
     $legend = 'Show more'; 
    } 
} 
else { 
echo $full_string; 
} 
?> 
<form name="new user" method="post" action="onepagetext.php"> 
<input type="hidden" name="formsubmitted" value="TRUE"> 
<input type="hidden" name="length" value="<?php echo $length;?>"> 
<input type="submit" value="<?php echo $legend;?>"> 
</form> 
</body> 
</html> 
+0

@ 카니 연구 - 피드백? ...... – kerry

+0

당신은 2 파일이 필요하지 않습니다 - 2 파일은 낭비입니다. 1 개의 파일을 가지고 논리를'$ _GET' 식별자로 나눠서 길거나 짧은 텍스트를 표시하십시오. –

+0

@ ᵈˑᵈˑ 피드를 다시 보내 주셔서 감사합니다. 그 점에 대해서도 생각했습니다. 숨겨진 필드가있는 양식에 제출 버튼을 사용하는 것도 생각했습니다. 질문자의 지식이 상당히 기본적인 것처럼 보였으므로, 그가 수정할 수있는 완전한 솔루션을 제공하고자했습니다. 이상적인 솔루션이 아니라는 점에 동의하지만 완전한 솔루션입니다. – kerry