解决方案 »
- 【急】请问我用Snoopy类采集一些信息,规则对,但是只能采集40条信息,可能是什么原因呢?
- 用array生成关联数组是括号内是字符串怎么办?
- 数据业务模型指的是什么?
- define('abc',include('abcd.php')); 请问类似这样的定义是什么意思,用意何在??
- prototype.js 怎么在服务器端接收postbody的内容
- javascript子窗口取父窗口问题
- 大家好,小弟最近开发一个招标系统网站.不知那位朋友做过类似此系统?
- 这个是什么问题??
- 我要编一个文件上传的程序,如何先判断要上传的文件的大小再copy?
- 为什么这样写超链接会报错?
- ie8
- 用MVC架构时,怎么进行多表联合查询?求一比较优秀的解决办法
通过表单把用户输入提交到b页面。b页面得到值后,调用c页面。问题就在这。你也说了,c是个类。那么b页面include c页面,把c页面中的类实例化,然后调用它的方法来处理数据然后方法将值返回给b页面不就行了?为什么一定要把值传给c让它处理?a.html
-------------------
<form method='post' action='b.php'>
<input type='text' name='txt' />
</form>b.php
--------------------
<?php
include 'c.php';
$result = c::change( $_POST['txt'] );
echo $result;
c.php
---------------------
<?php
class c{
public static function change( $txt ){
....
return $txt;
}
}
-------------------
<form method='post' action='b.php'>
<input type='text' name='txt' />
</form>b.php
--------------------
<?php
function request( $url, $data ){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $response;
}
echo request( 'http://localhost/c.php', 'txt='.$_POST['txt'] );
c.php
---------------------
<?php
class c{
public static function change( $txt ){
....
return $txt;
}
}echo c::change( $_POST['txt'] );我还是建议你用第一种。
假如B页面从A页面中取得 $_post['select']
为了页面代码整洁。我希望使用C页面的类进行处理。比如:
class list_number{
var $a,$b;
public function Number($a,$b){
$this->a=$a;
$this->b=$b;
switch ($this->a){
case $this->a==1;
$this->b=$this->b;
return $this->a;
return $this->b;
break;
case $this->a==2;
$this->b="Files_Introduction";
return $this->a;
return $this->b;
break;
case $this->a==3;
$this->b="Files_UploadTime";
return $this->a;
return $this->b;
break;
default;
echo "程序出错!请联系管理员!";
}
}B页面进行实例化。$Number=(int)$_POST['select'];
$list_Number= new list_number();
$list_Number->Number($Number,$Where,$Keyword);
那么我又纠结了。 处理好的$a,$b我怎么在B页面使用。?
B.php<?php include("class/Number.php"); ?><?php
if (isset($_POST['Search'])){
$Number=(int)$_POST['select'];
$Keyword=$_POST['keyword'];
$Where="Files_Name";
if(trim($Keyword)){
/*
$s = new list_number();
$a = unserialize($s);
$a->keyword();
*/
$list_Number= new list_number();
$list_Number->Number($Number,$Where,$Keyword); }
}
else{
header("Location: http://localhost/");
}
?>C页面代码<?php
class list_number{
var $a,$b,$c,$d;
public function Number($a,$b,$c){
$this->a=$a;
$this->b=$b;
$this->c=$c;
switch ($this->a){
case $this->a==1;
$this->b=$this->b;
return $this->a;
return $this->b;
break;
case $this->a==2;
$this->b="Files_Introduction";
return $this->a;
return $this->b;
break;
case $this->a==3;
$this->b="Files_UploadTime";
return $this->a;
return $this->b;
break;
default;
echo "程序出错!请联系管理员!";
}
}
public function keyword(){
if ($this->c){
$pattern = "/[ '.,:;*?~`!@#$%^&+=\-)(<>{}]|\]|\[|\/|\\\|\"|\|/";
$this->c= preg_replace($pattern," ", $this->c);
$pattern2 = "/[’。,:;*?~·!@#¥%……&+()、\-)(<>{}]|\]|\[|\/|\\\|\"|\|/";
$this->c= preg_replace($pattern2," ",$this->c);
$this->c= explode(" ",$this->c);
//print_r($this->c).'<br />';
if(is_array($this->c)){
foreach ($this->c as $key => $value) {
$value= trim($value);
if($value==""){
unset($this->c[$key]);
}
}
print_r($this->c);
}
}
}
}?>
我想使用C页面处理好的数据,然后代入SQL数据库查询。
但是不知道怎么去做! 求解释。 谢谢!
应删去所有的 return $this->a; 只保留 return $this->b;
调用时的
$list_Number->Number($Number,$Where,$Keyword);
改为
$Where = $list_Number->Number($Number,$Where,$Keyword);
这样 $Number、$Where、$Keyword 就可以用于组装 SQL 串了
请问一下,按照您说的那样做。$Where 是什么类型的数据了?
是不是这样调用。
$sql='select * from table where classid ='.$Where.' limit 0,10';怎么样查看他呢。 echo ? print_r ?
$Where 的取值是
不变
Files_Introduction
Files_UploadTime
之一echo $sql;
就可看到
测试了下,是可以的。但是只能看到一个值,最后一个问题!
如何获取指定的,比如说,Number($a,$b)
我只想要$a、$b或者全部。?
$a = $list_Number->a;
$b = $list_Number->b;
$c = $list_Number->c;
class list_number{
var $a,$b,$c,$d;