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


PHP fetch_array函数代码示例

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


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

示例1: get_products

function get_products()
{
    $query = query("SELECT * FROM products");
    confirm($query);
    while ($row = fetch_array($query)) {
        $product = <<<DELIMITER

<div class="col-sm-4 col-lg-4 col-md-4">
                        <div class="thumbnail">
                            <a href="item.php?id={$row['product_id']}"><img src="{$row['product_image']}" alt=""></a>
                            <div class="caption">
                                <h4 class="pull-right">&#36;{$row['product_price']}</h4>
                                <h4><a href="item.php?id={$row['product_id']}">{$row['product_title']}</a>
                                </h4>
                                <p>See more snippets like this online store item at <a target="_blank" href="http://www.bootsnipp.com">Bootsnipp - http://bootsnipp.com</a>.</p>
                                <a class="btn btn-primary" target="_blank" href="../resources/cart.php?add={$row['product_id']}">Add to Cart</a>
                            </div>

                        </div>
                    </div>

DELIMITER;
        echo $product;
    }
}
开发者ID:abhsag24,项目名称:it-mini-project,代码行数:25,代码来源:functions.php

示例2: saveDjai

function saveDjai($djai)
{
    $query = "SELECT * FROM djais d WHERE d.number = '" . $djai->number . "'";
    $result = mysql_query($query);
    $num_results = mysql_num_rows($result);
    $rows = fetch_array($result);
    $obj->successful = false;
    $obj->isNew = false;
    if ($num_results != 0) {
        // update (no fields for the moment to update)
        //		if(mysql_query($update))
        $obj->successful = true;
    } else {
        // insert
        foreach ($djai->cloths as $cloth) {
            $insert = "INSERT INTO djais VALUES ('" . $cloth->djaiId . "', '" . $djai->number . "', curdate(), '" . $cloth->amount . "', '" . $cloth->id . "')";
            if (mysql_query($insert)) {
                $obj->successful = true;
                $obj->isNew = true;
            }
        }
    }
    if ($obj->successful && !$obj->isNew) {
        handleCloths($djai, $rows, $obj);
    }
    $obj->djai = $djai;
    return $obj;
}
开发者ID:eznibe,项目名称:north-telas,代码行数:28,代码来源:djais_POST.php

示例3: saveGroup

function saveGroup($group)
{
    $obj->successful = true;
    $obj->isNew = !isset($group->id);
    if ($obj->isNew) {
        $query = "SELECT max(id) as maxid FROM groups";
        $result = mysql_query($query);
        $num_results = mysql_num_rows($result);
        $rows = fetch_array($result);
        if ($num_results > 0) {
            // unique result
            $group->id = $rows[0]['maxid'] + 1;
        }
        // insert new group
        $insert = "INSERT INTO groups VALUES ('" . $group->id . "', '" . $group->name . "')";
        if (!mysql_query($insert)) {
            $obj->successful = false;
            $obj->insert = $insert;
        }
    } else {
        $update = "UPDATE groups SET name = '" . $group->name . "' WHERE id = '" . $group->id . "'";
        if (!mysql_query($update)) {
            $obj->successful = false;
        }
        $obj->update = $update;
    }
    $obj->group = $group;
    return $obj;
}
开发者ID:eznibe,项目名称:north-telas,代码行数:29,代码来源:groups.php

