Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. +---------------------------------------------------+
  2. | id| itemName |itemColor|(some other specification)|
  3. +---------------------------------------------------+
  4. | 1 | item 1 | red | ------- |
  5. | 2 | item 2 | green | -------- |
  6. | 3 | item 3 | blue | ------- |
  7. +---------------------------------------------------+
  8.  
  9. +----------------------------------+
  10. |id|itemFrom|itemTo|rateFrom|rateTo|
  11. +----------------------------------+
  12. | 1| 1 | 3 | 1 | 30 |
  13. | 2| 1 | 2 | 30 | 20 |
  14. | 3| 1 | 1 | 3 | 2 |
  15. | 4| 2 | 1 | 5 | 3 |
  16. | 5| 2 | 3 | 6 | 10 |
  17. | 6| 2 | 2 | 6 | 5 |
  18. | 7| 3 | 1 | 1 | 1 |
  19. | 8| 3 | 2 | 5 | 3 |
  20. | 9| 3 | 3 | 2 | 1 |
  21. +----------------------------------+
  22.  
  23. {
  24. "itemName":"item 1",
  25. "itemcolor":"red",
  26. "exchangeFromRate":"5"
  27. "exchangeToRate":"3"
  28. },{
  29. "itemName":"item 2",
  30. "itemcolor":"green",
  31. "exchangeFromRate":"6"
  32. "exchangeToRate":"5"
  33. },{
  34. "itemName":"item 3",
  35. "itemcolor":"blue",
  36. "exchangeFromRate":"6"
  37. "exchangeToRate":"10"
  38. }
  39.  
  40. $itemfrom=$_GET['itemfrom'];
  41. $qry="select id from productTable where itemName='$itemfrom'"
  42. $result=mysqli_query($conn,$qry) or die("error in selecting ".mysqli_error($conn));
  43. while($row =mysqli_fetch_assoc($result))
  44. {
  45. $itemFromID=$row['id'];
  46. }
  47. $finalqry="select P.itemName,
  48. P.itemColor,
  49. R1.ratefrom
  50. R2.rateto
  51. from ProductTable P
  52. Join ExchangeRateTable R
  53. R1.ratefrom=?????
  54. R2.rateto=???????";
  55. $finalResult = mysqli_query($conn, $finalqry) or die("Error in Selecting " .mysqli_error($conn));
  56.  
  57. while($row =mysqli_fetch_assoc($finalResult ))
  58. {
  59. $exchangeToNameRates[] = $row;
  60. }
  61.  
  62. $exchangeToNameRateArrey = ['status' =>"true",
  63. "message"=> "Data fetched successfully!",
  64. 'data' =>$exchangeToNameRates];
  65.  
  66. echo json_encode($exchangeToNameRateArrey );
  67.  
  68. SELECT P.itemName,
  69. P.itemColor,
  70. R1.ratefrom
  71. R2.rateto
  72. from ProductTable P
  73. Join ExchangeRateTable R
  74. on R.itemFrom=P.id
  75. where P.itemName='$itemfrom'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement