老师叫我做一个PHP的 双色球选号,
做出来为什么就没有输出数字呢,大家帮帮我吧,
下面是代码.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>双色球选号页面</title>
<style type="text/css">
<!--
.x {
height: 5px;
width: 120px;
color: #CCCCFF;
background-color: #6666FF;
font-size: 11px;
float: none;
border: 1px dotted #6699FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
.y {
height: 5px;
width: 5px;
color: #CC0000;
background-color: #FF6600;
font-size: 11px;
float: none;
border: 1px dotted #6699FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
.z {
height: 5px;
width: 120px;
color: #FFFFFF;
background-color: #FF0000;
font-size: 11px;
float: none;
border: 1px dotted #6699FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
.i1 {
height: 12px;
width: 12px;
color: #3366FF;
background-color: #6699FF;
font-size: 11px;
float: none;
border: 2px inset #6666FF;
margin: 0px;
}
.i2 {
height: 16px;
width: 60px;
color: #F0F0F0;
background-color: #FF99FF;
font-size: 11px;
float: none;
margin: 0px;
border: 1px outset #FF00FF;
}
.a {
height: 5px;
width: 225px;
color: #CCCCFF;
background-color: #6666FF;
font-size: 11px;
float: none;
border: 1px dotted #6699FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
-->
</style>
</head><body>
<?php
class ssq{
function lan(){
$arr1=array();
while(count($arr1)<=5){
$arr1[]=mt_rand(1,33);
}
echo join(" , ",$arr1);
}function hong(){
$arr2=mt_rand(1,16);
echo $arr2;
}function h(){echo <<< HTML
<table>
<tr>
<td class='x'>$this->lan()</td>
<td class='y'>$this->hong()</td>
</tr>
</table>
HTML;}
function sl(){
$x=$_POST['t'];
for($i=1;$i<=$x;$i++){
$this->h();
echo "<br>";
}
}}?>
<form id="form1" name="form1" method="post" action="">
<label></label>
<table width="206" class="a">
<tr>
<td width="123">请输入您要购买的数量:</td>
<td width="23"><input name="t" type="text" class="i1" id="textfield" size="2" maxlength="2" /></td>
<td width="60"><input class="i2"type="submit" name="button" id="button" value="点击选号" /></td>
</tr>
</table>
</form>
<?php
$xx=new ssq();
$xx->sl();
?>
</body>
</html>
做出来为什么就没有输出数字呢,大家帮帮我吧,
下面是代码.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>双色球选号页面</title>
<style type="text/css">
<!--
.x {
height: 5px;
width: 120px;
color: #CCCCFF;
background-color: #6666FF;
font-size: 11px;
float: none;
border: 1px dotted #6699FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
.y {
height: 5px;
width: 5px;
color: #CC0000;
background-color: #FF6600;
font-size: 11px;
float: none;
border: 1px dotted #6699FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
.z {
height: 5px;
width: 120px;
color: #FFFFFF;
background-color: #FF0000;
font-size: 11px;
float: none;
border: 1px dotted #6699FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
.i1 {
height: 12px;
width: 12px;
color: #3366FF;
background-color: #6699FF;
font-size: 11px;
float: none;
border: 2px inset #6666FF;
margin: 0px;
}
.i2 {
height: 16px;
width: 60px;
color: #F0F0F0;
background-color: #FF99FF;
font-size: 11px;
float: none;
margin: 0px;
border: 1px outset #FF00FF;
}
.a {
height: 5px;
width: 225px;
color: #CCCCFF;
background-color: #6666FF;
font-size: 11px;
float: none;
border: 1px dotted #6699FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
-->
</style>
</head><body>
<?php
class ssq{
function lan(){
$arr1=array();
while(count($arr1)<=5){
$arr1[]=mt_rand(1,33);
}
echo join(" , ",$arr1);
}function hong(){
$arr2=mt_rand(1,16);
echo $arr2;
}function h(){echo <<< HTML
<table>
<tr>
<td class='x'>$this->lan()</td>
<td class='y'>$this->hong()</td>
</tr>
</table>
HTML;}
function sl(){
$x=$_POST['t'];
for($i=1;$i<=$x;$i++){
$this->h();
echo "<br>";
}
}}?>
<form id="form1" name="form1" method="post" action="">
<label></label>
<table width="206" class="a">
<tr>
<td width="123">请输入您要购买的数量:</td>
<td width="23"><input name="t" type="text" class="i1" id="textfield" size="2" maxlength="2" /></td>
<td width="60"><input class="i2"type="submit" name="button" id="button" value="点击选号" /></td>
</tr>
</table>
</form>
<?php
$xx=new ssq();
$xx->sl();
?>
</body>
</html>
解决方案 »
- 弹窗内容写到php里面
- 关于php执行sql文件的问题
- zend studio怎样部署环境?
- 求助:正则嵌套匹配问题
- 如何在框架中动态显示一个html页面内容
- 前些天看了一个关于MYSQL注入攻击内容,现在有关问题请大家讨论一下
- XP下不能用PHP+APACHE吗?我配了好长时间PHP文件还是不能显示,真晕阿
- 开始学PHP的菜鸟说:我现在用一个支持PHP的空间。比如XXX.PHP就可以用。我想用数据库。怎么连接呢?我可以把数据库放到自己的目录下用数
- 为什么implode("",$array)结果会是换行的呢?
- 哪里可以申请支持PHP的网站?
- 有一点不解。
- ...php 数据显示...请各位解答...急
<table>
<tr>
<td class='x'>$this->lan()</td>
<td class='y'>$this->hong()</td>
</tr>
</table>
HTML;
改成
echo <<< HTML
<table>
<tr>
<td class='x'>{$this->lan()}</td>
<td class='y'>{$this->hong()}</td>
</tr>
</table>
HTML;
echo " HTML
<table>
<tr>
<td class='x'>{$this->lan()} </td>
<td class='y'>{$this->hong()} </td>
</tr>
</table>
HTML";这样就对了.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>双色球选号页面</title>
<style type="text/css">
<!--
.x {
height: 5px;
width: 120px;
color: #CCCCFF;
background-color: #6666FF;
font-size: 11px;
float: none;
border: 1px dotted #6699FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
.y {
height: 5px;
width: 5px;
color: #CC0000;
background-color: #FF6600;
font-size: 11px;
float: none;
border: 1px dotted #6699FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
.z {
height: 5px;
width: 120px;
color: #FFFFFF;
background-color: #FF0000;
font-size: 11px;
float: none;
border: 1px dotted #6699FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
.i1 {
height: 12px;
width: 12px;
color: #3366FF;
background-color: #6699FF;
font-size: 11px;
float: none;
border: 2px inset #6666FF;
margin: 0px;
}
.i2 {
height: 16px;
width: 60px;
color: #F0F0F0;
background-color: #FF99FF;
font-size: 11px;
float: none;
margin: 0px;
border: 1px outset #FF00FF;
}
.a {
height: 5px;
width: 225px;
color: #CCCCFF;
background-color: #6666FF;
font-size: 11px;
float: none;
border: 1px dotted #6699FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
-->
</style>
</head><body>
<?php
class ssq{
function lan(){
$arr1=array();
while(count($arr1)<=5){
$arr1[]=mt_rand(1,33);
}
return join(" , ",$arr1);
}function hong(){
$arr2=mt_rand(1,16);
return $arr2;
}function h(){
echo <<< HTML
<table>
<tr>
<td class='x'>{$this->lan()}</td>
<td class='y'>{$this->hong()}</td>
</tr>
</table>
HTML;}
function sl(){
$x=$_POST['t'];
for($i=1;$i<=$x;$i++){
$this->h();
echo "<br>";
}
}}?>
<form id="form1" name="form1" method="post" action="">
<label></label>
<table width="206" class="a">
<tr>
<td width="123">请输入您要购买的数量:</td>
<td width="23"><input name="t" type="text" class="i1" id="textfield" size="2" maxlength="2" /></td>
<td width="60"><input class="i2"type="submit" name="button" id="button" value="点击选号" /></td>
</tr>
</table>
</form>
<?php
$xx=new ssq();
$xx->sl();
?>
</body>
</html>错误1:
我第一次运行没有打开页面。你的网页是中文字符却用了UTF-8字符集。不知道你这里怎么显示的,我这里是一片乱码。修改成GB2312后正常错误2:
字符串中注意歧义。PHP读到$this->lan后停止读取。以为他是一个变量。当然调用失败了。需要加花括号区分。代码一点都不规范,还需要好好提高!!
这位同学。你连 <<< 符号都没有理解