当前位置: 首页>>代码示例>>PHP>>正文


PHP site::readText方法代码示例

本文整理汇总了PHP中site::readText方法的典型用法代码示例。如果您正苦于以下问题:PHP site::readText方法的具体用法?PHP site::readText怎么用?PHP site::readText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在site的用法示例。


在下文中一共展示了site::readText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: site

$sth1 = $db->prepare($sstmt1);
$sth1->execute();
$arr1 = $sth1->fetchAll();
$sstmt2 = "SELECT `barcode`, `product` FROM `items_alcohol` WHERE 1";
$sth2 = $db->prepare($sstmt2);
$sth2->execute();
$arr2 = $sth2->fetchAll();
$products = array_merge($arr1, $arr2);
//generate the site home.
$site = new site("cart");
//call the genOpeneing method to generate the opening content of the home page.
$site->genOpening();
//call the genSearch method to genreate the search bar on the top of the page.
$site->genSearch();
//call readText method to pull information into the page from seperate source.
$site->readText("cart");
// If we find sections of the cart set, display the table.
// We are using map here because sizeof() doesn't handle nested arrays
if (isset($_SESSION["cart"]) && @max(array_map('count', $_SESSION["cart"])) > 0) {
    // Generate the heading of the table
    echo "<table><tr><th>Product</th><th>Quantity</th></tr>";
    //Iterate through the cart, setting the product name as $key and the quantity as $value
    foreach ($_SESSION["cart"] as $key => $value) {
        $productName = "Unknown Product";
        // Echo a table row with the information and a button.
        foreach ($products as $row) {
            if ($row[0] == $key) {
                $productName = $row[1];
            }
        }
        echo "<tr><td>{$productName}</td><td>{$value} <button onclick='action(\"remove\",\"{$key}\")'>- Remove</button></td></tr>";
开发者ID:klinthammel,项目名称:CS4420,代码行数:31,代码来源:cart.php

示例2: foreach

            $stmt2 = "SELECT `order_id`, `fName`, `lName`, `addr`, `ord` FROM `orders` WHERE order_id = :ord ORDER BY `order_id` DESC LIMIT 1";
            $sth2 = $db->prepare($stmt2);
            $sth2->bindParam(":ord", $order);
            $sth2->execute();
            $values = $sth2->fetchAll()[0];
            echo "Order for {$values['lName']}, {$values['fName']}<br />";
            echo "Shipped to {$values['addr']}<br />";
            $contents = json_decode($values["ord"], true);
            echo "<table><tr><th>Product</th><th>Quantity</th></tr>";
            foreach ($contents as $key => $value) {
                $productName = "Unknown Product";
                // Echo a table row with the information and a button.
                foreach ($products as $row) {
                    if ($row[0] == $key) {
                        $productName = $row[1];
                    }
                }
                echo "<tr><td>{$productName}</td><td>{$value}</td></tr>";
            }
            echo "</table>";
        } catch (PDOException $e) {
            echo $e->gettext();
        }
    } else {
        echo "Unknown order ID!";
    }
}
//call readText method to pull information into the page from separate source.
$site->readText("order");
//call genClosing method to generate bottom of page and close html.
$site->genClosing();
开发者ID:klinthammel,项目名称:CS4420,代码行数:31,代码来源:order.php

示例3: die

// Create a new statement handle, with the statement we created above
$sth = $db->prepare($stmt);
// Replace the :type param with the type given
@$sth->bindParam(":type", $type);
// Execute the search against the database
$sth->execute() or die("Unable to execute");
// Fetch the results from the statement handle
$result = $sth->fetchAll();
// Create a new "site" object
$site = new site(strtolower($type));
//call the genOpeneing method to generate the opening content of the page.
$site->genOpening();
//call the genSearch method to generate the search bar on the top of the page.
$site->genSearch();
// Display the text from our static contents
$site->readText($type);
// Echo the top of the table
echo <<<ENDL
<table class="sortable">
\t<tr>
\t\t<th>Product</th>
\t\t<th>Type</th>
\t\t<th>Wholesale</th>
\t\t<th>Quantity</th>
\t\t<th class="nj sorttable_nosort">Add to Cart</th>
\t</tr>
ENDL;
/*
foreach($result as $row) {
    echo "<tr><td>{$row["Product"]}<br />(Barcode: {$row["Barcode"]})</td><td>{$row["Category"]}</td><td>\${$row["Price"]}.00</td><td>{$row["Stock"]}</td><td>";
    if ($row["Stock"] < 1) { echo "This product is currently unavailable"; }
开发者ID:klinthammel,项目名称:CS4420,代码行数:31,代码来源:catalog.php

示例4: PDO

<?php

//start the user session
session_start();
//require the includes.php which ensures certain files are pulled in for database and site properties.
require "includes.php";
//create a PDO connection to the mySQL databse.
$db = new PDO("mysql:host={$GLOBALS['mysql_host']};dbname={$GLOBALS['mysql_database']}", $GLOBALS["mysql_user"], $GLOBALS["mysql_password"]) or die("Unable to connect to database.");
//generate the site home.
$site = new site("home");
//call the genOpeneing method to generate the opening content of the home page.
$site->genOpening();
//call the genSearch method to genreate the search bar on the top of the page.
$site->genSearch();
//call readText method to pull information into the page from separate source.
$site->readText("welcome");
//call genClosing method to generate bottom of page and close html.
$site->genClosing();
开发者ID:klinthammel,项目名称:CS4420,代码行数:18,代码来源:index.php


注:本文中的site::readText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。