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


PHP db_connect函数代码示例

本文整理汇总了PHP中db_connect函数的典型用法代码示例。如果您正苦于以下问题:PHP db_connect函数的具体用法?PHP db_connect怎么用?PHP db_connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: display_search_result_by_name

function display_search_result_by_name($search_key)
{
    // query database for the books in a category
    if (!$search_key || $search_key == '') {
        return false;
    }
    $conn = db_connect();
    $query = "select * from food;";
    $result = @$conn->query($query);
    if (!$result) {
        echo "Error: Can't execute query about food";
        return false;
    }
    $num = @$result->num_rows;
    if ($num == 0) {
        return false;
    }
    $is_search_mached = false;
    while ($row = $result->fetch_assoc()) {
        if (strpos($row['name'], $search_key) !== false) {
            echo "<div class=\"col-xs-12 col-sm-6 col-md-4\">\n\t\t\t\t\t  <div class=\"thumbnail\">\n\t\t\t\t\t    <a href=\"food_details.php?food_id=" . $row['food_id'] . "\"><img src=\"img/" . $row['food_id'] . ".jpg\" alt=\"...\"></a>\n\t\t\t\t\t\t<div class=\"caption\">\n\t\t\t\t\t\t  <h3><b>Name: </b>" . $row['name'] . "</h3>\n\t\t\t\t\t\t  <p><b>Description: </b>" . $row['description'] . "</p>\n\t\t\t\t\t\t   <p>\n\t\t\t\t\t\t      <a href=\"food_details.php?food_id=" . $row['food_id'] . "\" class=\"btn btn-primary\" role=\"button\">View Details</a>\t\t\t\t     \t\t\t     \n\t\t\t\t\t\t   </p>\n\t\t\t\t\t      </div>\n\t\t\t\t\t  </div>\n\t\t\t\t\t</div>";
            $is_search_mached = true;
        }
    }
    if (!$is_search_mached) {
        echo '<div class="form-group" id="success_message">
		    <div class="col-sm-offset-2 col-sm-8">
		    	<div class="alert alert-danger">
		    		<h3> No results!</h3>
		    	</div>
		    </div>
		  </div>';
    }
}
开发者ID:ChongDeng,项目名称:FoodGalaxy,代码行数:34,代码来源:search_result_by_food_name.php

示例2: printGrp

function printGrp()
{
    # Set up table to display in
    $printGrp = "\r\n    <h3>Asset Groups</h3>\r\n    <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n    <tr><th>Group</th><th>Cost Account</th><th>Accumulated Depreciation Account</th><th>Depreciation Account</th><th colspan=2>Options</th></tr>";
    # connect to database
    db_connect();
    # Query server
    $i = 0;
    $sql = "SELECT * FROM assetgrp WHERE div = '" . USER_DIV . "' ORDER BY grpname ASC";
    $GrpRslt = db_exec($sql) or errDie("Unable to retrieve Asset Groups from database.");
    if (pg_numrows($GrpRslt) < 1) {
        return "\r\n\t\t\t\t<li> There are no Assets Groups in Cubit.</li><br>" . mkQuickLinks(ql("assetgrp-new.php", "Add Asset Group"), ql("assetgrp-view.php", "View Asset Groups"));
    }
    while ($Grp = pg_fetch_array($GrpRslt)) {
        # get ledger account name(cost)
        core_connect();
        $sql = "SELECT accname FROM accounts WHERE accid = '{$Grp['costacc']}' AND div = '" . USER_DIV . "'";
        $accRslt = db_exec($sql);
        $acccost = pg_fetch_array($accRslt);
        # get ledger account name(accum dep)
        $sql = "SELECT accname FROM accounts WHERE accid = '{$Grp['accdacc']}' AND div = '" . USER_DIV . "'";
        $accRslt = db_exec($sql);
        $acdacc = pg_fetch_array($accRslt);
        # get ledger account name(dep)
        $sql = "SELECT accname FROM accounts WHERE accid = '{$Grp['depacc']}' AND div = '" . USER_DIV . "'";
        $accRslt = db_exec($sql);
        $accdep = pg_fetch_array($accRslt);
        # alternate bgcolor
        $printGrp .= "<tr class='" . bg_class() . "'><td>{$Grp['grpname']}</td><td>{$acccost['accname']}</td><td>{$acdacc['accname']}</td><td>{$accdep['accname']}</td><td><a href='assetgrp-edit.php?grpid={$Grp['grpid']}'>Edit</a></td>";
        $printGrp .= "<td><a href='assetgrp-rem.php?grpid={$Grp['grpid']}'>Remove</a></td></tr>";
        $i++;
    }
    $printGrp .= "</table>\r\n    <p>\r\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=15%>\r\n        <tr><td><br></td></tr>\r\n        <tr><th>Quick Links</th></tr>\r\n\t\t<tr class='bg-odd'><td><a href='assetgrp-new.php'>Add Asset Group</a></td></tr>\r\n\t\t<script>document.write(getQuicklinkSpecial());</script>\r\n\t</table>";
    return $printGrp;
}
开发者ID:kumarsivarajan,项目名称:accounting-123,代码行数:35,代码来源:assetgrp-view.php

示例3: getArtist

function getArtist($counter)
{
    global $artistList;
    $limit_start = $counter;
    $limit_stop = $counter + 20;
    $conn = db_connect();
    $conn->set_charset("utf8");
    // 指定数据库字符编码
    $result = $conn->query("select artist.id, artist.name, artist.avatar, company.name as company, artist.comments_number, artist.score from decoration_artist as artist, decoration_company as company WHERE artist.company = company.id LIMIT {$limit_start}, {$limit_stop} ");
    if (!$result) {
        throw new Exception('Search user score failed.');
    }
    $num_result = $result->num_rows;
    $artistList['total'] = $num_result;
    //数据库查询出来的字段全部是字符串,另外json定义跟数据库定义可能不一致,所以需要做相应地转换
    for ($i = 0; $i < $num_result; $i++) {
        $row_db = $result->fetch_assoc();
        $converted_row = array();
        //保存转换后的单条记录
        $converted_row['id'] = intval(stripslashes($row_db['id']));
        $converted_row['name'] = stripslashes($row_db['name']);
        $converted_row['avatar'] = stripslashes($row_db['avatar']);
        $converted_row['company'] = stripslashes($row_db['company']);
        $converted_row['comments'] = intval(stripslashes($row_db['comments_number']));
        $converted_row['score'] = intval(stripslashes($row_db['score']));
        $artistList["row"][$i] = $converted_row;
    }
    $result->free();
    $conn->close();
    return json_encode($artistList);
}
开发者ID:RainbowMango,项目名称:DecorationbusWeb,代码行数:31,代码来源:getArtist.php

示例4: create_backup_sql

 function create_backup_sql($file)
 {
     $line_count = 0;
     $db_connection = db_connect();
     mysql_select_db(db_name()) or exit;
     $tables = mysql_list_tables(db_name());
     $sql_string = NULL;
     while ($table = mysql_fetch_array($tables)) {
         $table_name = $table[0];
         $sql_string = "DELETE FROM {$table_name}";
         $table_query = mysql_query("SELECT * FROM `{$table_name}`");
         $num_fields = mysql_num_fields($table_query);
         while ($fetch_row = mysql_fetch_array($table_query)) {
             $sql_string .= "INSERT INTO {$table_name} VALUES(";
             $first = TRUE;
             for ($field_count = 1; $field_count <= $num_fields; $field_count++) {
                 if (TRUE == $first) {
                     $sql_string .= "'" . mysql_real_escape_string($fetch_row[$field_count - 1]) . "'";
                     $first = FALSE;
                 } else {
                     $sql_string .= ", '" . mysql_real_escape_string($fetch_row[$field_count - 1]) . "'";
                 }
             }
             $sql_string .= ");";
             if ($sql_string != "") {
                 $line_count = write_backup_sql($file, $sql_string, $line_count);
             }
             $sql_string = NULL;
         }
     }
     return $line_count;
 }
