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

problems with contact forms that are only protected against SQL injections
What could be a potential problem with contact forms that are only protected against SQL injections

help me, how to find text on an external html site using PHP
Would anyone know how to search an external html file for a work or phrase ?

I was thinking s

how to hide input fields on selection screen using variant attribute
Hello all,

I want to know how to hide input fields on selection screen using variant attr

PHP Redirecting
Hello everyone. Is there a way to redirect people to pages within a statement in PHP? Since there is

media recovery
Hi,
i startup the database i got the error

SQL> startup
ORACLE instance started.

IF Statement & Two Tables With Different Echoes
I'm retrieving two tables in a single query using UNION ALL, like so:

Code: $query = "SE

Using Windows message as a Handle
Hi,

I am writing one of my first multithreaded programs.

In one of the thread,

Parse error: syntax error, unexpected T_ELSEIF in /home/......html/item.php on l
I do not know what is wrong with this. Hope some one can help. I do nto want to post the entire site

$_FILES array
Ok,

I just started experimenting with PHP today. My goal right now is to have people be able

InternetOpenUrl() Invalid cert
Hi all,

Does anyone know how to prevent calls to InternetOpenUrl() from failing with erro

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