• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mysql_query函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getEventbriteEvents

function getEventbriteEvents($eb_keywords, $eb_city, $eb_proximity)
{
    global $eb_app_key;
    $xml_url = "https://www.eventbrite.com/xml/event_search?...&within=50&within_unit=M&keywords=" . $eb_keywords . "&city=" . $eb_city . "&date=This+month&app_key=" . $eb_app_key;
    echo $xml_url . "<br />";
    $xml = simplexml_load_file($xml_url);
    $count = 0;
    // loop over events from eventbrite xml
    foreach ($xml->event as $event) {
        // add event if it doesn't already exist
        $event_query = mysql_query("SELECT * FROM events WHERE id_eventbrite={$event->id}") or die(mysql_error());
        if (mysql_num_rows($event_query) == 0) {
            echo $event_id . " ";
            // get event url
            foreach ($event->organizer as $organizer) {
                $event_organizer_url = $organizer->url;
            }
            // get event address
            foreach ($event->venue as $venue) {
                $event_venue_address = $venue->address;
                $event_venue_city = $venue->city;
                $event_venue_postal_code = $venue->postal_code;
            }
            // get event title
            $event_title = str_replace(array("\r\n", "\r", "\n"), ' ', $event->title);
            // add event to database
            mysql_query("INSERT INTO events (id_eventbrite, \n                                      title,\n                                      created, \n                                      organizer_name, \n                                      uri, \n                                      start_date, \n                                      end_date, \n                                      address\n                                      ) VALUES (\n                                      '{$event->id}',\n                                      '" . parseInput($event_title) . "',\n                                      '" . strtotime($event->created) . "',\n                                      '" . trim(parseInput($event->organizer->name)) . "',\n                                      '{$event_organizer_url}',\n                                      '" . strtotime($event->start_date) . "',\n                                      '" . strtotime($event->end_date) . "',\n                                      '{$event_venue_address}, {$event_venue_city}, {$event_venue_postal_code}'\n                                      )") or die(mysql_error());
        }
        $count++;
    }
}
开发者ID:nickhammond,项目名称:represent-map,代码行数:31,代码来源:events_get.php


示例2: createMainDataElement

function createMainDataElement($plan, $num, $dbConn)
{
    if ($plan['dato_principal_' . $num] != NULL) {
        $query_dato = sprintf("SELECT * FROM tipoDatosServicios WHERE id_tipoDato=%s", GetSQLValueString($plan['id_tipoDato_principal_' . $num], "int"));
        $dato = mysql_query($query_dato, $dbConn) or die(mysql_error());
        $row_dato = mysql_fetch_assoc($dato);
        $display = true;
        $label = "";
        if ($row_dato['tipo'] == "boolean") {
            if ($plan['dato_principal_' . $num] == "1") {
                $label = $row_dato['label'];
            } else {
                $display = false;
            }
        } else {
            if ($row_dato['display_label']) {
                $label = $plan['dato_principal_' . $num] . " " . $row_dato['label'];
            } else {
                $label = $plan['dato_principal_' . $num];
            }
        }
        if ($display) {
            echo "<div class='dato'>";
            echo "\t<li class='tipo_" . $plan['id_tipoDato_principal_' . $num] . "' value='" . $plan['dato_principal_' . $num] . "'>";
            echo $label;
            echo "\t</li>";
            echo "</div>";
        }
    }
    //if
}
开发者ID:designomx,项目名称:eligefacil,代码行数:31,代码来源:comparadorBackup.php


示例3: grabar_venta

 public function grabar_venta($pedido, $cliente, $tipo_documento, $nro_documento, $serie_documento)
 {
     $query = "INSERT INTO ventas(ped_id,cli_id,ven_fecha,ven_estado,ven_nrodoc,tipc_id,ven_seriedoc) VALUES ('{$pedido}','{$cliente}','" . date('y-m-d') . "','0','{$nro_documento}','{$tipo_documento}','{$serie_documento}')";
     $rs = mysql_query($query);
     $_SESSION['venta_codigo'] = mysql_insert_id();
     return $rs;
 }
开发者ID:kailIII,项目名称:Sistema-de-ventas-1.0,代码行数:7,代码来源:ventas_data.php


示例4: db

 function db($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = 'utf8', $pconnect = 0)
 {
     if ($pconnect) {
         if (!($this->mlink = @mysql_pconnect($dbhost, $dbuser, $dbpw))) {
             $this->halt('Can not connect to MySQL');
         }
     } else {
         if (!($this->mlink = @mysql_connect($dbhost, $dbuser, $dbpw))) {
             $this->halt('Can not connect to MySQL');
         }
     }
     if ($this->version() > '4.1') {
         if ('utf-8' == strtolower($dbcharset)) {
             $dbcharset = 'utf8';
         }
         if ($dbcharset) {
             mysql_query("SET character_set_connection={$dbcharset}, character_set_results={$dbcharset}, character_set_client=binary", $this->mlink);
         }
         if ($this->version() > '5.0.1') {
             mysql_query("SET sql_mode=''", $this->mlink);
         }
     }
     if ($dbname) {
         mysql_select_db($dbname, $this->mlink);
     }
 }
开发者ID:eappl,项目名称:prototype,代码行数:26,代码来源:db.class.php


示例5: getTangentText

function getTangentText($type, $keyword)
{
    global $dbHost, $dbUser, $dbPassword, $dbName;
    $link = @mysql_connect($dbHost, $dbUser, $dbPassword);
    if (!$link) {
        die("Cannot connect : " . mysql_error());
    }
    if (!@mysql_select_db($dbName, $link)) {
        die("Cannot find database : " . mysql_error());
    }
    $result = mysql_query("SELECT sr_keywords, sr_text FROM soRandom WHERE sr_type = '" . $type . "' ORDER BY sr_ID ASC;", $link);
    $tempCounter = 0;
    while ($row = mysql_fetch_assoc($result)) {
        $pKey = "/" . $keyword . "/";
        $pos = preg_match($pKey, $row['sr_keywords']);
        //echo $pos . " is pos<br>";
        //echo $keyword;
        //echo " is keyword and this is the search return: " . $row['keywords'];
        if ($pos != 0) {
            $text[$tempCounter] = stripslashes($row["sr_text"]);
            $tempCounter++;
        }
    }
    mysql_close($link);
    //$text=htmlentities($text);
    return $text;
}
开发者ID:ui-libraries,项目名称:TIRW,代码行数:27,代码来源:includes.php


示例6: Query

 function Query($sqlString)
 {
     if (!($resourseId = @mysql_query($sqlString, $this->dbId))) {
         die("<b>MySQL</b>: Unable to execute<br /><b>SQL</b>: " . $sqlString . "<br /><b>Error (" . mysql_errno() . ")</b>: " . @mysql_error());
     }
     return $resourseId;
 }
开发者ID:serg-smirnoff,项目名称:autobroker,代码行数:7,代码来源:db.class.php


示例7: executesql

function executesql($sql, $link)
{
    if (!mysql_query($sql, $link)) {
        die('Error: ' . mysql_error());
        exit(0);
    }
}
开发者ID:Arpitkohale,项目名称:E3gblntwrk,代码行数:7,代码来源:function_common_58462554.php


示例8: dataInsert

 function dataInsert($table, $dataArray)
 {
     $fldArray = $dataArray;
     $i = 0;
     $j = 0;
     $sql .= "insert into `" . $table . "` (";
     while (list($key1, $value1) = each($fldArray)) {
         $sql .= "`" . $key1 . "`";
         $j++;
         if ($j != count($fldArray)) {
             $sql .= ",";
         }
         if ($j == count($fldArray)) {
             $sql .= ") VALUES (";
         }
     }
     while (list($key1, $value1) = each($dataArray)) {
         $sql .= "'" . $value1 . "'";
         $i++;
         if ($i != count($dataArray)) {
             $sql .= ",";
         }
         if ($i == count($dataArray)) {
             $sql .= ")";
         }
     }
     mysql_query($sql) or die(CHECK_QUERY . $sql);
     $id = mysql_insert_id();
     return $id;
 }
开发者ID:mix376,项目名称:biverr,代码行数:30,代码来源:db_recommend.php


示例9: checkIndividually