示例4: index

 function index()
 {
     $indexPushType = $this->indexPushType;
     $tid = getgpc("tid");
     $data["tid"] = $tid;
     $data["indexPushType"] = $indexPushType;
     //面包屑导航
     $menuadd = array("name" => $indexPushType[$tid], 'link' => "?mod=indexpush&tid=" . $tid);
     $data['headpagemenu'] = $this->createmenu($menuadd);
     $data['headpagetitle'] = $indexPushType[$tid];
     //左侧菜单
     $data['menumod'] = "indexpush";
     //
     //数据总量
     $count = fetch_one_array("select count(*) as num from " . dbtable("indexpush") . " where tid ='" . $tid . "' and status>=1 ");
     //分页
     $per_page = getgpc("per_page");
     $per_page = $per_page ? $per_page : 0;
     $pnum = 20;
     $this->load->library('pagination');
     $config['base_url'] = 'admin.php?mod=indexpush&tid=' . $tid;
     $config['total_rows'] = $count["num"];
     $config['per_page'] = $pnum;
     $this->pagination->initialize($config);
     $data["page"] = $this->pagination->create_links();
     $list = fetch_array("select * from " . dbtable("indexpush") . " where tid ='" . $tid . "' and status>=1 order by istop desc,displayorder desc, id desc limit {$per_page},{$pnum} ");
     $data["reslist"] = $list;
     $this->load->view('indexpush_index', $data);
 }
开发者ID:visonforcoding,项目名称:cidev,代码行数:29,代码来源:indexpush.php

示例5: display_users

function display_users()
{
    $category_query = query("SELECT * FROM users");
    confirm($category_query);
    while ($row = fetch_array($category_query)) {
        $user_id = $row['user_id'];
        $username = $row['username'];
        $first_name = $row['first_name'];
        $email = $row['email'];
        $active = $row['active'];
        $type = $row['type'];
        $user = <<<DELIMETER
<tr>
    <td>{$user_id}</td>
    <td>{$username}</td>
    <td>{$first_name}</td>
     <td>{$email}</td>
     <td>{$active}</td>
     <td>{$type}</td>
DELIMETER;
        echo $user;
        $user1 = <<<DELIMETER
\t<td><a class="btn btn-warning" href="/admin?edit_user&id={$row['user_id']}"><span class="glyphicon glyphicon glyphicon-pencil"></span></a></td>
    <td><a class="btn btn-danger" href="html/php/includes/admin/delete_user.php?id={$row['user_id']}"><span class="glyphicon glyphicon-remove"></span></a></td>
</tr>
DELIMETER;
        if ($row['user_id'] != 1) {
            echo $user1;
        }
    }
}
开发者ID:rakshans1,项目名称:shoppcart,代码行数:31,代码来源:users.php

示例6: getListOfBuyClicks

function getListOfBuyClicks($dt)
{
    global $mycatid;
    $str = "";
    $lnk = dbConnect('localhost', 'root', 'lyntik');
    $query = "SELECT b.fdate as fdate,b.ip as cip,b.goodid as gid,b.name as sname,b.source as src,b.price as price  FROM buylog b WHERE b.date='{$dt}' AND b.mycat_id={$mycatid} ORDER BY b.ip,b.fdate";
    $res = exec_query($query);
    $ip = "0.0.0.0";
    $i = 0;
    $str .= "<div class=\"all_clicks\">";
    $str .= "<div class=\"click_row_title\">\n             <div class=\"left click_date title\">Дата</div>\n             <div class=\"left click_id title\">ID товара</div>\n             <div class=\"left click_name title\">Наименование</div>\n             <div class=\"left click_id title\">Цена</div>\n             <div class=\"left click_name title\">Источник</div>\n             " . closeFloat() . "\n            </div>";
    if (mysql_num_rows($res) == 0) {
        $str .= "<div>За выбранную дату нажатий не было</div>";
    } else {
        while ($rows = fetch_array($res)) {
            if ($ip != $rows['cip']) {
                $ip = $rows['cip'];
                if ($i != 0) {
                    $str .= "</div>";
                }
                $str .= "<div class=\"ipclicks\">";
                $str .= "<div class=\"client_ip\">Клики с адреса:<b>" . $rows['cip'] . "</b></div>";
            }
            $str .= "<div class=\"click_row\">\n             <div class=\"left click_date\">" . $rows['fdate'] . "</div>\n             <div class=\"left click_id\">" . $rows['gid'] . "</div>\n             <div class=\"left click_name\">" . $rows['sname'] . "</div>\n             <div class=\"left click_id\">" . $rows['price'] . "</div>\n             <div class=\"left click_name\">" . $rows['src'] . "</div>\n             " . closeFloat() . "\n            </div>";
        }
        $str .= "</div>";
    }
    $str .= "</div></div>";
    mysql_free_result($res);
    dbDisconnect($lnk);
    return $str;
}
开发者ID:xent1986,项目名称:ychebgit,代码行数:32,代码来源:myhist.php