开发者ID:samjiks,项目名称:semedng,代码行数:32,代码来源:cmodel.php

示例5: write_details

function write_details($_POST)
{
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($branch_ip, "url", 1, 50, "Invalid Branch IP.");
    $v->isOk($branch_company, "url", 4, 4, "Invalid Branch Company Code.");
    $v->isOk($branch_username, "string", 1, 50, "Invalid Branch Username.");
    //	$v->isOk ($branch_password, "url", 1, 50, "Invalid Branch Password.");
    //	$v->isOk ($branch_passwordconfirm, "url", 1, 50, "Invalid Branch Password.");
    //	$v->isOk ($branch_ip, "url", 1, 50, "Invalid Branch IP.");
    if ($branch_password != $branch_passwordconfirm) {
        $v->addError($branch_password, "Passwords do not match.");
    }
    # display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        return get_details($_POST, $confirmCust);
    }
    db_connect();
    $add_sql = "\n\t\tINSERT INTO branches_data (\n\t\t\tbranch_name, branch_desc, branch_contact, branch_ip, \n\t\t\tdate_added, last_online, branch_username, branch_password, \n\t\t\tlast_login_from, branch_localuser, branch_company\n\t\t) VALUES (\n\t\t\t'{$branch_name}', '{$branch_desc}', '{$branch_contact}', '{$branch_ip}', \n\t\t\t'now', '1990-01-01', '{$branch_username}', md5('{$branch_password}'), \n\t\t\t'1990-01-01', '{$branch_localuser}', '{$branch_company}'\n\t\t)";
    $run_add = pg_exec($add_sql) or errDie("Unable to add branch information.");
    $display = "\n\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Branch Added</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<td>Branch Has Been Added.</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t";
    return $display;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:30,代码来源:branches-add.php

示例6: confirm

function confirm($catid)
{
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($catid, "num", 1, 50, "Invalid stock category id.");
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class=err>-" . $e["msg"] . "<br>";
        }
        return $confirm;
    }
    # Select Stock
    db_connect();
    $sql = "SELECT * FROM stockcat WHERE catid = '{$catid}' AND div = '" . USER_DIV . "'";
    $catRslt = db_exec($sql) or errDie("Unable to access databse.", SELF);
    if (pg_numrows($catRslt) < 1) {
        return "<li> Invalid Stock ID.";
    } else {
        $cat = pg_fetch_array($catRslt);
    }
    # get stock vars
    foreach ($cat as $key => $value) {
        ${$key} = $value;
    }
    // Layout
    $confirm = "<h3>Stock Category</h3>\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t\t<tr><th width=40%>Field</th><th width=60%>Value</th></tr>\n\t\t\t<tr class='bg-odd'><td>Category Code</td><td>{$catcod}</td></tr>\n\t\t\t<tr class='bg-even'><td>Category Name</td></td><td>{$cat}</td></tr>\n\t\t\t<tr class='bg-odd'><td valign=top>Description</td><td><pre>{$descript}</pre></td></tr>\n\t\t</table>\n\t\t<p>\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=100>\n\t\t\t<tr><th>Quick Links</th></tr>\n\t\t\t<tr class='bg-odd'><td><a href='stockcat-edit.php?catid={$catid}'>Edit</a></td></tr>\n\t\t\t<tr class='bg-even'><td><a href='stockcat-view.php'>View Stock Category</a></td></tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>";
    return $confirm;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:32,代码来源:stockcat-det.php

示例7: fill_with_random_data

function fill_with_random_data()
{
    $gen = new LoremIpsumGenerator('lorem.txt');
    $iterations = 10;
    $rows_per_iteration = 10000;
    $connection = db_connect();
    while ($iterations--) {
        $query = "INSERT INTO goods (`name`, `description`, `price`, `imgurl`) VALUES ";
        for ($i = 0; $i < $rows_per_iteration; $i++) {
            $item = [];
            $item['name'] = ucfirst(trim($gen->get_sentence()));
            $item['description'] = trim($gen->get_paragraph());
            $item['price'] = rand(1, 10000000) / 100;
            $item['imgurl'] = get_random_img_name();
            $query .= "('{$item['name']}', '{$item['description']}', '{$item['price']}', '{$item['imgurl']}')";
            if ($i + 1 != $rows_per_iteration) {
                $query .= ",";
            }
        }
        $result = mysqli_query($connection, $query);
        if (!$result) {
            die('query error: ' . mysqli_error($connection));
        }
    }
}
开发者ID:plFlok,项目名称:vk_test_task,代码行数:25,代码来源:test_data_generator.php

