hello all my friend

i have on problem in result return by mysql in php my query is:

$sql="SELECT GROUP_CONCAT( '<tr><td>', `id` ,  '</td><td>', `titr` , '</td><td><input type=\"submit\" onmousedown=\"javafunc(', `id` , ');\" value=\"Edit it\" /></td></tr>'
ORDER BY `id` DESC
SEPARATOR '\n' ) AS 'allads'
FROM `ads` ";

the query is return only 8 rows form 45 rows and 8th row is incomplete and if add a html tag this result is lesser than for example SEPARATOR '\n' -> SEPARATOR '\n<br />' the result rows are 7 and i can't use solve this problem and i don't have use many work to server by split the query

please help me!

    ouch, how about this

    <?php
    $sql = "SELECT id, titr FROM ads ORDER BY id DESC  ";
    $result = mysql_query($sql);
    
    while ( $data = mysql_fetch_assoc($result) ){
    	$out .= '<tr><td>'.$data['id'].'</td><td>'.$data['titr'].'</td><td><input type="submit" onmousedown="javafunc('.$data['id'].');" value="Edit it" /></td></tr>';
    }
    echo $out;
    ?>

    build the output in a while loop in php, much easier to maintain and debug

      dagon;10966258 wrote:

      ouch, how about this

      <?php
      $sql = "SELECT id, titr FROM ads ORDER BY id DESC  ";
      $result = mysql_query($sql);
      
      while ( $data = mysql_fetch_assoc($result) ){
      	$out .= '<tr><td>'.$data['id'].'</td><td>'.$data['titr'].'</td><td><input type="submit" onmousedown="javafunc('.$data['id'].');" value="Edit it" /></td></tr>';
      }
      echo $out;
      ?>

      build the output in a while loop in php, much easier to maintain and debug

      tnx my friend i know much easier but your way is long and slow because when send query to MySQL select the rows of fields behind the scenes in MySQL data is mark by php request grouping rows and send to php and when use fetch split all in some steps write to document,

      but one way is very short i send all Html code in query and return Monolithic data and show this

      Is it really wise to use the first way?

        you can do it either way, but as yours wasn't working you have few debugging options where my way its far easier to debug, so has proved its usefulness.

          tnx for your answer

          if have to don't use my way i m use a way between them and way is :

          $sql="SELECT CONCAT( '<tr><td>', id , '</td><td>', titr , '</td><td><input type=\"submit\" onmousedown=\"javafunc(', id , ');\" value=\"Edit it\" /></td></tr>')
          AS 'allads'
          FROM ads
          ORDER BY id DESC ;";

          this is one split only by rows

          this way is very few difference by my way and i recommending to you use this way for optimum of system Resources .

          Good Luck

            for reference

            The result is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024. The value can be set higher, although the effective maximum length of the return value is constrained by the value of max_allowed_packet.

            http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat

            ergo poorer handling of large data than the standard method

              Write a Reply...