示例7: echoPage

function echoPage($page, $limit)
{
    $dbLink = db_connect_syslog(DBUSER, DBUSERPW);
    if ($limit <= 10) {
        echo " <a href='wres.php?page={$page}&limit=" . ($limit + 10) . "' class='load_more'></a\t";
        $sqllimit = "0,{$limit}";
    } else {
        $sqllimit = "10,{$limit}";
    }
    echo "<div style=\"width: 310px; margin-bottom: 5px; margin-left: 5px; text-align: center; font-size: 5px;\">";
    echo " <table> ";
    if ($page == "tail") {
        if ($limit <= 10) {
            echo "\n\t\t\t   \t<td class=\"wapresultsheader\">HOST</td>\n\t\t\t   \t<td class=\"wapresultsheader\">TIME</td>\n\t\t\t   \t<td class=\"wapresultsheader\">MESSAGE</td>\n\t\t\t   \t";
        }
        $query = "SELECT * FROM logs JOIN (select seq from logs FORCE INDEX(PRIMARY) ORDER BY seq DESC LIMIT {$sqllimit}) as sub USING(seq)";
    }
    if ($page == "topx") {
        if ($limit <= 10) {
            echo "\n\t\t\t   \t<td class=\"wapresultsheader\">HOST</td>\n\t\t\t   \t<td class=\"wapresultsheader\">COUNT</td>\n\t\t\t   \t<td class=\"wapresultsheader\">MESSAGE</td>\n\t\t\t   \t";
        }
        if (defined('SQZ_ENABLED') && SQZ_ENABLED == TRUE) {
            $query = "SELECT host,counter as count,msg from logs WHERE counter>1 ORDER BY counter DESC LIMIT {$sqllimit}";
        } else {
            $query = "SELECT host,count(*) as count,msg from logs GROUP BY host ORDER BY count DESC LIMIT {$sqllimit}";
        }
    }
    $results = perform_query($query, $dbLink);
    $color = "waplighter";
    $today = date('Y-m-d');
    while ($row = fetch_array($results)) {
        if ($color == "wapdarker") {
            $color = "waplighter";
        } else {
            $color = "wapdarker";
        }
        echo "<tr class=\"{$color}\">";
        echo "<td>" . $row['host'] . "</td>";
        if ($page == "tail") {
            $pieces = explode(" ", $row['datetime']);
            echo '<td>';
            if ($pieces[0] != $today) {
                echo $pieces[0] . "&nbsp;";
            }
            echo $pieces[1];
        }
        if ($page == "topx") {
            echo '<td>';
            echo $row['count'] . "&nbsp;";
        }
        echo "</td>\n";
        $row['msg'] = preg_replace('/\\s:/', ':', $row['msg']);
        $row['msg'] = preg_replace('/.*(%.*?:.*)/', '$1', $row['msg']);
        $msg = htmlspecialchars($row['msg']);
        echo "<td>";
        echo "{$msg}</td>\n";
        echo "</tr>\n";
    }
    echo "</div>\n";
}
开发者ID:jeroenrnl,项目名称:php-syslog-ng,代码行数:60,代码来源:wres.php

