count only commas outside parenteses


Posted on 16th Feb 2014 07:03 pm by admin

I have a sql table containing
id - query - query name
the first page contains a drop down menu of all the query names. When chosen the user is sent to a page that prints the result of the query in a html table.

Did you know?Explore Trending and Topic pages for more stories like this.
Now i nees to find how many rows the table should have.

This counts how many rows i need in the table:

$parts=explode(' FROM ',$query);
$count=explode(",", $parts[0]);
$result=count($count);

But the problem is that here i explode by commas but the query also contains commas like this: substring (***,19,10) as Part1

My question is how do i count only commas outside these parenteses.

something like this:

$var=0;
start counting commas in parts[0],
when ( accures increase $var to 1,
if $var = 1 dont count commas,
but when ) accures set $var to 0,
and start counting again

The reason why im making it this way is that it's suppose to be possible to just add a query to the sql table no matter how many rows this query needs in output.

Any ideas?
No comments posted yet

Your Answer:

Login to answer
177 Like 14 Dislike
Previous forums Next forums
Other forums

How to search for several parameters from objects in a database?
I have a database with lots of information about objects.
Now I would like to search for 4 or 5 p

PHP webpage & array print issue
I have this code running, and it works perfectly … however, see my bottom bit about what I see

Looking for help on using joining mysql tables and php....
Does anyone have any good links to references on how to pull mysql data, through joining tables and

Problems with adding a link to one position in a 'foreach' loop, please help
Hello!

Iam pretty new to programming and I wanna create a table with users from an array. It

Stopping page post back
I have few literal contriols in my page and a repeater too. But inspite of using update panel, postb

Libraries in C++
Hi all,

I have two libraries. one is based targeted on linux platform and uses another li

Is it possible to view php source code??
Hi All

I was just wondering if it's possible to view a websites php source code?
I know

Else statement screws up all css
Does anyone know what goes wrong in the process with this php code?
This code seems to be causing

mysql select with $_get ?
Hi, i have this code:
Code: // If char id is 0 and character dont exist do:
if ($_GET["id

C problem struct and string
Hi guys,

This is my first post and I'm hoping the experts here can help me solve my problem.<

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash