本文整理汇总了PHP中get_cats函数的典型用法代码示例。如果您正苦于以下问题:PHP get_cats函数的具体用法?PHP get_cats怎么用?PHP get_cats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_cats函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_cats
function get_cats($parent)
{
global $db_con, $db_con, $mysql_table_prefix, $debug;
$sql_query = "SELECT * FROM " . $mysql_table_prefix . "categories WHERE parent_num={$parent}";
$result = $db_con->query($sql_query);
if ($debug && $db_con->errno) {
$err_row = __LINE__ - 2;
printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error);
if (__FUNCTION__) {
printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>");
} else {
printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>");
}
printf("<p><span class='red'> Script execution aborted. <br /></span>");
printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
echo "<p> {$sql_query} </p>";
exit;
}
$arr[] = $parent;
if ($result->num_rows) {
while ($row = $result->fetch_array(MYSQL_ASSOC)) {
$id = $row['category_id'];
$arr = add_arrays($arr, get_cats($id));
}
}
return $arr;
}
示例2: get_cats
function get_cats($parent)
{
global $db;
$query = "SELECT * FROM " . TABLE_PREFIX . "categories WHERE parent_num={$parent}";
$result = $db->query($query);
echo sql_errorstring(__FILE__, __LINE__);
$arr[] = $parent;
while ($row = $result->fetch()) {
$id = $row[category_id];
$arr = add_arrays($arr, get_cats($id));
}
return $arr;
}
示例3: get_cats
function get_cats($parent)
{
global $mysql_table_prefix;
$query = "SELECT * FROM " . $mysql_table_prefix . "categories WHERE parent_num={$parent}";
echo mysql_error();
$result = mysql_query($query);
$arr[] = $parent;
while (mysql_num_rows($result) != "" && ($row = mysql_fetch_array($result))) {
$id = $row[category_id];
$arr = add_arrays($arr, get_cats($id));
}
return $arr;
}
示例4: get_cats
function get_cats($parent)
{
global $mysql_table_prefix, $mysqli_conn;
$query = "SELECT * FROM " . $mysql_table_prefix . "categories WHERE parent_num={$parent}";
echo mysql_error();
$result = $mysqli_conn->query($query);
$arr[] = $parent;
if ($result->num_rows > 0) {
while ($row = $result->fetch_array()) {
$id = $row[category_id];
$arr = add_arrays($arr, get_cats($id));
}
}
return $arr;
}
示例5: get_cats
function get_cats($parent)
{
// global $db, DEBUG;
$query = "SELECT * FROM " . TABLE_PREFIX . "categories WHERE parent_num={$parent}";
$result = mysql_query($query);
if (DEBUG > '0') {
echo mysql_error();
}
$arr[] = $parent;
if (mysql_num_rows($result) != '') {
while ($row = mysql_fetch_array($result)) {
$id = $row[category_id];
$arr = add_arrays($arr, get_cats($id));
}
}
return $arr;
}
示例6: deletecat
function deletecat($cat_id)
{
global $mysql_table_prefix;
$list = implode(",", get_cats($cat_id));
mysql_query("delete from " . $mysql_table_prefix . "categories where category_id in ({$list})");
echo mysql_error();
mysql_query("delete from " . $mysql_table_prefix . "site_category where category_id={$cat_id}");
echo mysql_error();
return "<center><b>Category deleted.</b></center>";
}
示例7: search
function search($searchstr, $category, $start, $per_page, $type, $domain)
{
global $length_of_link_desc, $mysql_table_prefix, $show_meta_description, $merge_site_results, $stem_words, $did_you_mean_enabled;
$possible_to_find = 1;
$result = mysql_query("select domain_id from " . $mysql_table_prefix . "domains where domain = '{$domain}'");
if (mysql_num_rows($result) > 0) {
$thisrow = mysql_fetch_array($result);
$domain_qry = "and domain = " . $thisrow[0];
} else {
$domain_qry = "";
}
//find all sites that should not be included in the result
if (count($searchstr['+']) == 0) {
return null;
}
$wordarray = $searchstr['-'];
$notlist = array();
$not_words = 0;
while ($not_words < count($wordarray)) {
if ($stem_words == 1) {
$searchword = addslashes(stem($wordarray[$not_words]));
} else {
$searchword = addslashes($wordarray[$not_words]);
}
$wordmd5 = substr(md5($searchword), 0, 1);
$query1 = "SELECT link_id from " . $mysql_table_prefix . "link_keyword{$wordmd5}, " . $mysql_table_prefix . "keywords where " . $mysql_table_prefix . "link_keyword{$wordmd5}.keyword_id= " . $mysql_table_prefix . "keywords.keyword_id and keyword='{$searchword}'";
$result = mysql_query($query1);
while ($row = mysql_fetch_row($result)) {
$notlist[$not_words]['id'][$row[0]] = 1;
}
$not_words++;
}
//find all sites containing the search phrase
$wordarray = $searchstr['+s'];
$phrase_words = 0;
while ($phrase_words < count($wordarray)) {
$searchword = addslashes($wordarray[$phrase_words]);
$query1 = "SELECT link_id from " . $mysql_table_prefix . "links where fulltxt like '% {$searchword}%'";
echo mysql_error();
$result = mysql_query($query1);
$num_rows = mysql_num_rows($result);
if ($num_rows == 0) {
$possible_to_find = 0;
break;
}
while ($row = mysql_fetch_row($result)) {
$phraselist[$phrase_words]['id'][$row[0]] = 1;
}
$phrase_words++;
}
if ($category > 0 && $possible_to_find == 1) {
$allcats = get_cats($category);
$catlist = implode(",", $allcats);
$query1 = "select link_id from " . $mysql_table_prefix . "links, " . $mysql_table_prefix . "sites, " . $mysql_table_prefix . "categories, " . $mysql_table_prefix . "site_category where " . $mysql_table_prefix . "links.site_id = " . $mysql_table_prefix . "sites.site_id and " . $mysql_table_prefix . "sites.site_id = " . $mysql_table_prefix . "site_category.site_id and " . $mysql_table_prefix . "site_category.category_id in ({$catlist})";
$result = mysql_query($query1);
echo mysql_error();
$num_rows = mysql_num_rows($result);
if ($num_rows == 0) {
$possible_to_find = 0;
}
while ($row = mysql_fetch_row($result)) {
$category_list[$row[0]] = 1;
}
}
//find all sites that include the search word
$wordarray = $searchstr['+'];
$words = 0;
$starttime = getmicrotime();
while ($words < count($wordarray) && $possible_to_find == 1) {
if ($stem_words == 1) {
$searchword = addslashes(stem($wordarray[$words]));
} else {
$searchword = addslashes($wordarray[$words]);
}
$wordmd5 = substr(md5($searchword), 0, 1);
$query1 = "SELECT distinct link_id, weight, domain from " . $mysql_table_prefix . "link_keyword{$wordmd5}, " . $mysql_table_prefix . "keywords where " . $mysql_table_prefix . "link_keyword{$wordmd5}.keyword_id= " . $mysql_table_prefix . "keywords.keyword_id and keyword='{$searchword}' {$domain_qry} order by weight desc";
echo mysql_error();
$result = mysql_query($query1);
$num_rows = mysql_num_rows($result);
if ($num_rows == 0) {
if ($type != "or") {
$possible_to_find = 0;
break;
}
}
if ($type == "or") {
$indx = 0;
} else {
$indx = $words;
}
while ($row = mysql_fetch_row($result)) {
$linklist[$indx]['id'][] = $row[0];
$domains[$row[0]] = $row[2];
$linklist[$indx]['weight'][$row[0]] = $row[1];
}
$words++;
}
if ($type == "or") {
$words = 1;
}
//.........这里部分代码省略.........
示例8: search
function search($searchstr, $category, $start, $per_page, $type, $domain)
{
global $length_of_link_desc, $show_meta_description, $merge_site_results, $stem_words;
global $did_you_mean_enabled, $did_you_mean_always;
global $matchless, $equivalent, $language;
global $db;
$possible_to_find = 1;
$stat = $db->prepare("SELECT domain_id FROM " . TABLE_PREFIX . "domains WHERE domain = :domain");
$stat->execute(array(':domain' => $domain));
if ($row = $stat->fetch()) {
$domain_qry = "and domain = " . $row[0];
} else {
$domain_qry = "";
}
$stat->closeCursor();
/* if there are no words to search for, quit */
if (!isset($searchstr['+']) || count($searchstr['+']) == 0) {
return null;
}
/* find all words that should _not_ be included in the result */
if (isset($searchstr['-'])) {
$wordarray = $searchstr['-'];
} else {
$wordarray = array();
}
$notlist = array();
$not_words = 0;
while ($not_words < count($wordarray)) {
if ($stem_words == 1) {
$searchword = stem($wordarray[$not_words]);
} else {
$searchword = $wordarray[$not_words];
}
$wordmd5 = substr(md5($searchword), 0, 1);
$stat = $db->prepare("SELECT link_id from " . TABLE_PREFIX . "link_keyword{$wordmd5}, " . TABLE_PREFIX . "keywords where " . TABLE_PREFIX . "link_keyword{$wordmd5}.keyword_id= " . TABLE_PREFIX . "keywords.keyword_id and keyword = :keyword");
$stat->execute(array(':keyword' => $searchword));
while ($row = $stat->fetch()) {
$notlist[$not_words]['id'][$row[0]] = 1;
}
$not_words++;
}
/* find all phrases */
if (isset($searchstr['+s'])) {
$wordarray = $searchstr['+s'];
} else {
$wordarray = array();
}
$phrase_words = 0;
while ($phrase_words < count($wordarray)) {
$searchword = $wordarray[$phrase_words];
$searchword = str_replace("|", "", $searchword);
$searchword = str_replace("%", "|%", $searchword);
$searchword = str_replace("_", "|_", $searchword);
$stat = $db->prepare("SELECT link_id from " . TABLE_PREFIX . "links where fulltxt like :keyword escape '|'");
$stat->execute(array(':keyword' => "%" . $searchword . "%"));
echo sql_errorstring(__FILE__, __LINE__);
$row = $stat->fetch();
if (!$row) {
$possible_to_find = 0;
$stat->closeCursor();
break;
}
$phraselist[$phrase_words]['id'][$row[0]] = 1;
while ($row = $stat->fetch()) {
$phraselist[$phrase_words]['id'][$row[0]] = 1;
}
$phrase_words++;
}
if ($category > 0 && $possible_to_find == 1) {
$allcats = get_cats($category);
$catlist = implode(",", $allcats);
$result = $db->query("SELECT link_id FROM " . TABLE_PREFIX . "links, " . TABLE_PREFIX . "sites, " . TABLE_PREFIX . "categories, " . TABLE_PREFIX . "site_category where " . TABLE_PREFIX . "links.site_id = " . TABLE_PREFIX . "sites.site_id and " . TABLE_PREFIX . "sites.site_id = " . TABLE_PREFIX . "site_category.site_id and " . TABLE_PREFIX . "site_category.category_id in ({$catlist})");
echo sql_errorstring(__FILE__, __LINE__);
$row = $result->fetch();
if (!$row) {
$possible_to_find = 0;
} else {
$category_list[$row[0]] = 1;
while ($row = $result->fetch()) {
$category_list[$row[0]] = 1;
}
}
$result->closeCursor();
}
/* find individual words */
$word_not_found = array();
$wordarray = $searchstr['+'];
$words = 0;
while ($words < count($wordarray) && $possible_to_find == 1) {
if ($stem_words == 1) {
$searchword = stem($wordarray[$words]);
} else {
$searchword = $wordarray[$words];
}
$wordmd5 = substr(md5($searchword), 0, 1);
$stat = $db->prepare("SELECT distinct link_id, weight, domain FROM " . TABLE_PREFIX . "link_keyword{$wordmd5}, " . TABLE_PREFIX . "keywords WHERE " . TABLE_PREFIX . "link_keyword{$wordmd5}.keyword_id= " . TABLE_PREFIX . "keywords.keyword_id AND keyword=:keyword {$domain_qry}\tORDER\tBY\tweight\tDESC");
$stat->execute(array(':keyword' => $searchword));
echo sql_errorstring(__FILE__, __LINE__);
$row = $stat->fetch();
if (!$row) {
//.........这里部分代码省略.........
示例9: deletecat
function deletecat($cat_id)
{
global $db;
$list = implode(",", get_cats($cat_id));
$db->exec("delete from " . TABLE_PREFIX . "categories where category_id in ({$list})");
echo sql_errorstring(__FILE__, __LINE__);
$db->exec("delete from " . TABLE_PREFIX . "site_category where category_id={$cat_id}");
echo sql_errorstring(__FILE__, __LINE__);
return "<center><b>Category deleted.</b></center>";
}
示例10: deletecat
function deletecat($cat_id)
{
$list = implode(",", get_cats($cat_id));
mysql_query("delete from " . TABLE_PREFIX . "categories where category_id in ({$list})");
if (DEBUG > '0') {
echo mysql_error();
}
mysql_query("delete from " . TABLE_PREFIX . "site_category where category_id={$cat_id}");
if (DEBUG > '0') {
echo mysql_error();
}
return "<p class='msg'>Category deleted.</p>";
}
示例11: ui_bottom
if (login_checklogin() && $_SESSION['userinfo']['wallpapers_ban'] > time()) {
echo '<h1>Fel</h1>' . "\n";
echo '<h2>Du får inte ladda upp fler bilder på ett tag! Läs i din gästbok för mer info.</h2>';
ui_bottom();
exit;
}
?>
<h2>Lägg till ny bakgrundsbild</h2>
<p style="color:red;">Alla fält är obligatoriska</p>
<form action="#" id="wallpapers_form" enctype="multipart/form-data" method="post">
<h5>Namn</h5>
<input type="text" class="textbox" id="form_title" name="title" />
<h5>Kategori</h5>
<select name="cat">
<?php
echo get_cats(0);
?>
</select>
<h5>Licens</h5>
<select name="license">
<?php
$query = 'SELECT id, title FROM ' . WALLPAPERS_LICENSE . ' WHERE is_removed = 0 ORDER BY id ASC';
$result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
if (mysql_num_rows($result) > 0) {
while ($data = mysql_fetch_assoc($result)) {
echo '<option value="' . $data['id'] . '">' . $data['title'] . '</option>' . "\n";
}
}
?>
</select>
<h5>Upphovsrättsinnehavare</h5>
示例12: search
function search($searchstr, $category, $start, $per_page, $type, $domain)
{
global $length_of_link_desc, $mysql_table_prefix, $show_meta_description, $sort_results, $query_hits;
global $stem_words, $did_you_mean_enabled, $relevance, $query, $utf8, $wildcount, $type, $case_sensitive;
$possible_to_find = 1;
$result = mysql_query("select domain_id from " . $mysql_table_prefix . "domains where domain = '{$domain}'");
if (mysql_num_rows($result) > 0) {
$thisrow = mysql_fetch_array($result);
$domain_qry = "and domain = " . $thisrow[0];
} else {
$domain_qry = "";
}
//find all sites that should not be included in the result
if (count($searchstr['+']) == 0) {
return null;
}
$wordarray = $searchstr['-'];
$notlist = array();
$not_words = 0;
while ($not_words < count($wordarray)) {
if ($stem_words == 1) {
$searchword = addslashes(stem($wordarray[$not_words]));
} else {
$searchword = addslashes($wordarray[$not_words]);
}
$wordmd5 = substr(md5($searchword), 0, 1);
$query1 = "SELECT link_id from " . $mysql_table_prefix . "link_keyword{$wordmd5}, " . $mysql_table_prefix . "keywords where " . $mysql_table_prefix . "link_keyword{$wordmd5}.keyword_id= " . $mysql_table_prefix . "keywords.keyword_id and keyword='{$searchword}'";
$result = mysql_query($query1);
while ($row = mysql_fetch_row($result)) {
$notlist[$not_words]['id'][$row[0]] = 1;
}
$not_words++;
}
//find all sites containing the search phrase
$wordarray = $searchstr['+s'];
$phrase_words = 0;
while ($phrase_words < count($wordarray)) {
$searchword = addslashes($wordarray[$phrase_words]);
$phrase_query = $searchword;
if ($case_sensitive == '1') {
$query1 = "SELECT link_id from " . $mysql_table_prefix . "links where fulltxt like '% {$searchword}%'";
}
if ($case_sensitive == '0') {
$searchword = lower_case($searchword);
$query1 = "SELECT link_id from " . $mysql_table_prefix . "links where CONVERT(LOWER(fulltxt)USING utf8) like '% {$searchword}%'";
}
/*
if ($utf8 =='0') {
$searchword = lower_case($searchword);
$query1 = "SELECT link_id from ".$mysql_table_prefix."links where LOWER(fulltxt) like '% $searchword%'";
}
*/
$result = mysql_query($query1);
echo mysql_error();
$num_rows = mysql_num_rows($result);
if ($num_rows == 0) {
$possible_to_find = 0;
break;
}
while ($row = mysql_fetch_row($result)) {
$value = $row[0];
$phraselist[$phrase_words]['id'][$row[0]] = 1;
$phraselist[$phrase_words]['val'][$row[0]] = $value;
}
$phrase_words++;
}
if ($category > 0 && $possible_to_find == 1) {
$allcats = get_cats($category);
$catlist = implode(",", $allcats);
$query1 = "select link_id from " . $mysql_table_prefix . "links, " . $mysql_table_prefix . "sites, " . $mysql_table_prefix . "categories, " . $mysql_table_prefix . "site_category where " . $mysql_table_prefix . "links.site_id = " . $mysql_table_prefix . "sites.site_id and " . $mysql_table_prefix . "sites.site_id = " . $mysql_table_prefix . "site_category.site_id and " . $mysql_table_prefix . "site_category.category_id in ({$catlist})";
$result = mysql_query($query1);
echo mysql_error();
$num_rows = mysql_num_rows($result);
if ($num_rows == 0) {
$possible_to_find = 0;
}
while ($row = mysql_fetch_row($result)) {
$category_list[$row[0]] = 1;
}
}
//find all sites that include the search word
$wordarray = $searchstr['+'];
$words = 0;
$starttime = getmicrotime();
$searchword = addslashes($wordarray[$words]);
// get only first word of search query
$strictpos = strpos($searchword, '!');
// if ! is in position 0, we have to search strict
if ($strictpos === 0) {
// **** for 'Strict search' enter here
$searchword = str_replace('!', '', $searchword);
$query = "SELECT keyword_id, keyword from " . $mysql_table_prefix . "keywords where keyword = '{$searchword}'";
echo mysql_error();
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
if ($num_rows == 0) {
// if there was no searchword in table keywords
$possible_to_find = 0;
$break = 1;
}
//.........这里部分代码省略.........
示例13: get_cats
function get_cats($val, $level = 0, $cat)
{
$query = 'SELECT title, id FROM ' . WALLPAPERS_CATS . ' WHERE pid = ' . $val . ' AND is_removed = 0';
$result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE);
$out = '';
while ($row = mysql_fetch_assoc($result)) {
if ($row['title'] != '') {
$spaces = str_repeat(' ', $level * 4);
$val = $row['id'];
$out .= "\t" . '<option value="' . $val . '"' . ($row['id'] == $cat ? ' selected="selected"' : '') . '>' . $spaces . $row['title'] . '</option>' . "\n";
$out .= get_cats($val, $level + 1, $cat);
}
}
return $out;
}
示例14: intval
$query = 'UPDATE ' . WALLPAPERS_TABLE . ' SET title = "' . $_POST['title'] . '", cid = ' . intval($_POST['cat']) . ' WHERE id = ' . intval($_GET['id']);
mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
jscript_go_back();
} else {
if ($is_image) {
$cat = wallpapers_fetch(array('id' => intval($_GET['id']), 'limit' => 1));
$cat = $cat[0]['cid'];
echo rounded_corners_top();
echo '<h2>Admin</h2>' . "\n";
echo '<form action="' . $_SERVER['PHP_SELF'] . '?action=preview&id=' . intval($_GET['id']) . '" method="post">' . "\n";
echo '<h5>Titel</h5>
<input type="text" name="title" value="' . $imagetitle . '" />' . "\n";
echo '<br />' . "\n";
echo '<h5>Kategori</h5>' . "\n";
echo '<select name="cat">' . "\n";
echo get_cats(0, 0, $cat);
echo '</select>' . "\n";
echo '<br />' . "\n";
echo '<input type="button" onclick="confirm(\'Sure?\') ? document.location.href=\'?action=delete&id=' . intval($_GET['id']) . '\' : false;" value="Radera" class="button" />' . "\n";
echo '<input type="submit" value="Spara" />';
echo rounded_corners_bottom();
}
}
break;
case 'delete':
$query = 'SELECT c.extension, a.resolution_w AS width, a.resolution_h AS height FROM ' . WALLPAPERS_RES . ' AS a
LEFT JOIN ' . WALLPAPERS_RES_RELATION . ' AS b ON b.resolution_pid = a.id
LEFT JOIN ' . WALLPAPERS_TABLE . ' AS c ON c.id = b.pid
WHERE c.id = ' . intval($_GET['id']);
$result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
if (mysql_num_rows($result) > 0) {
示例15: deletecat
function deletecat($cat_id)
{
global $db_con, $mysql_table_prefix, $debug;
$list = implode(",", get_cats($cat_id));
$sql_query = "DELETE from " . $mysql_table_prefix . "categories where category_id in ({$list})";
$db_con->query($sql_query);
if ($debug && $db_con->errno) {
$err_row = __LINE__ - 2;
printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error);
if (__FUNCTION__) {
printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>");
} else {
printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>");
}
printf("<p><span class='red'> Script execution aborted. <br /></span>");
printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
echo "<p> {$sql_query} </p>";
exit;
}
$sql_query = "DELETE from " . $mysql_table_prefix . "site_category where category_id={$cat_id}";
$db_con->query($sql_query);
if ($debug && $db_con->errno) {
$err_row = __LINE__ - 2;
printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error);
if (__FUNCTION__) {
printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>");
} else {
printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>");
}
printf("<p><span class='red'> Script execution aborted. <br /></span>");
printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
echo "<p> {$sql_query} </p>";
exit;
}
return "<p class='msg'>Category deleted.</p>";
}