示例8: get_cate_post

function get_cate_post($id)
{
    $db = db_connect();
    $query = "select * from entries where category=" . $id;
    $result = $db->query($query);
    return $result;
}
开发者ID:pyhale,项目名称:PHPblog,代码行数:7,代码来源:db_fns.php

示例9: display_duck_blinds

function display_duck_blinds()
{
    $dbinfo = initialize_db_info();
    #report_database_settings($dbinfo);
    try {
        $db_link = db_connect($dbinfo);
        db_select($db_link, $dbinfo);
    } catch (Exception $e) {
        echo report_exception("Database Connection", $e);
        echo report_database_settings($dbinfo);
    }
    $sql = generate_blind_list_sql();
    $result_rows = mysql_query($sql, $db_link);
    if (!$result_rows) {
        echo $sql;
        $message = 'Invalid query: ' . mysql_error() . "\n";
        echo $message;
        throw new Exception('No Results.');
    }
    echo '<table>';
    while ($row = mysql_fetch_array($result_rows, MYSQL_ASSOC)) {
        //echo generate_blind_row($row);
    }
    echo '</table>';
}
开发者ID:coyotetracks,项目名称:PiutePonds,代码行数:25,代码来源:duck_blinds.php

示例10: show_branches

function show_branches($active_search = FALSE)
{
    db_connect();
    $get_branches = "SELECT * FROM branches_data ORDER BY branch_name";
    $run_branches = db_exec($get_branches) or errDie("Unable to get branch information.");
    if (pg_numrows($run_branches) < 1) {
        $listing = "\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<td colspan='7'>No Branches Found.</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t";
    } else {
        $listing = "";
        while ($barr = pg_fetch_array($run_branches)) {
            if ($active_search == FALSE) {
                $status = "Unknown";
            } else {
                if ($connect_test = @fsockopen("{$barr['branch_ip']}", 80, $errno, $errstr, 4)) {
                    #online ...
                    $status = "Online";
                } else {
                    $status = "Offline";
                }
            }
            $get_username = "SELECT username FROM users WHERE userid = '{$barr['branch_localuser']}' LIMIT 1";
            $run_username = db_exec($get_username) or errDie("Unable to get user information.");
            if (pg_numrows($run_username) < 1) {
            }
            $listing .= "\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td>{$barr['branch_name']}</td>\n\t\t\t\t\t\t\t\t<td>" . nl2br($barr['branch_desc']) . "</td>\n\t\t\t\t\t\t\t\t<td>{$barr['branch_username']}</td>\n\t\t\t\t\t\t\t\t<td>{$barr['branch_contact']}</td>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td>{$barr['branch_ip']}</td>\n\t\t\t\t\t\t\t\t<td>{$status}</td>\n\t\t\t\t\t\t\t\t<td><a href='branches-rem.php?bid={$barr['id']}'>Remove</a></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t";
        }
    }
    $display = "\n\t\t\t\t\t<h3>Current Branches on Cubit</h3>\n\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t\t\t\t<input type='hidden' name='key' value='confirm'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Branch Name</th>\n\t\t\t\t\t\t\t<th>Branch Description</th>\n\t\t\t\t\t\t\t<th>Branch Username</th>\n\t\t\t\t\t\t\t<th>Branch Contact</th>\n\t\t\t\t\t\t\t<th>Local Username</th>\n\t\t\t\t\t\t\t<th>Branch IP</th>\n\t\t\t\t\t\t\t<th>Status</th>\n\t\t\t\t\t\t\t<th>Remove</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t{$listing}\n\t\t\t\t\t\t<tr><td><br></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td><input type='submit' value='Update Status'></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</form>\n\t\t\t\t\t</table>\n\t\t\t\t";
    return $display;
}
开发者ID:kumarsivarajan,项目名称:accounting-123,代码行数:30,代码来源:branches-view.php

