omardavinci
-
Posts
32 -
Joined
-
Last visited
Posts posted by omardavinci
-
-
Ok so i need to change parameters and sintaxis. Ok i will check tutorial and i will do the updates
-
One question i changed( mysql_ for mysqli_ ) But anyways i get still errores like these:
Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in C:\wamp\www\CoffeeWebsite\Model\CoffeeModel.php on line 31 Call StackSome suggestions? dissapointments are good received
About input i will take one page of example:
http://www.voidrealms.com/index.php?r=tutorial/index
Something like this. I mean it that
-
1. If i mustnt use function what do you recomend to me?
2.Are you refering to this? http://php.net/manual/es/ref.pdo-mysql.php
3.I want to include in the tables one input or type to search in the fields.
4. So you recommend me to do this query: "select ... where type='" . $type . '%'. "'";?
About pdo i will check the manual, you said me it is deprecated
-
Hi i did one webpage in php with a different tables and posts. But i need help because i want to add in this page one type and one input in my table for searching in each column.CREATE TABLE IF NOT EXISTS `coffee` (`id` int(11) NOT NULL AUTO_INCREMENT,`name` varchar(255) DEFAULT NULL,`type` varchar(255) DEFAULT NULL,`price` double DEFAULT NULL,`roast` varchar(255) DEFAULT NULL,`country` varchar(255) DEFAULT NULL,`image` varchar(255) DEFAULT NULL,`review` text,`ide` text,PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;---- Gegevens worden uitgevoerd voor tabel `coffee`--INSERT INTO `coffee` (`id`, `name`, `type`, `price`, `roast`, `country`, `image`, `review`) VALUES(1, 'Cafe au Lait', 'Classic', 2.25, 'Medium', 'France', 'Images/Coffee/Cafe-Au-Lait.jpg', 'A coffee beverage consisting strong or bold coffee (sometimes espresso) mixed with scalded milk in approximately a 1:1 ratio.'')'),(2, 'Caffe Americano', 'Espresso', 3.25, 'Medium', 'Italy', 'Images/coffee/caffe_americano.jpg', 'Similar in strength and taste to American-style brewed coffee, there are subtle differences achieved by pulling a fresh shot of espresso for the beverage base.'),(3, 'Peppermint White Chocolate Mocha', 'Espresso', 3.25, 'Medium', 'Italy', 'Images/coffee/white-chocolate-peppermint-mocha.jpg', 'Espresso with white chocolate and peppermint flavored syrups and steamed milk. Topped with sweetened whipped cream and dark chocolate curls.'),(4, 'Galao', 'Latte', 4.2, 'Light', 'Portugal', 'Images/Coffee/galao_kaffee_portugal.jpg', 'Galao is a hot drink from Portugal made of espresso and foamed milk');In model php contains database related code for page of table://Get coffeeEntity objects from the database and return them in an array.function GetCoffeeByType($type) {require ('Credentials.php');//Open connection and Select database.mysql_connect($host, $user, $passwd) or die(mysql_error);mysql_select_db($database);$query = "SELECT * FROM coffee WHERE type LIKE '$type'";$result = mysql_query($query) or die(mysql_error());$coffeeArray = array();//Get data from database.while ($row = mysql_fetch_array($result)) {$id = $row[0];$name = $row[1];$type = $row[2];$price = $row[3];$roast = $row[4];$country = $row[5];$image = $row[6];$review = $row[7];$ide = $row[8];//Create coffee objects and store them in an array.$coffee = new CoffeeEntity($id, $name, $type, $price, $roast, $country, $image, $review);array_push($coffeeArray, $coffee);}//Close connection and return resultmysql_close();return $coffeeArray;}And here the code that will connect this to my php:<?php$title = "Manage coffee objects";include './Controller/CoffeeController.php';$coffeeController = new CoffeeController();$content = $coffeeController->CreateOverviewTable();if(isset($_POST['types'])){//Fill page with coffees of the selected type$coffeeTables = $coffeeController->CreateCoffeeTables($_POST['types']);}else{//Page is loaded for the first time, no type selected -> Fetch all types$coffeeTables = $coffeeController->CreateCoffeeTables('%');}if(isset($_GET["delete"])){$coffeeController->DeleteCoffee($_GET["delete"]);}include './Template.php';?>So please if you have some suggestion how to include in my php the type and input, and it uses to search in my table; say me. All sugestions, dissapointments are good received
page php, how include input and type to search in my table
in PHP Coding Help
Posted
one question about functions. the functions are still used in PDO? in this tutorial she is using PDO? Or with PDO it is not necessary, thx again and regard