javascript - How to get PHP array from Database Field -


i want store items field php array.

  • the database ".accdb" file
  • the connection database through php's odbc functions

this table i've been using test code (its name "posts1"):
enter image description here

this latest version of php code, returns 1 result.

<?php     $dbname = $_server["document_root"] . "/project6/phptest/sampleusers.accdb";     $connection = odbc_pconnect("driver={microsoft access driver (*.mdb, *.accdb)};dbq=" .$dbname, ";", ";");     if ($connection != true){ exit; };     $query_string = "select body posts1";     $results = odbc_exec ( $connection , $query_string);     $output = odbc_result($results, 1);     odbc_close ( $connection );     echo $output; ?> 

if change index of result i'm trying access, code won't work.
ex: $output = odbc_result($results, 2);
if did work, planned create loop transfer items array.

before this, tried using fetch_array not make work. difficult because using json communicate array between client , server, have no experience with.

the web side got here, literally copy , paste. website link , div: when link clicked, javascript sends off request php. div updated based on php echos.

i'm hoping guidance, i'm new web development.

edit
i've made working version now, makes use of odbc_fetch_array instead of odbc_result. other answers still appreciated, if offer improvement i'll accept them.

$output = array(); ($value = array_pop(odbc_fetch_array($results)), $i = 1;      $value != false;     $value = array_pop(odbc_fetch_array($results)), $i++) {     $output[$i] = $value; } 


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -