Mysql query works in Phpmyadmin but not works in PHP

user4013871

i have two tables the first one is cont_details

     -------------- --------------
    | cont_details_id  | cont_no |
     -----------------------------
    |  1                |   A001 |
    |  2                |   A002 |
    |  3                |   A003 |
    ------------------------------

and the second one is cont_sold_tmp

     --------------
    | id | cont_no |
     --------------
    |  1 |   1    |
    |  2 |   3    |
    ----------------

now i need to select from table cont_details table which are not in temp_cont

so i used this query

select * from cont_details left join cont_sold_tmp on cont_details.cont_details_id = cont_sold_tmp.cont_no where cont_sold_tmp.cont_no is null

This query works perfectly when i check in PhpmyAdmin but when i use it in HTMl, not working

<select name="cont_no"  id="cont_no" data-rel="chosen">
    <option value="">Select</option>
    <?php
       $qry = mysql_query("select * from cont_details left join cont_sold_tmp on cont_details.cont_details_id = cont_sold_tmp.cont_no where cont_sold_tmp.cont_no is null");
           while($res = mysql_fetch_array($qry))
              {
         ?>
         <option value="<?php echo $res["cont_details_id"];?>">
           <?php echo $res["cont_no"];?>
      </option>
     <?php } ?>
    </select>

Database connections are working perfectly, instead of join query i just checked with the simple query "select * from cont_details" its shows all the records. but when i use this join query. i dont get any records in dropdown

user4013871

And finally found the mistake what i did -_-

select cont_details.cont_details_id as cont_details_id, 
cont_details.cont_no as cont_no
from cont_details left join cont_sold_tmp
on cont_details.cont_details_id = cont_sold_tmp.cont_no
where cont_sold_tmp.cont_no is NULL

after combining tables, i didn't choose column correctly with table name (.)

so the result when i use <option value="<?php echo $res["cont_details_id"];?>"> , it doesnt exits there so its show empty

thank you for ur replys :-)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

MySQL query works in PHPMyAdmin but not PHP

From Dev

Query works in phpmyadmin but not in PHP

From Dev

MySQL SELECT query works in PHPmyadmin, not in PHP

From Dev

MySQL INSERT query works in Phpmyadmin but not in PHP

From Dev

mysql query works in phpmyadmin but errors in php

From Dev

PHP MYSQL query won't work in PHP but works in PHPMyAdmin

From Dev

mysql and php %like% query. Works in phpmyadmin but different results php

From Dev

MySQL UPDATE works in phpMyAdmin but not in PHP

From Dev

mysql query works in phpmyadmin but not in node.js

From Dev

MySQL Query Not Working Live But Works In PHPMyAdmin

From Dev

A query that uses variables works in PHPMyAdmin, but not in a PHP script

From Dev

SQL Query works in phpMyAdmin but not in php page

From Dev

A query that uses variables works in PHPMyAdmin, but not in a PHP script

From Dev

PHP and MySQL french accent works in PHPMyAdmin but not in page

From Dev

query works in mysql terminal but not in php

From Dev

query works in mysql fails in php

From Dev

How can I get a mysql script that works in PHPmyadmin, to work in a PHP mysql query?

From Dev

DB query from PHP gives no result but same query on phpMyAdmin works?

From Dev

mysql "between date" query works in phpmyadmin but returns nothing with PDO

From Dev

Insert query works on phpMyAdmin but not with Java

From Dev

Mysql query not working in PHP, works fine in mysql

From Dev

MySQL Workbench works and phpmyadmin does not

From Dev

MySQL Workbench works and phpmyadmin does not

From Dev

MySQL works in terminal on PHPmyadmin but does not work in php script?

From Dev

update query that Works directly in MYSQL but not in PHP

From Dev

query works on mysql but not in java

From Dev

Query works wrong MySQL

From Dev

Query works in sql but not in php

From Dev

Query returns empty in script, works perfect in phpMyAdmin

Related Related

  1. 1

    MySQL query works in PHPMyAdmin but not PHP

  2. 2

    Query works in phpmyadmin but not in PHP

  3. 3

    MySQL SELECT query works in PHPmyadmin, not in PHP

  4. 4

    MySQL INSERT query works in Phpmyadmin but not in PHP

  5. 5

    mysql query works in phpmyadmin but errors in php

  6. 6

    PHP MYSQL query won't work in PHP but works in PHPMyAdmin

  7. 7

    mysql and php %like% query. Works in phpmyadmin but different results php

  8. 8

    MySQL UPDATE works in phpMyAdmin but not in PHP

  9. 9

    mysql query works in phpmyadmin but not in node.js

  10. 10

    MySQL Query Not Working Live But Works In PHPMyAdmin

  11. 11

    A query that uses variables works in PHPMyAdmin, but not in a PHP script

  12. 12

    SQL Query works in phpMyAdmin but not in php page

  13. 13

    A query that uses variables works in PHPMyAdmin, but not in a PHP script

  14. 14

    PHP and MySQL french accent works in PHPMyAdmin but not in page

  15. 15

    query works in mysql terminal but not in php

  16. 16

    query works in mysql fails in php

  17. 17

    How can I get a mysql script that works in PHPmyadmin, to work in a PHP mysql query?

  18. 18

    DB query from PHP gives no result but same query on phpMyAdmin works?

  19. 19

    mysql "between date" query works in phpmyadmin but returns nothing with PDO

  20. 20

    Insert query works on phpMyAdmin but not with Java

  21. 21

    Mysql query not working in PHP, works fine in mysql

  22. 22

    MySQL Workbench works and phpmyadmin does not

  23. 23

    MySQL Workbench works and phpmyadmin does not

  24. 24

    MySQL works in terminal on PHPmyadmin but does not work in php script?

  25. 25

    update query that Works directly in MYSQL but not in PHP

  26. 26

    query works on mysql but not in java

  27. 27

    Query works wrong MySQL

  28. 28

    Query works in sql but not in php

  29. 29

    Query returns empty in script, works perfect in phpMyAdmin

HotTag

Archive