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

Share admin accross websites
I'm using .net memberships and roles in one of my sites, but I need to be able to share logins and p

A little help in c#
i am doing a simple paint program using c# i want to draw with the mouse so i wrote the code of the

Chat Box in PHP
I was thinking in doing a Chat Box in PHP. For that I would use a form with two fields, Nick and Mes

Deleting pointers froms vector?
Hi. I have a vector filled with pointers and I want to delete the pointers. I could do a loop and do

Can't find a decent web analytics!!!
I've downloaded and installed Piwik. It's location detection based on IP addresses is fairly inaccur

how do i display data on a page from mysql
1 - do i use this code at the top of each of my page i wish to only alow access if there as been a s

ME54/ME54N Conditional check for Release of PR
Hi Gurus,

My requirement is to put a check on the release of the PR with respect to the c

big pagination problem in php
<?php

$connect = mysql_connect("localhost", "root", "")

SQL Query/echo not working
Hey all,

I'm trying to run (what I thought) was a simple operation and it isn't working. I h

Firewall / visited websites logger
Hi. I have a firewall implementation and I want to log all the websites visited on the machine. S

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