erdomester Posted May 7, 2009 Share Posted May 7, 2009 Hi all, I want to get a value of the first row of a table in Ms Access. I have found an appropriate command for MySQL but none for Access. I am looking for something like this: get_first_row(title_of_specified_coloumn); Thanks, erdomester Link to comment https://forums.phpfreaks.com/topic/157253-solved-how-to-get-a-value-in-the-first-row-in-an-ms-access-db-with-php/ Share on other sites More sharing options...
premiso Posted May 7, 2009 Share Posted May 7, 2009 ODBC are the functions you want to look into. Particularly the odbc_fetch_row function. Link to comment https://forums.phpfreaks.com/topic/157253-solved-how-to-get-a-value-in-the-first-row-in-an-ms-access-db-with-php/#findComment-828666 Share on other sites More sharing options...
erdomester Posted May 7, 2009 Author Share Posted May 7, 2009 My program is like this: there is a database with tables of bus_stops and minutes (how many minutes does the bus arrives to the stop from the terminus in). All bus-stops are pushed in a dropdown box. Tables of buses are in an array ($stops_array) like Bus_205, Bus_35 etc. E.g. Bus 205 table: STOPS MINS Stop.1 0 Stop.2 1 Stop.3 3 ...and so on and for all bus tables. Program works this way: 1. User selects one from the dropdown box ($selected) 2. Program goes thru all the bus tables (for loop) 3. and searches for the selected stop in the table (while loop) 4. If there is a match, it writes out that e.g. bus No. X arrives in Y minutes from TERMINUS. First part of the result is ok, but how can i write out the terminus, which is the first row of the tables? I use Ms Access and haven't found a solution, however there is a command for MySQL... My code is: for ($i=0; $i<sizeof($stops_array); $i++) { $sqlt="SELECT * FROM $stops_array[$i]"; $rst=odbc_exec($conn,$sqlt); if (!$rst) {exit("Error in SQL");} while (odbc_fetch_row($rst)) { $stops=odbc_result($rst,"STOPS"); $mins=odbc_result($rst,"MINS"); if ($selected == $stops) { echo: " "; } } } Link to comment https://forums.phpfreaks.com/topic/157253-solved-how-to-get-a-value-in-the-first-row-in-an-ms-access-db-with-php/#findComment-828867 Share on other sites More sharing options...
erdomester Posted May 8, 2009 Author Share Posted May 8, 2009 Well, i turned out to be an idiot. I was just studying for my complex exam at the uni when it stroke to me that i don't have to fill the array up, I just need the first element. So my code is like: 1. start filling up array 2. if there is a match, write out the 0.th element. Link to comment https://forums.phpfreaks.com/topic/157253-solved-how-to-get-a-value-in-the-first-row-in-an-ms-access-db-with-php/#findComment-829354 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.