示例11: _valid_db

function _valid_db($name, $pass, $admin_auser = 0)
{
    $name = strtolower($name);
    global $dbhost, $dbuser, $dbpass, $dbdb;
    db_connect($dbhost, $dbuser, $dbpass, $dbdb);
    $query = "SELECT * FROM user WHERE user_uname='" . addslashes($name) . "'" . ($admin_auser ? "" : " AND user_pass='" . addslashes($pass) . "' AND user_authtype='db'");
    $r = db_query($query);
    //	$a = db_fetch_assoc($r);
    //	if (db_num_rows($r)  && $a['pass'] == $pass) {
    if (db_num_rows($r)) {
        $a = db_fetch_assoc($r);
        $x = array();
        // array for returned info
        $x[fullname] = $a[user_fname];
        $x[user] = $name;
        $x[pass] = $pass;
        $x[email] = $a[user_email];
        $x[type] = $a[user_type];
        $x[method] = 'db';
        $x[id] = $a[user_id];
        return $x;
    }
    /*else {
    	    $query = "select * from users where email='$name' and pass='$pass' and status='open'";
    	    $r = db_query($query);
    	    if (db_num_rows($r)) {
    	        $logmethod = "open";
    	        return $r;
    	    }
    	}*/
    return 0;
}
开发者ID:adamfranco,项目名称:segue-1.x,代码行数:32,代码来源:db.inc.php

示例12: printDep

