0

`

<!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));``

2
Contributors
5
Replies
15
Views
3 Years
Discussion Span
Last Post by diafol
0

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.

0

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";
0

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

Edited by ankit1122

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.