`

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title>Our Local site</title>

    </head>
    <body>
        <form action="welcome.php" method="post">
            <input id="t1" name="t1"type="text" placeholder="table name"><br>
          <input id="s1"type="text" name="skill[]"placeholder="skill or item or spec">
        <input id="s2" type="text" name="skill[]" placeholder="skill or item or spec">
        <input id="s3" type="text" name="skill[]" placeholder="skill or item or spec">
        <input id="s4"type="text" name="skill[]" placeholder="skill or item or spec">
        <input id="s5"type="text" name="skill[]" placeholder="skill or item or spec">
        <input id="s6"type="text" name="skill[]" placeholder="skill or item or spec">
        <input id="s7"type="text" name="skill[]" placeholder="skill or item or spec">
        <input id="s8"type="text" name="skill[]" placeholder="skill or item or spec">
        <input id="s9"type="text" name="skill[]" placeholder="skill or item or spec">
        <input id="c1"type="text" name="city[]"placeholder="city">
        <input id="c2"type="text" name="city[]"placeholder="city">
        <input id="c3"type="text" name="city[]" placeholder="city">
        <input id="c4"type="text" name="city[]" placeholder="city">
        <input id="c5"type="text" name="city[]" placeholder="city">
        <input id="c6"type="text" name="city[]"placeholder="city"><br>
        <input id="r1"type="text" name="region[]"placeholder="Region in city">
        <input id="r2"type="text" name="region[]" placeholder="Region in city">
        <input id="r3"type="text" name="region[]" placeholder="Region in city">
        <input id="cn1"type="text" name="country[]" placeholder="country">
        <input id="cn2"type="text" name="country[]" placeholder="country">
        <input id="cn3"type="text" name="country[]" placeholder="country">
        <input id="l1"type="text" name="lat"placeholder="Latitude in degrees">
        <input id="l2"type="text" name="long"placeholder="Longitude in degrees">
        <input type="submit">
       </form>
    </body>
</html>

i have this code..
upon counting post array it shows number 7..please reply how to solve this error...` $sk= $_POST;

print_r(count($sk));``

Member Avatar for diafol

This is correct - you have 7 different names:

t1,skill,city,region,country,lat,long

What were you expecting/Did you think to get count of skills? I'm just assuming since you called your variable $sk.

$sk= $_POST['skills'];

BTW, your DTD is missing.

yes but i need to count all

Member Avatar for diafol

What the total number of fields in the form?

You need a recursive count, but they can be fiddly, or you can do a simple loop if the arrays are one 1 deep.

$count = 0;
foreach($_POST as $item)
{
    $count += (is_array($item)) ? count($item) : 1;
}
echo "Items = $count";

is the item is not an array what does it do then?

Member Avatar for diafol

is the item is not an array what does it do then?

See line 4 - it adds 1 if not an array as it's a scalar.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.