LMarie Posted November 23, 2009 Share Posted November 23, 2009 Hi... iv made an sql table that contains id number - name of sql query and an sql query. The problem is that the table contains very different querys. On the first page you choose a query from a drop down menu. When this is done i check if the query contains date as a parametre. if yes a date picker is desplayed. When a date is picked the report runs when submited. i want the results of the query to be displayed in a html table and need help to figure out how many rows the sql query output needs. For example select firstname, lastname from users needs two rows and select firstname, lastname, birthdate from users needs three rows. my solution is maybe to check how many commas the variable containing the query has between select and from any one know how this can be done in php or maybe have a simpler way of solving this? Link to comment https://forums.phpfreaks.com/topic/182641-check-how-many-commas-the-variable-containing-the-query-has-between-iselecti/ Share on other sites More sharing options...
cags Posted November 23, 2009 Share Posted November 23, 2009 There's probably a better way, but off the top of my head... $sql = "SELECT one, two, three FROM table"; echo substr_count($sql, ",", 0, stripos($sql, "FROM")) + 1; Link to comment https://forums.phpfreaks.com/topic/182641-check-how-many-commas-the-variable-containing-the-query-has-between-iselecti/#findComment-963993 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.