0

hello there I have PHP query that Fetch Records from a database with where condition I have four pages in WebSite I want to Fetch data from DataBase with where Condition Ever pages Fetch own Content From database Through link It's my query that's not work

Prefix already in config file

$prefix     = 'v1_';

$link = $p['link'] ;
    $data_query = $db->query("
        SELECT * FROM ".$prefix.$key." 
        WHERE "$p['link'] = $link "
      "); 

In WebSite pages are Define with key $x

$x = 'about';
$pages[$x]['title']  = 'About Us';
$pages[$x]['link']   = 'about_us';
$pages[$x]['source'] = 0;

and same variable and own info in both pages

$x = 'objects';
$x = 'services';

and I'm using this query in website its work fine but now I want to change that I mention above details

 $data_query = $db->query("
    SELECT * FROM ".$prefix.$key." 
    WHERE online = 1 ;
  ");

Any contributors to this post, I thank you for your help :)

Uzair
  • 21
  • 1

2 Answers2

0

Try this:

$data_query = $db->query("SELECT * FROM {$table} WHERE link = {$link}"); 
Stoycho Trenchev
  • 557
  • 4
  • 12
0

you can use LIKE query

eg.

SELECT * <TABLE_NAME> WHERE COLUMN_NAME LIKE '<prefix>%'

For multiple where condition read this answere

Community
  • 1
  • 1
Hiren Makwana
  • 1,976
  • 2
  • 13
  • 28