Jump to content

omardavinci

Members
  • Posts

    32
  • Joined

  • Last visited

Posts posted by omardavinci

  1. 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 Stack

     

     

    Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\wamp\www\CoffeeWebsite\Model\CoffeeModel.php on line 34 Call Stack

     

    Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\wamp\www\CoffeeWebsite\Model\CoffeeModel.php on line 34 Call Stack

     

    Some 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

  2. 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 result
            mysql_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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.