Advertisement
apl-mhd

posinsertupdate

Sep 14th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | None | 0 0
  1. <?php
  2. /*
  3. SELECT post.postdesc, location.locationname,category.categoryname FROM post
  4. JOIN location ON location.id = post.locationid
  5. JOIN category ON post.categoryid = category.id
  6. WHERE postid = 41; */
  7.  
  8.  
  9. /**
  10.  * Created by PhpStorm.
  11.  * User: apelmahmud
  12.  * Date: 02/04/2017
  13.  * Time: 3:24 PM
  14.  */
  15. include('connect.php');
  16. include('uploadscript.php');
  17. include ('debug.php');
  18. session_start();
  19.  
  20.  
  21. $category = $_POST['category'];
  22. $discountrate = $_POST['discount'];
  23. $expire = $_POST['expire'];
  24. $postdesc = $_POST['postinfo'];
  25. $location = $_POST['location'];
  26. $category = $_POST['category'];
  27.  
  28.  
  29. $userid =  $_SESSION['userid'];
  30. $date = date('Y-m-d');
  31.  
  32.  
  33.  
  34. /*query for locationid in location table*/
  35. $sqlLocation = "SELECT * FROM  location where  locationname = '$location' ";
  36.  
  37. $queryLocation = $con->query($sqlLocation);
  38.  
  39. $rowLocation = $queryLocation->fetch_assoc();
  40.  
  41. /*Query for category id in category table*/
  42.  
  43.  
  44. $sqlCategory = "SELECT * FROM  category where  subcategory = '$category' ";
  45.  
  46. $queryCategory = $con->query($sqlCategory);
  47. $rowCategory = $queryCategory->fetch_assoc();
  48.  
  49. if($con->query($sqlCategory) === false)
  50.     echo  $con->error;
  51.  
  52.  
  53. if($queryCategory->num_rows > 0)
  54.     echo  $rowCategory['id']."<br>";
  55.  
  56.  
  57.  else
  58.     show($category);
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66. $sql = "INSERT INTO post(userid, locationid , categoryid, postdesc, expire, discountrate,postdate,imglink)
  67.  
  68.                             values (' ". $userid. " ' , ' ".$rowLocation['id'] ."' , ' ".$rowCategory['id']." ' ,' ".$postdesc."', ' ".$expire."', ' ".$discountrate." ', '".$date ."', ' " . $fileNameNew . " ' )";
  69.  
  70.  
  71.  
  72. if ($con->query($sql) === true)
  73.  
  74.     echo  "insert success";
  75. else
  76.  
  77.     show($category['category']);
  78.  
  79.  
  80. ?>
  81.  
  82. <?php
  83. $con->close();
  84.  
  85.  
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement