Advertisement
Guest User

Untitled

a guest
Feb 11th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. <?php
  2. $category = $_POST['category'];
  3. $recipe = $_POST['recipe'];
  4. $connection = pg_connect("host=localhost port=5432 dbname=recipes user=postgres password=xxxxx") or die("Connection Error");
  5.  
  6. $result = pg_query($connection,"SELECT recipeID, description, keywords FROM recipesystem.recipe WHERE recipename = '$recipe' AND category = '$category';");
  7. while ($row = pg_fetch_array($result)) {
  8. $recipeID = $row['recipeID'];
  9. $description = $row['description'];
  10. $keywords = $row['keywords'];
  11. echo json_encode(array("recipeID" => $recipeID, "category" => $category, "recipe" => $recipe, "description" => $description, "keywords" => $keywords));
  12. };
  13. ?>
  14.  
  15. CREATE TABLE recipesystem.recipe
  16. (
  17. recipeid integer NOT NULL DEFAULT nextval('recipesystem.recipe_recipeid_seq'::regclass),
  18. whencreated timestamp without time zone NOT NULL,
  19. recipename character varying(200) COLLATE pg_catalog."default" NOT NULL,
  20. description text COLLATE pg_catalog."default",
  21. meal character varying(75) COLLATE pg_catalog."default",
  22. category character varying(75) COLLATE pg_catalog."default",
  23. keywords text COLLATE pg_catalog."default",
  24. isselected boolean,
  25. notes text COLLATE pg_catalog."default",
  26. CONSTRAINT recipe_pkey PRIMARY KEY (recipeid)
  27. )
  28. WITH (
  29. OIDS = FALSE
  30. )
  31. TABLESPACE pg_default;
  32.  
  33. ALTER TABLE recipesystem.recipe
  34. OWNER to postgres;
  35.  
  36. -- Index: idxrecipenamecategory
  37.  
  38. -- DROP INDEX recipesystem.idxrecipenamecategory;
  39.  
  40. CREATE UNIQUE INDEX idxrecipenamecategory
  41. ON recipesystem.recipe USING btree
  42. (recipename COLLATE pg_catalog."default", category COLLATE pg_catalog."default")
  43. TABLESPACE pg_default;
  44.  
  45. echo $num;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement