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

help need on ob_start()
Hi

I am a newbie in php, I have a code
Line number On/Off | Expand/Contract <?phpo

Oracle11g Patch issue
Hi all,

I'm getting the following error while installing Oracle11g Patch 11.1.0.7.0 on IBM-AI

I apologise! It's a newbie to PHP feedback form problem!
Hi,

I am a total newbie to PHP. I am also a unemployed and need to get a job. So after 100% r

Streaming local file from PHP while it’s been written to by a CURL process
I am creating a simple Proxy server for my website. Why I am not using mod_proxy and mod_cache is a

use an array from 1 class in a second class
I have a class that adds data to an array

Then I have a second class and I need to check if t

Help with PHP Email Script
Hi guys,

I'm a newbie to php and need help with the script below:

At the moment when I

php include email form with attachment
I have had no luck with finding a email form all over the Internet for various reasons. Some insecur

server trace logs
could any one tell me from where do i get error logs in xMII??I want to check the reason for dtabase

Inserting a variable in a link
I have this code that I want to insert for my own variable but I have no idea how. This is what I wa

Help: problem with Headers to download PDF file
Hi,

I'm trying to implement a script where when a user clicks a link he gets a PDF file to op

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