示例8: index

 function index()
 {
     ////面包屑导航
     //        $data['headpagemenu']=array(
     //            0=>array('name'=>'后台','link'=>"admin.php"),
     //            1=>array('name'=>'网站概况','link'=>""),
     //        );
     //        $data['headpagetitle']="网站概况";
     ////左侧菜单
     //        $data['menumod']="index";
     $product_tech = $this->config->item("product_tech");
     $res = array();
     foreach ($product_tech[4] as $key => $row) {
         $list = fetch_array("select p.* from " . dbtable("product_tech") . " t," . dbtable("product") . " p where t.pid=p.id and t.type='{$key}'");
         $res[$key] = $list;
     }
     $data["list"] = $res;
     if (checkmobile()) {
         $this->load->view('mobile/safety', $data);
     } else {
         $data['tech_type'] = "4";
         $data['type_id'] = "4_1";
         $this->load->view('safety', $data);
     }
 }
开发者ID:visonforcoding,项目名称:cidev,代码行数:25,代码来源:safety.php

示例9: links

function links($cat = 0, $direction = "asc")
{
    global $linksmessage, $prefix;
    if ($direction != "asc" && $direction != "desc") {
        $direction = "asc";
    }
    $out = "";
    if ($cat) {
        $query = "SELECT * FROM " . $prefix . "linkscat WHERE id=" . $cat . " ORDER BY nome";
    } else {
        $query = "SELECT * FROM " . $prefix . "linkscat ORDER BY nome";
    }
    if (!($cresult = dbquery($query))) {
        die($linksmessage[4]);
    }
    $out .= "\n<div id=\"LNE_show\">\n";
    while ($crow = fetch_array($cresult)) {
        $out .= "<h3>" . decode($crow['descr']) . "</h3>\n";
        $query = "SELECT * FROM " . $prefix . "links where hits=" . $crow[0] . " ORDER BY name " . $direction;
        if (!($result = dbquery($query))) {
            die($linksmessage[5]);
        }
        if (num_rows($result)) {
            $out .= "<ul>\n";
            while ($row = fetch_array($result)) {
                $out .= "<li><a href=\"" . $row['link'] . "\" onclick=\"window.open(this.href,'_blank');return false;\">" . decode($row['name']) . "</a><div>" . decode($row['descr']) . "</div></li>\n";
            }
            $out .= "</ul>\n";
        }
    }
    $out .= "</div>\n";
    return $out;
}
开发者ID:squidjam,项目名称:LightNEasy,代码行数:33,代码来源:main.php

示例10: construire_tableau

function construire_tableau($theme = 0, $pertinence = 0, $diff = 0, $nbQuestions)
{
    $connexion = connect($host, $port, $user, $password, $database);
    //On récupère un recordset correspondant aux critères
    $query = "SELECT Q.noq, Q.question, Q.reponse " . "FROM questions Q";
    /* ", sujets S, themes T, pertinences P, difficultes D ".
    	"WHERE Q.noq = S.noq AND S.theme = T.theme AND ".
    	"S.pertinence = P.pertinence AND S.difficulte = D.difficulte".
    	"AND S.theme = ". $theme ." AND S.pertinence = ". $pertinence ." AND S.difficulte = ". $diff .";";
    */
    $result = exec_query($connexion, $query);
    $Nbr = numrows($result);
    echo "Nombre d'enregistrements : " . $Nbr . "<BR>";
    //Organisation aléatoire des questions
    $ints = range(0, $Nbr - 1);
    srand(time());
    shuffle($ints);
    if ($Nbr < $nbQuestions) {
        $nbQuestions = $Nbr;
    }
    // On construit le tableau permettant de trier aléatoirement
    for ($i = 0; $i < $nbQuestions && ($row = fetch_array($result, $ints[$i])); $i++) {
        echo "libelle Q : " . $row[1] . "<BR>";
        $tabQ[$i][0] = $row[0];
        // recuperation du numero,
        $tabQ[$i][1] = $row[1];
        // du libelle,
        $tabQ[$i][2] = $row[2];
        // de la reponse a la question
    }
    close($connexion);
    return $tabQ;
}
开发者ID:pierrechtux,项目名称:QCV,代码行数:33,代码来源:script_qcm.php

示例11: saveCloth

