关于在SQL的写法 及在PHP页面中的应用?

关于在SQL的写法 及在PHP页面中的应用


一只萌萌小番薯
浏览 1081回答 5
5回答

Cats萌萌

sql:select a.value,a.data1,a.data2,a.period,b.name,b.main_url from 表2 a,表1 b wherea.period in (1,2,3) and a.name=nb_visits and a.idsite = b.idsite orderby a.value desc;代码:<td><div><?php&nbsp;echo $row['name']?></div></td><td><div><?php&nbsp;echo $row['main_url']?></div></td><td><div><?php&nbsp;if($row['period'] == 1){echo $row['value'];} ?></div></td> 当period=1的时候 输出value??<td><div><?php if($row['period'] == 2){echo $row['value'];}?></div></td>当period=2的时候 输出value??<td><div><?php if($row['period'] == 3){echo $row['value'];}?></div></td>当period=3的时候 输出value??

30秒到达战场

$sql = "select * form 表名 where name='nb_visits' and period in (1,2,3) order by value desc";$res = mysql_query($sql);while($result = mysql_fetch_array($res)){if($result['period'] == 1){echo '<td><div align="center">'.$row['value'].'</div></td>';}if($result['period'] == 2){echo '<td><div align="center">'.$row['value'].'</div></td>';}if($result['period'] == 3){echo '<td><div align="center">'.$row['value'].'</div></td>';}}

holdtom

<?php$period = $_GET['period'];$result = mysql_query("select * form 表名 where name='nb_visits' and period=" .$period. " order by value desc");while($row = mysql_fetch_array($result)){?><td><div align="center"><?php&nbsp;echo $row['value']?></div></td><?php&nbsp;} ?>大概这个意思,前面连接数据库代码没写,这是最基础中的基础了应该不用我教

幕布斯6054654

select * form 表名 where name='nb_visits' and period in (1,2,3) order by value desc或者select * form 表名 where name='nb_visits' and (period=1 or period=2 or period=3) order by value desc

交互式爱情

你指的 period 这个变量是一个数组,还是一个单独值?如果是数组:$period = array(1,2,3);$period_str = implode(',',$period);select * form 表名 where name='nb_visits' and period in (".$period_str.") order by value desc如果是一个单独的值$period = 1;select * form 表名 where name='nb_visits' and period=".$period." order by value desc
打开App,查看更多内容
随时随地看视频慕课网APP