Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

drupal table with the edit link -


i have table in drupal displays content table. have added edit link each record . link should take user input form has values populated in corresponding record. right populating form last row.

for row x, need form populated values record x.

the table created

function _mymodule_sql_to_table($sql) {       $html = "";      // execute sql     $resource = db_query($sql);      // fetch database results in array     $results = array();     while ($row = db_fetch_array($resource)) {       $results[] = $row;       $email = $row['p1'];       $comment = $row['p2'];     }       // ensure results exist     if (!count($results)) {     $html .= "sorry, no results found.";     return $html;       }      // create array contain table rows     $rows = array();     // list of column headers     $columnnames = array_keys($results[0]);      // loop through results , create table rows     foreach ($results $key => $data) {        // create row data        $row = array(     'edit' => l(t('edit'),"admin/content/test/$p1/$p2/table1",     $options=array()),);        // loop through column names       foreach ($columnnames $c) {        $row[] = array(         'data' => $data[$c],         'class' => strtolower(str_replace(' ', '-', $c)),         );       }        // add row rows array       $rows[] = $row;       }      // loop through column names , create headers     $header = array();     foreach ($columnnames $c) {      $header[] = array(       'data' => $c,       'class' => strtolower(str_replace(' ', '-', $c)),       );     }      // generate table html     $html .= theme('table', $header, $rows);      return $html;    }     // can call in code...    function _mymodule_some_page_callback() {      $html = "";      $sql = "select * {contactus}";      $html .= _mymodule_sql_to_table($sql);      return $html;   }    function display(){     $results = array();  $html = "";     $resource  = db_query("select * contactus");  $output = '';  while($row = db_fetch_array($resource)){     $results[] = $row;  }  if(!count($results)){    $html.= "unable display table";    return $html;           }    $rows = array();    $columnnames = array_keys($results[0]);           foreach($results $key=>$data){        $row = array();       foreach($columnnames $c){        $row = array(       'data' => $data[$c],            'class' => strtolower(str_replace(' ', '-', $c)),     );     }     $rows[] = $row;  }  $header = array();  foreach($columnnames $c){  $header[] = array(       'data' => $c,       'class' => strtolower(str_replace(' ', '-', $c)),     );  }   $html .= theme('table', $header, $rows);      return $html; } 

you'll want have $rows = array(); appear before while loop. you're doing destroying array , redeclaring empty array on each pass. why last row appearing you.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -