I have a code:

 $data=$_SESSION['title'];
    $view=$con->query("select flower.*, mystash.* from flower,mystash where mystash.name like '%$data%' OR flower.name like '%$data%' ORDER BY name ASC");
    $check=$view;
    if($check!="")
    {
    while($descri=mysqli_fetch_object($view))
    {

I am trying to get the name from each table flower and mystash

each have a column in there of name I am not sure why this is not working but it just return no results for '%$data%'

Recommended Answers

All 2 Replies

You need to use a join.

`select flower.*, mystash.* from flower
join mystash on flower.something = mystash.something where mystash.name like '%$data%' OR flower.name like '%$data%' ORDER BY name ASC`

The two .somethings need to be changed to whatever the two tables have in common. I.e. an ID column that links the two tables.

you can use : JOIN, INNER JOIN,......

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.