function saveCloth($cloth)
{
    global $country;
    $query = "SELECT * FROM cloths c WHERE c.id = '" . $cloth->id . "'";
    $result = mysql_query($query);
    $num_results = mysql_num_rows($result);
    $rows = fetch_array($result);
    $obj->successful = false;
    if ($num_results != 0) {
        // update
        $update = "UPDATE cloths SET name = '" . $cloth->name . "', stockMin = " . $cloth->stockMin . ", groupId = '" . $cloth->groupId . "' WHERE id = '" . $cloth->id . "'";
        if (mysql_query($update)) {
            $obj->successful = true;
        }
    } else {
        // insert
        $groupId = $cloth->groupId ? "'" . $cloth->groupId . "'" : 'null';
        $matchId = uniqid();
        $insert = "INSERT INTO cloths (id, name, stockMin, groupId, matchClothId, country) VALUES ('" . $cloth->id . "', '" . $cloth->name . "', '" . $cloth->stockMin . "', {$groupId}, '{$matchId}', '{$country}')";
        if (mysql_query($insert)) {
            $obj->successful = true;
            $obj->isNew = true;
            $otherCountry = $country == 'ARG' ? 'BRA' : 'ARG';
            $insert = "INSERT INTO cloths (id, name, stockMin, groupId, matchClothId, country) VALUES ('" . uniqid() . "', '" . $cloth->name . "', '" . $cloth->stockMin . "', {$groupId}, '{$matchId}', '{$otherCountry}')";
            if (!mysql_query($insert)) {
                $obj->successful = false;
                $obj->insert = $insert;
            }
        }
    }
    $obj->cloth = $cloth;
    return $obj;
}
开发者ID:eznibe,项目名称:north-telas,代码行数:33,代码来源:cloths_POST.php

示例12: index

 function index()
 {
     $pid = $_POST["compareid"];
     //读取所有的床垫的TID
     $mattessTid_t = fetch_array("select id from " . dbtable("product_type") . " where id='2' or upid='2'");
     $mattessType = array();
     foreach ($mattessTid_t as $row) {
         $mattessTid[] = $row["id"];
         $mattessType[$row["tid"]] = $row["tname"];
     }
     $comtype = fetch_array("select * from " . dbtable("product_compare") . " where 1 and status=1 order by  displayorder desc, id asc");
     $data["comtype"] = $comtype;
     foreach ($pid as $row) {
         $res_one = fetch_one_array("select * from " . dbtable("product") . " where id='" . $row . "' ");
         if (in_array($res_one["tid"], $mattessTid)) {
             $resimage = fetch_one_array("select imgurl from " . dbtable("product_img") . " where pid='" . $row . "' and status='1' order by  displayorder limit 1");
             $res_one["compare"] = unserialize($res_one["compare"]);
             $res_one['com_imgurl'] = $resimage['imgurl'];
             $res[] = $res_one;
         }
     }
     $data["mattessType"] = $mattessType;
     $data["reslist"] = $res;
     $this->load->view('compare', $data);
     //dump($res);
 }
开发者ID:visonforcoding,项目名称:cidev,代码行数:26,代码来源:compare.php

示例13: getOneDesignSails

function getOneDesignSails()
{
    global $country;
    $query = "SELECT sailPrefix as sail FROM onedesign o GROUP BY sailPrefix ORDER BY sailPrefix";
    $result = mysql_query($query);
    return fetch_array($result);
}
开发者ID:eznibe,项目名称:north-telas,代码行数:7,代码来源:sails.php

示例14: executeQuery

function executeQuery($query)
{
    $query = str_replace("\\", "", $query);
    if ($result = mysql_query($query)) {
        return fetch_array($result);
    }
    return $query;
}
开发者ID:eznibe,项目名称:north-telas,代码行数:8,代码来源:queries.php

示例15: rowCount

 function rowCount($query)
 {
     $count = 0;
     while ($data = fetch_array($query)) {
         $count++;
     }
     return $count;
 }
开发者ID:atarubi,项目名称:php-team-training,代码行数:8,代码来源:class.db.php


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