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;


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.
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <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">
$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"]);

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

for ($i=0;$i<count($skills);$i++)



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


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, learning, and sharing knowledge.