function checkIndividually()
{
    #----------------------------------------------------------------------
    global $competitionCondition, $chosenWhich;
    echo "<hr /><p>Checking <b>" . $chosenWhich . " individual results</b>... (wait for the result message box at the end)</p>\n";
    #--- Get all results (id, values, format, round).
    $dbResult = mysql_query("\n    SELECT\n      result.id, formatId, roundId, personId, competitionId, eventId, result.countryId,\n      value1, value2, value3, value4, value5, best, average\n    FROM Results result, Competitions competition\n    WHERE competition.id = competitionId\n      {$competitionCondition}\n    ORDER BY formatId, competitionId, eventId, roundId, result.id\n  ") or die("<p>Unable to perform database query.<br/>\n(" . mysql_error() . ")</p>\n");
    #--- Build id sets
    $countryIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Countries")));
    $competitionIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Competitions")));
    $eventIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Events")));
    $formatIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Formats")));
    $roundIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Rounds")));
    #--- Process the results.
    $badIds = array();
    echo "<pre>\n";
    while ($result = mysql_fetch_array($dbResult)) {
        if ($error = checkResult($result, $countryIdSet, $competitionIdSet, $eventIdSet, $formatIdSet, $roundIdSet)) {
            extract($result);
            echo "Error: {$error}\nid:{$id} format:{$formatId} round:{$roundId}";
            echo " ({$value1},{$value2},{$value3},{$value4},{$value5}) best+average({$best},{$average})\n";
            echo "{$personId}   {$countryId}   {$competitionId}   {$eventId}\n\n";
            $badIds[] = $id;
        }
    }
    echo "</pre>";
    #--- Free the results.
    mysql_free_result($dbResult);
    #--- Tell the result.
    noticeBox2(!count($badIds), "All checked results pass our checking procedure successfully.<br />" . wcaDate(), count($badIds) . " errors found. Get them with this:<br /><br />SELECT * FROM Results WHERE id in (" . implode(', ', $badIds) . ")");
}
开发者ID:Baiqiang,项目名称:worldcubeassociation.org,代码行数:31,代码来源:check_results.php


示例10: consulta

	function consulta($sql=""){
		if($sql!="")
		{
			$this->consultaId=mysql_query($sql,$this->conexionId);
			return $this->consultaId;
		}
	}
开发者ID:rommelxcastro,项目名称:CRI-Online-Sales---Admin,代码行数:7,代码来源:clases.class.php


示例11: get_user_paid_expenses_test

function get_user_paid_expenses_test($userid_array)
{
    if (is_array($userid_array)) {
        $userids = implode(",", $userid_array);
    } else {
        $userids = $userid_array;
    }
    $sql = "SELECT user_id as userid, expense_id as exid, group_id, amount, UNIX_TIMESTAMP(expense_date) AS expensedate, \n            description FROM expenses WHERE user_id in ({$userids})";
    if (!($result = mysql_query($sql))) {
        return false;
    } else {
        $total = 0;
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['amount'] = $row['amount'];
            $paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['expense_date'] = date("j M Y", $row['expensedate']);
            $paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['description'] = $row['description'];
            $paid['users'][$row['userid']]['groups'][$row['group_id']]['group_total'] += $row['amount'];
            $paid['users'][$row['userid']]['user_total'] += $row['amount'];
            $total += $row['amount'];
            // format totals with two decimals
            $paid['users'][$row['userid']]['groups'][$row['group_id']]['total'] = number_format($paid['users'][$row['userid']]['groups'][$row['group_id']]['total'], DECIMALS, DSEP, TSEP);
            $paid['users'][$row['userid']]['total'] = number_format($paid['users'][$row['userid']]['total'], DECIMALS, DSEP, TSEP);
            $paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['running_total'] += $row['amount'] + $last_running[$row['userid']][$row['group_id']];
            $last_running[$row['userid']][$row['group_id']] = $paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['running_total'];
        }
        $paid['total'] = number_format($total, DECIMALS, DSEP, TSEP);
    }
    // array structure: ['users'][$userid]['groups'][$groupid][$expenseid]['amount|expense_date|description']
    return $paid;
}
开发者ID:Whiskey24,项目名称:GoingDutchApi,代码行数:30,代码来源:test.php


示例12: get_img_old

function get_img_old($id)
{
    $query = mysql_query("select menu_img from menus \n\t\t\t\t\t\twhere menu_id = '" . $id . "'");
    $result = mysql_fetch_array($query);
    $row = $result['menu_img'];
    return $row;
}
开发者ID:muguli22,项目名称:house_plan,代码行数:7,代码来源:menu_model.php


