i have an array names skills in which there are various skills

now i wanna create aquery like

select * from tablename where skills regexp ""skill1" and skills regexp "skills2" and skills regexp "skills3";

how could i do this..

upon defining a string for concatenation php shows error....`$s=select * from $table[0] where skills regexp;

help!`

Recommended Answers

All 5 Replies

It would help if you could be more specific. Show some code so we can see things like the array structure and values, the table structure, the complete error message etc.

<!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>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <form name="f1" action="wel.php" method="post">
            <textarea name="table" placeholder="table"></textarea>
            <textarea name="skills" placeholder="skill or item or spec"></textarea>
            <textarea name="city" placeholder="city"></textarea>
            <textarea name="region" placeholder="region"></textarea>
            <textarea name="country" placeholder="country"></textarea>
        <input type="submit">
        </form>
        </body>
</html>
<?php
$count = 0;
    foreach($_POST as $item)
    {
    $count += (is_array($item)) ? count($item) : 1;
    }
   // echo "Items = $count";


$skills = explode(" ", $_POST["skills"]);
$table = explode(" ", $_POST["table"]);
$city = explode(" ", $_POST["city"]);
$region = explode(" ", $_POST["region"]);
$country = explode(" ", $_POST["country"]);
print_r($country);

/* @var $table type */
$s=select * from $table[0] where skills regexp;

if(!empty($skills[0])){
for ($i=0;$i<count($skills);$i++)
{

}
}
?>

reply

Post the table structure and complete error message (see my post above).

reply

Please be patient if people don't have time to reply immediately :-)

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.