0

Rightnow i am facing a problem of print Long Text. In my database i have data in long text format and that field has around 2000 line of text so how can i print that.

I am giving here full code of my file please go through it and try to solve my problem

<?php
if($objConnect = mysql_connect("localhost","root","")){
$objDB = mysql_select_db("android");
    $from_date=$_GET['from_date'];
    $to_date=$_GET['to_date'];
    $time = strtotime($from_date);
    $time1 = strtotime($to_date);
    $fdate = date( 'Y-m-d', $time );
    $todate = date( 'Y-m-d', $time1 );
    $tmpdate="";
    $time2 = strtotime($tmpdate);
    $tempdate = date( 'Y-m-d', $time2 );
    if($fdate==$tempdate){
    echo "if block";
        $strSQL = "SELECT LessonText FROM lesson_details ";/*Here this field LessonText is Long Text*/
        $objQuery = mysql_query($strSQL);
        $intNumField = mysql_num_fields($objQuery);
        $resultArray = array();
        while($obResult = mysql_fetch_array($objQuery)){
            $arrCol = array();
            for($i=0;$i<$intNumField;$i++){
                $arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
            }
        array_push($resultArray,$arrCol);
        }
        $Jdata=(json_encode(array('lessons:'=>$resultArray)));
        if($Jdata!=""){
            $error_code=0;
            $error_massage="Success";
            $Result=array(array('Lesson_details:'=>$resultArray),array('error_code:'=>$error_code,'error_massage:'=>$error_massage));
            echo json_encode($Result);
        }
        else{
            echo "Else Block";
            $error_code=1;
            $error_massage="No Record Found";
            $Result=array(array('Lesson_details:'=>$resultArray),array('error_code:'=>$error_code),array('error_massage:'=>$error_massage));
            echo json_encode($Result);
        }               
    }
    elseif($fdate!="1970-01-01" && $todate!="1970-01-01"){
        $strSQL = "SELECT * FROM lesson_details WHERE UpdatedDate>='$fdate' &&UpdatedDate<='$todate'";
        $objQuery = mysql_query($strSQL);
        $intNumField = mysql_num_fields($objQuery);
        $resultArray = array();
        while($obResult = mysql_fetch_array($objQuery)){
            $arrCol = array();
            for($i=0;$i<$intNumField;$i++){
                $arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
            }
            array_push($resultArray,$arrCol);
        }
        $Jdata=(json_encode(array('lessons:'=>$resultArray)));
        if($Jdata!=""){
            $error_code=0;
            $error_massage="Success";
            $Result=array(array('Lesson_details:'=>$resultArray),array('error_code:'=>$error_code,'error_massage:'=>$error_massage));
            echo json_encode($Result);
        }
        else{
            echo "Else Block";
            $error_code=1;
            $error_massage="No Record Found";
            $Result=array(array('Lesson_details:'=>$resultArray),array('error_code:'=>$error_code),array('error_massage:'=>$error_massage));
            echo json_encode($Result);
        }       
    }
    else{
        $strSQL = "SELECT * FROM lesson_details WHERE UpdatedDate>='$fdate'";
        $objQuery = mysql_query($strSQL);
        $intNumField = mysql_num_fields($objQuery);
        $resultArray = array();
        while($obResult = mysql_fetch_array($objQuery)){
            $arrCol = array();
            for($i=0;$i<$intNumField;$i++){
                $arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
            }
            array_push($resultArray,$arrCol);
        }
        $Jdata=json_encode($resultArray);
        $Jdata=(json_encode(array('lessons:'=>$resultArray)));
        if($Jdata!=""){
            $error_code=0;
            $error_massage="Success";
            $Result=array(array('Lesson_details:'=>$resultArray),array('error_code:'=>$error_code,'error_massage:'=>$error_massage));
            echo json_encode($Result);
        }
        else{
            echo "Else Block";
            $error_code=1;
            $error_massage="No Record Found";
            $Result=array(array('Lesson_details:'=>$resultArray),array('error_code:'=>$error_code),array('error_massage:'=>$error_massage));
            echo json_encode($Result);
        }       
    }
}
else{
    $error=array("ErrCode"=>2,"ErrMsg"=>"Database connection error");
    echo (json_encode($error));
}
?>

Edited by pritaeas: Moved.

5
Contributors
10
Replies
41
Views
4 Years
Discussion Span
Last Post by broj1
Featured Replies
0

The problem with your question is that, you haven't realy explain what realy happened in the code you posted. The code looks unclear.

0

Your question is not very clear about what exactly is the problem.

Is the text html? To display html use htmlspecialchars function which will safely display problematic characters (such as < and >). If you have different character sets use mb_encode_numericentity function instead.

If the text is plain text your only option for formatting is existence of escape sequences \t, \r, \n and some others.

The other thing you have to be careful is to not run out of memory on your server.

Edited by broj1

0

problem is that i want to print long text but through this code i can print only 10 lines of character and if i print some html tags in that then output is null

0

Have you tried the htmlspecialchar function? Do you have any unescaped quotes in the text? Is it a html text? And why are you using two nicks?

Edited by broj1

0

Sometime in my case it is the problem of utf8 encoding. so i have add following line below my select query
mysql_query('SET CHARACTER SET utf8');

0

so i have add following line below my select query mysql_query('SET CHARACTER SET utf8');

It is actually a good piece of information for other people with similar problems. Please mark as solved (using the nick that opened the thread).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.