示例13: query

 public function query($sql)
 {
     if ($this->link) {
         $resource = mysql_query($sql, $this->link);
         if ($resource) {
             if (is_resource($resource)) {
                 $i = 0;
                 $data = array();
                 while ($result = mysql_fetch_assoc($resource)) {
                     $data[$i] = $result;
                     $i++;
                 }
                 mysql_free_result($resource);
                 $query = new \stdClass();
                 $query->row = isset($data[0]) ? $data[0] : array();
                 $query->rows = $data;
                 $query->num_rows = $i;
                 unset($data);
                 return $query;
             } else {
                 return true;
             }
         } else {
             $trace = debug_backtrace();
             trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br /> Error in: <b>' . $trace[1]['file'] . '</b> line <b>' . $trace[1]['line'] . '</b><br />' . $sql);
         }
     }
 }
开发者ID:honeynatividad,项目名称:mircatu,代码行数:28,代码来源:mysql.php


示例14: saveRatinglist

 public function saveRatinglist()
 {
     foreach ($this->ratings as $player) {
         //Controleren of speler al bestaat + ophalen id
         $sql = "SELECT * FROM svn_leden WHERE knsb = " . $player["knsb"];
         $query = mysql_query($sql);
         if (mysql_num_rows($query) == 1) {
             $data = mysql_fetch_assoc($query);
             $player["id"] = $data["id"];
         } elseif (mysql_num_rows($query) == 0) {
             //Toevoegen van de speler
             print_r($player);
         }
         //Controleren of de rating al bestaat
         $sql = "SELECT * FROM svn_rating WHERE id = " . $player["id"] . " AND datum = '" . $this->ratingList . "'";
         $query = mysql_query($sql);
         if (mysql_num_rows($query) == 0) {
             //Toevoegen rating
             $sql = "INSERT INTO svn_rating VALUES ('',\"" . $this->ratingList . "\"," . $player["id"] . ",1," . $player["rating"] . ")";
             mysql_query($sql);
         }
     }
     $sql = "SELECT * FROM svn_leden WHERE knsb = " . $speler_geg["id"];
     $result = mysql_query($sql);
     $speler_dat = mysql_fetch_array($result);
     if ($speler_geg["rating"] != "") {
         $sql = "INSERT INTO svn_rating VALUES ('',\"" . $datum . "\"," . $speler_dat[0] . ",1," . $speler_geg["rating"] . ")";
         //echo $sql;
         mysql_query($sql);
     }
 }
开发者ID:haverver,项目名称:SVN,代码行数:31,代码来源:class.ratinglijst.php


示例15: insert_item

function insert_item()
{
    // Connect to the 'test' database
    // The parameters are defined in the teach_cn.inc file
    // These are global constants
    connect_and_select_db(DB_SERVER, DB_UN, DB_PWD, DB_NAME);
    // Get the information entered into the webpage by the user
    // These are available in the super global variable $_POST
    // This is actually an associative array, indexed by a string
    $itemNumber = mysql_real_escape_string($_POST['itemNumber']);
    $itemDescription = mysql_real_escape_string($_POST['itemDescription']);
    $category = mysql_real_escape_string($_POST['category']);
    $departmentName = mysql_real_escape_string($_POST['departmentName']);
    $purchaseCost = mysql_real_escape_string($_POST['purchaseCost']);
    $retailPrice = mysql_real_escape_string($_POST['retailPrice']);
    // Create a String consisting of the SQL command. Remember that
    // . is the concatenation operator. $varname within double quotes
    // will be evaluated by PHP
    $insertStmt = "INSERT INTO Item (ItemNumber, ItemDescription, Category, DepartmentName,\n\t\t       PurchaseCost, FullRetailPrice) values ( '{$itemNumber}','{$itemDescription}', '{$category}',\n                      '{$departmentName}', '{$purchaseCost}', '{$retailPrice}')";
    //Execute the query. The result will just be true or false
    $result = mysql_query($insertStmt);
    $message = "";
    if (!$result) {
        $message = "Error in inserting Item. <br />Item Number: {$itemNumber}<br />Item Description:\n{$itemDescription} <br />Category:\n{$category}\n<br />Department\n Name: {$departmentName} <br />" . mysql_error();
    } else {
        $message = "Data for Item inserted successfully. <br />Item Number: {$itemNumber}<br />Item Description: {$itemDescription} <br />Category: {$category} <br />Department Name: {$departmentName}";
    }
    ui_show_item_insert_result($message, $itemNumber, $itemDescription, $category, $departmentName, $purchaseCost, $retailPrice);
}
开发者ID:rjoac1,项目名称:CSC423_TermProject,代码行数:29,代码来源:insert_item.php