function printDep()
{
    # Set up table to display in
    $printDep = "\n\t\t<h3>View Employee Departments</h3>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Department</th>\n\t\t\t\t<th colspan='2'>Options</th>\n\t\t\t</tr>";
    # connect to database
    db_connect();
    # Query server
    $i = 0;
    $sql = "SELECT * FROM departments ORDER BY department ASC";
    $depRslt = db_exec($sql) or errDie("Unable to retrieve employee departments from database.");
    if (pg_numrows($depRslt) < 1) {
        return "<li>There are no employee departments in Cubit.</li>";
    }
    while ($dep = pg_fetch_array($depRslt)) {
        $printDep .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center'>{$dep['department']}</td>\n\t\t\t\t<td><a href='empdepartment-edit.php?id={$dep['id']}'>Edit</a></td>";
        $sql = "SELECT * FROM employees WHERE department='{$dep['id']}'";
        $depRslt = db_exec($sql) or ereDie("Unable to retrieve employee departments from database.");
        if (pg_numrows($depRslt) < 1) {
            $printDep .= "<td><a href='empdepartment-rem.php?id={$dep['id']}'>Remove</a></td></tr>";
        } else {
            $printDep .= "</tr>";
        }
        $i++;
    }
    $printDep .= "\n\t\t</table>\n\t\t<p>\n\t\t<table " . TMPL_tblDflts . " width='15%'>\n\t\t\t<tr><td><br></td></tr>\n\t\t\t<tr>\n\t\t\t\t<th>Quick Links</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td><a href='empdepartment-add.php'>Add Employee Department</a></td>\n\t\t\t</tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>";
    return $printDep;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:27,代码来源:empdepartment-view.php

示例13: transform

function transform($x, $y, $oldEPSG, $newEPSG)
{
    if (is_null($x) || !is_numeric($x) || is_null($y) || !is_numeric($y) || is_null($oldEPSG) || !is_numeric($oldEPSG) || is_null($newEPSG) || !is_numeric($newEPSG)) {
        return null;
    }
    if (SYS_DBTYPE == 'pgsql') {
        $con = db_connect(DBSERVER, OWNER, PW);
        $sqlMinx = "SELECT X(transform(GeometryFromText('POINT(" . pg_escape_string($x) . " " . pg_escape_string($y) . ")'," . pg_escape_string($oldEPSG) . ")," . pg_escape_string($newEPSG) . ")) as minx";
        $resMinx = db_query($sqlMinx);
        $minx = floatval(db_result($resMinx, 0, "minx"));
        $sqlMiny = "SELECT Y(transform(GeometryFromText('POINT(" . pg_escape_string($x) . " " . pg_escape_string($y) . ")'," . pg_escape_string($oldEPSG) . ")," . pg_escape_string($newEPSG) . ")) as miny";
        $resMiny = db_query($sqlMiny);
        $miny = floatval(db_result($resMiny, 0, "miny"));
    } else {
        $con_string = "host=" . GEOS_DBSERVER . " port=" . GEOS_PORT . " dbname=" . GEOS_DB . "user=" . GEOS_OWNER . "password=" . GEOS_PW;
        $con = pg_connect($con_string) or die("Error while connecting database");
        /*
         * @security_patch sqli done
         */
        $sqlMinx = "SELECT X(transform(GeometryFromText('POINT(" . pg_escape_string($x) . " " . pg_escape_string($y) . ")'," . pg_escape_string($oldEPSG) . ")," . pg_escape_string($newEPSG) . ")) as minx";
        $resMinx = pg_query($con, $sqlMinx);
        $minx = floatval(pg_fetch_result($resMinx, 0, "minx"));
        $sqlMiny = "SELECT Y(transform(GeometryFromText('POINT(" . pg_escape_string($x) . " " . pg_escape_string($y) . ")'," . pg_escape_string($oldEPSG) . ")," . pg_escape_string($newEPSG) . ")) as miny";
        $resMiny = pg_query($con, $sqlMiny);
        $miny = floatval(pg_fetch_result($resMiny, 0, "miny"));
    }
    return array("x" => $minx, "y" => $miny);
}
开发者ID:bfpi,项目名称:klarschiff-frontend-mit-mapbender,代码行数:28,代码来源:mod_coordsLookup_server.php

示例14: render_tag_page

function render_tag_page($tag_name, $page)
{
    $start = (intval($page) - 1) * 20;
    $html = render_header($tag_name, "", true);
    $html .= "<div class=\"bg_menu_wrapper\">\n" . "<ul class=\"bg_menu\">\n" . "<li><a href=\"/explore/firehose\" title=\"Firehose\">Firehose</a></li>\n" . "<li><a href=\"/explore/popular\" title=\"Popular\">Popular</a></li>\n" . "<li class=\"selected\"><a href=\"/explore/tags\" title=\"Tags\">Tags</a></li>\n" . "<li><a href=\"/explore/directory\" title=\"Directory\">Directory</a></li>\n" . "<li><a href=\"/explore/suggested\" title=\"Suggested Users\">Suggested</a></li>\n" . "<li><a href=\"/explore/search\" title=\"Search\">Search</a></li>\n" . "</ul>\n" . "<div class=\"clear\"></div>\n" . "</div>\n";
    $mysqli = db_connect();
    $sql = "";
    $sql_count = "";
    if (isset($_SESSION["user_id"])) {
        $sql = "SELECT DISTINCT Posts.*,Users.Username,Users.Avatar,Likes.Id AS LikeId FROM Posts" . " INNER JOIN Users ON Posts.UserId=Users.Id" . " INNER JOIN PostTags ON Posts.Id=PostTags.PostId" . " INNER JOIN Tags ON PostTags.TagId=Tags.Id" . " LEFT OUTER JOIN Likes ON Likes.UserId=" . $mysqli->real_escape_string($_SESSION["user_id"]) . " AND Likes.PostId=Posts.Id" . " LEFT OUTER JOIN Friends FriendsA ON Posts.UserId=FriendsA.UserId" . " WHERE" . " ((FriendsA.FriendId=" . $mysqli->real_escape_string($_SESSION["user_id"]) . " AND Posts.Privacy=" . POST_PRIVACY_FRIENDS_ONLY . ")" . " OR" . " (Posts.Privacy=" . POST_PRIVACY_PUBLIC . ")" . " OR" . " (Posts.UserId=" . $mysqli->real_escape_string($_SESSION["user_id"]) . "))" . " AND Posts.Status=" . POST_STATUS_PUBLISHED . " AND Tags.Name='" . $mysqli->real_escape_string($tag_name) . "'" . " ORDER BY Created DESC LIMIT " . $mysqli->real_escape_string($start) . ",20";
        $sql_count = "SELECT COUNT(DISTINCT Posts.Id) AS NumPosts FROM Posts" . " INNER JOIN Users ON Posts.UserId=Users.Id" . " INNER JOIN PostTags ON Posts.Id=PostTags.PostId" . " INNER JOIN Tags ON PostTags.TagId=Tags.Id" . " LEFT OUTER JOIN Friends FriendsA ON Posts.UserId=FriendsA.UserId" . " WHERE" . " ((FriendsA.FriendId=" . $mysqli->real_escape_string($_SESSION["user_id"]) . " AND Posts.Privacy=" . POST_PRIVACY_FRIENDS_ONLY . ")" . " OR" . " (Posts.Privacy=" . POST_PRIVACY_PUBLIC . ")" . " OR" . " (Posts.UserId=" . $mysqli->real_escape_string($_SESSION["user_id"]) . "))" . " AND Posts.Status=" . POST_STATUS_PUBLISHED . " AND Tags.Name='" . $mysqli->real_escape_string($tag_name) . "'";
    } else {
        $sql = "SELECT DISTINCT Posts.*,Users.Username,Users.Avatar FROM Posts" . " INNER JOIN Users ON Posts.UserId=Users.Id" . " INNER JOIN PostTags ON Posts.Id=PostTags.PostId" . " INNER JOIN Tags ON PostTags.TagId=Tags.Id" . " WHERE" . " Posts.Privacy=" . POST_PRIVACY_PUBLIC . " AND Posts.Status=" . POST_STATUS_PUBLISHED . " AND Tags.Name='" . $mysqli->real_escape_string($tag_name) . "'" . " ORDER BY Created DESC LIMIT " . $mysqli->real_escape_string($start) . ",20";
        $sql_count = "SELECT COUNT(DISTINCT Posts.Id) AS NumPosts FROM Posts" . " INNER JOIN Users ON Posts.UserId=Users.Id" . " INNER JOIN PostTags ON Posts.Id=PostTags.PostId" . " INNER JOIN Tags ON PostTags.TagId=Tags.Id" . " WHERE" . " Posts.Privacy=" . POST_PRIVACY_PUBLIC . " AND Posts.Status=" . POST_STATUS_PUBLISHED . " AND Tags.Name='" . $mysqli->real_escape_string($tag_name) . "'";
    }
    // fetch count for pagination
    $count_result = $mysqli->query($sql_count);
    $count_row = $count_result->fetch_assoc();
    $count = $count_row["NumPosts"];
    $post_result = $mysqli->query($sql);
    $html .= "<div id=\"header\"><h1>Posts tagged &#8216;<span>" . $tag_name . "</span>&#8217;</h1></div>\n";
    $html .= render_posts($mysqli, $post_result);
    $html .= render_pagination("explore/tag/" . $tag_name, $page, $count, 20);
    $html .= render_display_controls();
    $html .= render_footer();
    return $html;
}
开发者ID:jonbeckett,项目名称:wetheusers,代码行数:27,代码来源:tag.php

示例15: printInv

function printInv()
{
    # Set up table to display in
    $printQuo = "\n\t\t\t\t\t<h3>View previous POS Quotes</h3>\n\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Department</th>\n\t\t\t\t\t\t\t<th>Sales Person</th>\n\t\t\t\t\t\t\t<th>Quote No.</th>\n\t\t\t\t\t\t\t<th>Quote Date</th>\n\t\t\t\t\t\t\t<th>Customer Name</th>\n\t\t\t\t\t\t\t<th>Order No</th>\n\t\t\t\t\t\t\t<th>Grand Total</th>\n\t\t\t\t\t\t\t<th colspan='6'>Options</th>\n\t\t\t\t\t\t\t<th>Email</th>\n\t\t\t\t\t\t</tr>";
    # connect to database
    db_connect();
    # Query server
    $i = 0;
    $sql = "SELECT * FROM pos_quotes WHERE accepted != 'c' AND done = 'y' AND div = '" . USER_DIV . "' ORDER BY quoid DESC";
    $quoRslt = db_exec($sql) or errDie("Unable to retrieve quotes from database.");
    if (pg_numrows($quoRslt) < 1) {
        $printQuo = "<li>No previous quotes.</li>";
    } else {
        while ($quo = pg_fetch_array($quoRslt)) {
            # format date
            $quo['odate'] = explode("-", $quo['odate']);
            $quo['odate'] = $quo['odate'][2] . "-" . $quo['odate'][1] . "-" . $quo['odate'][0];
            $printQuo .= "\n\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t<td>{$quo['deptname']}</td>\n\t\t\t\t\t\t\t\t\t<td>{$quo['salespn']}</td>\n\t\t\t\t\t\t\t\t\t<td>{$quo['quoid']}</td>\n\t\t\t\t\t\t\t\t\t<td align='center'>{$quo['odate']}</td>\n\t\t\t\t\t\t\t\t\t<td>{$quo['cusname']} {$quo['surname']}</td>\n\t\t\t\t\t\t\t\t\t<td align=right>{$quo['ordno']}</td>\n\t\t\t\t\t\t\t\t\t<td>" . CUR . " {$quo['total']}</td>\n\t\t\t\t\t\t\t\t\t<td><a href='pos-quote-details.php?quoid={$quo['quoid']}'>Details</a></td>";
            if ($quo['accepted'] == 'n') {
                $printQuo .= "\n\t\t\t\t\t\t\t\t\t<td><a href='pos-quote-new.php?quoid={$quo['quoid']}&cont=true&done='>Edit</a></td>\n\t\t\t\t\t\t\t\t\t<td><a href='pos-quote-cancel.php?quoid={$quo['quoid']}'>Cancel</a></td>\n\t\t\t\t\t\t\t\t\t<td><a href='pos-quote-accept.php?quoid={$quo['quoid']}'>Accept</a></td>\n\t\t\t\t\t\t\t\t\t<td><a href='pos-quote-print.php?quoid={$quo['quoid']}' target='_blank'>Print</a></td>\n\t\t\t\t\t\t\t\t\t<td><a href='pdf/pos-quote-pdf-print.php?quoid={$quo['quoid']}' target='_blank'>Print in PDF</a></td>\n\t\t\t\t\t\t\t\t\t<td><input type='checkbox' name='evs[]' value='{$quo['quoid']}'></td>\n\t\t\t\t\t\t\t\t</tr>";
            } else {
                $printQuo .= "\n\t\t\t\t\t\t\t\t\t<td colspan='3'>Accepted</td>\n\t\t\t\t\t\t\t\t\t<td><a href='pos-quote-print.php?quoid={$quo['quoid']}' target='_blank'>Print</a></td>\n\t\t\t\t\t\t\t\t\t<td><a href='pdf/pos-quote-pdf-print.php?quoid={$quo['quoid']}' target='_blank'>Print in PDF</a></td>\n\t\t\t\t\t\t\t\t\t<td><input type='checkbox' name='evs[]' value='{$quo['quoid']}'></td>\n\t\t\t\t\t\t\t\t</tr>";
            }
            $i++;
        }
        $printQuo .= "\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td colspan='14' align='right'><input type='submit' name='key' value='Send Emails'></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t";
    }
    // Layout
    $printQuo .= "\n\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t\t\t<tr><td><br></td></tr>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<th>Quick Links</th>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr class='datacell'>\n\t\t\t\t\t\t\t\t\t<td align='center'><a href='pos-quote-new.php'>New POS Quote</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr class='datacell'>\n\t\t\t\t\t\t\t\t\t<td align='center'><a href='main.php'>Main Menu</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</table>";
    return $printQuo;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:31,代码来源:pos-quote-view.php


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