如何从下面的列表菜单中排除某些国家/地区?现在我的代码将列出数据库中的所有国家/地区名称.
示例我想从列表菜单中排除阿尔巴尼亚国家/地区.如何根据这些代码实现它.
码
<?php $select_country=mysql_query("SELECT * FROM tbl_country ORDER BY country_name ASC")?>
<select name="country" onchange="return get_country(this.value);">
<option value=""><?=SELECT_COUNTRY?></option>
<? while($country=mysql_fetch_array($select_country)) {?>
<option <? if($_SESSION['getcountry']==$country['id']){ ?> selected="selected"<? }?> value="<?=$country['id']?>">
<?=$country['country_name']?></option>
<? } ?>
</select>
Run Code Online (Sandbox Code Playgroud)
Mysql的
id country_name
1 Afghanistan
2 Aland Islands
3 Albania
4 Algeria
5 American Samoa
6 Andorra
Run Code Online (Sandbox Code Playgroud) 当前代码仅将空格替换为破折号( - )
$url = str_replace(' ','-',$url);
Run Code Online (Sandbox Code Playgroud)
我只想在URL上允许使用字母,数字和短划线( - ).
让我知道这些技巧.
简单的问题,但我解决这个游戏很头疼.示例正则表达式.
[a-zA-Z0-9\s]
[whitespace]Stack[whitespace]Overflow - not allow
Stack[whitespace]Overflow - allow
Stack[whitespace]Overflow[whitespace] - not allow
Run Code Online (Sandbox Code Playgroud)
让我知道
function regex($str)
{
$check = preg_replace('/^[a-zA-Z0-9][a-zA-Z0-9\s]+[a-zA-Z0-9]$|^[a-zA-Z0-9]*$/', "", $str);
if (empty($check)) {
return true;
} else {
return false;
}
}
$str = 'Stack Overflow ';
$validator = regex($str);
if ($validator) {
echo "OK » " .$str;
} else {
echo "ERROR » " . $str;
}
Run Code Online (Sandbox Code Playgroud) 保存性别的示例
<form action="save.php?id=<?=$id?>" method="post">
<p><label><input name="gender" type="radio" value="male" <?php if($gender=='male'){?>checked="checked"<? }?> /> Male</label></p>
<p><label><input name="gender" type="radio" value="female" <?php if($gender=='female'){?>checked="checked"<? }?> /> Female</label></p>
</form>
Run Code Online (Sandbox Code Playgroud)
这是一个更新值的示例
if ($_REQUEST['gender']) {
mysql_query("UPDATE users SET gender='$gender' WHERE id='" . $id . "'") or die(mysql_error());
}
Run Code Online (Sandbox Code Playgroud)
如何点击性别时该值将自动保存到数据库.让我知道.
如果您turn off在stackoverflow noscript-warning上使用javascript,您将看到顶部
#noscript-warning {
font-family:Arial,Helvetica,sans-serif;
position:fixed;
top:0;
left:0;
width:100%;
z-index:101;
text-align:center;
font-weight:bold;
font-size:120%;
color:#fff;
background-color:#AE0000;
padding: 5px 0 5px 0;
}
Run Code Online (Sandbox Code Playgroud)
题.如何在浏览器底部定位警报?
我想在点之后删除任何数字.例
$input = '33.892';
$input = '15.274856';
$input = '-3.14';
$input = '5.055';
Run Code Online (Sandbox Code Playgroud)
输出应该是33,15,3和5.让我知道.
我想创建简单的谜题,从输入中选择随机的5个名字.
让我们说我想给我的博客评论员送礼物.所以我收集他们的名字并粘贴到textarea
我现在所做的只在http://jsfiddle.net/CDSuN/上形成
$winner = 'john, micheal, peter, sally, rooney, owen, tevez, ronaldo, wayne rooney, nani';
Run Code Online (Sandbox Code Playgroud)
如何用php或jquery选择获胜者.让我知道
我有一个小脚本,想要从管理页脚检测脚本版本.在admin footer.php上我放了这段代码.
<?php
define('VERSION', '1.0');
$fp = fopen("http://v.domain.com/version.txt", "r");
while ($line = fgets($fp)) {
$line;
if (VERSION != $line) {
?>
<div id="upgrade">
<a href="http://domain.com/download/" target="_blank">Download a new version [<?php echo $line; ?>]</a>
</div>
<?php
}
}
?>
Run Code Online (Sandbox Code Playgroud)
在version.txt中只有1.0.1和工作正常才能比较版本.
问题在这里,客户端网站会变慢.如何解决这个问题?
我的页脚上的示例链接
$powered = 'Powered by <a href="htp://stackoverflow.com">Stackoverflow</a>';
Run Code Online (Sandbox Code Playgroud)
主题文件
<?php echo $powered; ?>
Run Code Online (Sandbox Code Playgroud)
如果$powered从我的页脚中删除并错误/提醒通知它如何制作.
例 die('Do not remove the powered link')
我想知道什么语言可以让我的模板变得动态.示例HTML sturtcure
<div id="tabs">
<ul class="tabs">
<li><a href="#tabs-1">Header</a></li>
<li><a href="#tabs-2">Navigation</a></li>
<li><a href="#tabs-3">Layout & Colors</a></li>
<li><a href="#tabs-4">Optimization</a></li>
<li><a href="#tabs-5">Miscellaneous</a></li>
</ul>
<form method="post" action="options.php">
<div class="tab-container">
<div id="tabs-1" class="tab-content">Header</div>
<div id="tabs-2" class="tab-content">Navigation</div>
<div id="tabs-3" class="tab-content">Layout & Colors</div>
<div id="tabs-4" class="tab-content">Optimization</div>
<div id="tabs-5" class="tab-content">Miscellaneous</div>
</div>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
我想要LI和DIV
<li><a href="#tabs-1">Header</a></li>
<div id="tabs-1" class="tab-content">Header</div>
Run Code Online (Sandbox Code Playgroud)
可以是动态的而不是一个一个地写.怎么做?
在PHP中,如何验证用户输入,如下例所示.
示例有效输入
$input ='abkc32453';
$input ='a32453';
$input ='dsjgjg';
Run Code Online (Sandbox Code Playgroud)
示例无效输入
$input ='2sdf23';
$input ='2121adsasadf';
$input ='23142134';
Run Code Online (Sandbox Code Playgroud)