示例16: query

 public function query($sql)
 {
     $resource = mysql_query($sql, $this->link);
     if ($resource) {
         if (is_resource($resource)) {
             $i = 0;
             $data = array();
             while ($result = mysql_fetch_assoc($resource)) {
                 $data[$i] = $result;
                 $i++;
             }
             mysql_free_result($resource);
             $query = new stdClass();
             $query->row = isset($data[0]) ? $data[0] : array();
             $query->rows = $data;
             $query->num_rows = $i;
             unset($data);
             return $query;
         } else {
             return true;
         }
     } else {
         trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br />' . $sql);
         exit;
     }
 }
开发者ID:ahmedkato,项目名称:openshift-opencart,代码行数:26,代码来源:sqlite.php


示例17: getNumTaxtype

function getNumTaxtype()
{
    $sql = "select count(taxtype) from cri_ro_taxtypes where status=1";
    $result = mysql_query($sql);
    $total = mysql_fetch_array($result);
    return $total[0];
}
开发者ID:mohammedafsath,项目名称:Automation,代码行数:7,代码来源:tax_types.php


示例18: getGameCount

function getGameCount()
{
    // Load game info
    $gameData = mysql_query("SELECT * FROM games");
    // Get game count and return it
    return mysql_num_rows($gameData);
}
开发者ID:ThomasGaubert,项目名称:roketgamer,代码行数:7,代码来源:getnumbergames.php


示例19: service

	function service($text)
	{
		$text = str_replace("\\\"","\"",$text);
		$token = explode(",",$text);
		$last_token = $token[sizeof($token)-1];
		$last_token = trim($last_token);
		$items = array();		
		$result = mysql_query("select firstName, lastName, email from employees where CONCAT(firstName,' ',lastName,' ', email) like '%$last_token%' order by email;");
		
		while($row = mysql_fetch_assoc($result))
		{

			$text = '"'.$row["firstName"]." ".$row["lastName"].'"'."<".$row["email"].">";
			$text_array = $token;
			$text_array[sizeof($text_array)-1] = $text;
			$text = join(",",$text_array);			
			
			$html = '"'.$row["firstName"]." ".$row["lastName"].'"'."[".$row["email"]."]";
			$html = preg_replace("/".$last_token."/i","<b>$last_token</b>",$html);
			$html = str_replace("[","&lt;",$html);
			$html = str_replace("]","&gt;",$html);
			
			$item = array("text"=>$text,"html"=>$html);
			array_push($items,$item);
		}
		return $items;
	}
开发者ID:rusli-nasir,项目名称:hospitalPhp,代码行数:27,代码来源:example.php


示例20: candidatesArePeopleToo

function candidatesArePeopleToo()
{
    $s = mysql_query("SELECT * FROM candidates");
    while ($r = mysql_fetch_array($s)) {
        $name = $r['name_cleaned'];
        $sid = $r['id'];
        if (strpos($r['url'], "http://") === 0) {
            $url = $r['url'];
        } else {
            $url = 'http://www.alegeri-2008.ro' . $r['url'];
        }
        $idString = '<a href=' . $url . '>alegeri2008</a>';
        $persons = getPersonsByName($name, $idString);
        // If I reached this point, I know for sure I either have one
        // or zero matches, there are no ambiguities.
        if (count($persons) == 0) {
            $person = addPersonToDatabase($name, $r['name_cleaned']);
        } else {
            $person = $persons[0];
            info("Found      {" . $name . "}");
        }
        // First and foremost, attempt to add this to the person's history.
        addPersonHistory($person->id, "alegeri/2008", $url);
        // Locate these people and update them in several tables now.
        // We're mainly interested in updating the ID to the new ID that
        // will be in the People database, from the previous ID that was
        // the senator's ID in the senators table.
        mysql_query("UPDATE candidates " . "SET idperson={$person->id} " . "WHERE id=" . $r['id']);
    }
}
开发者ID:nightsh,项目名称:hartapoliticii,代码行数:30,代码来源:candidates_to_people.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mysql_query_with_throw函数代码示例发布时间:2022-05-15
下一篇:
PHP mysql_prep函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap