数据特殊显示``````

将列表侧立,下面是效果图:

下面是实现方法:

<style> td { text-align:center; font-size: 12px; line-height: 20px; } .style1 { background-color: #D4AC89; margin-right:1px; color:#FFFFFF; font-weight: bold; } .style2 { color: #676767; } </style>

<?php //连接并选择到数据库服务器 $connection = mysql_connect ("localhost", "root", "mmmmmm"); mysql_select_db("test", $connection); //查询数据 mysql_query("SET NAMES 'utf-8'"); $query="SELECT shi FROM testtb group by shi"; $result=mysql_query($query,$connection); //mysql_fetch_array()获得数据,并输出 ?> <table cellpadding="0" cellspacing="0"> <tr> <? while($row=mysql_fetch_array($result)){?> <td width="100" valign="top"><div class="style1"><?=$row[0]?></div> <? $query1="SELECT sheng FROM testtb where shi='".$row[0]."'"; $i=0; $result1=mysql_query($query1,$connection); while($row1=mysql_fetch_array($result1)) { ?> <div class="style2" style="background-color: <? if ($i==1) {$i--;echo "#F3F3F3";} else {$i++;} ?>"> <?=$row1[0]?></div> <? }?> </td> <? }?> </tr> </table>

数据特殊显示``````

阅读更多
换一批

关于特殊节日的显示

11-17

以下为我做个一个日历控件的代码:想要达到四个目的:1、为日历定制样式rn 2、控制日立的选择模式rn 3、设置和获取选中的日期rn 4、让特殊的日期有提示,同时将页面导航到有文章的页面去。rnrn下面伪代码:rnusing System;rnusing System.Collections.Generic;rnusing System.Linq;rnusing System.Web;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Data;rnusing System.Data.OracleClient;rnusing System.Configuration;rnrnpublic partial class Default14 : System.Web.UI.Pagernrn string[][] arr;rnrn protected void Page_Init(object sender, EventArgs e)rn rn for (int y = 1980; y < 2050; y++)rn rn ye.Items.Add(y.ToString());rn rn for (int m = 1; m < 13; m++)rn rn mo.Items.Add(m.ToString());rn rn for (int d = 1; d < 32; d++)rn rn da.Items.Add(d.ToString());rn rn rn protected void Page_void(object sender, EventArgs e)rn rn arr = new string[13][];rn for (int i = 0; i < 13; i++)rn rn arr[i] = new string[32];rn rn arr[1][1] = "元旦节";rn arr[2][14] = "情人节";rn arr[3][8] = "妇女节";rn arr[4][15] = "清明节";rn arr[5][1] = "劳动节";rn arr[6][1] = "儿童节";rn arr[7][1] = "建党节";rn arr[7][15] = "鬼节";rn arr[8][1] = "建军节";rn arr[9][10] = "教师节";rn arr[9][28] = "热烈庆祝,今天是猫仔的生日";rn arr[10][1] = "国庆节";rn arr[11][15] = "生日";rn arr[12][24] = "平安夜";rn arr[12][25] = "圣诞节";rnrn rn protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)rn rn switch (DropDownList1.SelectedValue)rn rn case "None":rn Calendar1.SelectionMode = CalendarSelectionMode.None;rn break;rn case "DayWeekMonth":rn Calendar1.SelectionMode = CalendarSelectionMode.DayWeekMonth;rn break;rn case "DayWeek":rn Calendar1.SelectionMode = CalendarSelectionMode.DayWeek;rn break;rn case "Day":rn Calendar1.SelectionMode = CalendarSelectionMode.Day;rn break;rnrn rn rn protected void Calendar1_SelectionChanged(object sender, EventArgs e)rn rn Label1.Text = "完整的日期是:" + Calendar1.SelectedDate.ToShortDateString();rn Label2.Text = Calendar1.SelectedDate.Day.ToString() + "日";rn Label3.Text = Calendar1.SelectedDate.Month.ToString() + "月";rn Label4.Text = Calendar1.SelectedDate.Year.ToString() + "年";rn rnrn protected void Button1_Click(object sender, EventArgs e)rn rn string y = ye.SelectedValue.ToString();rn string m = mo.SelectedValue.ToString();rn string d = da.SelectedValue.ToString();rn Calendar1.VisibleDate = Convert.ToDateTime(y + "-" + m + "-" + d);rn rn protected static DataTable ds(string day)rn rn OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["pconn"].ConnectionString);rn OracleDataAdapter sda = new OracleDataAdapter();rn sda.SelectCommand = new OracleCommand("SELECT [ID], [TITLE], [ADDDATE]FROM [XIN] WHERE( [ID]= :ID)");rn DataSet ds = new DataSet();rn sda.Fill(ds, "xin");rn return ds.Tables["xin"];rn rn protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)rn rn CalendarDay d = e.Day;rn TableCell c = e.Cell;rn if (d.IsOtherMonth)rn rn c.Controls.Clear();rn rn elsern rn tryrn rn string txt = arr[d.Date.Month][d.Date.Day];rn if (txt != string.Empty)rn rn string day = e.Day.Date.ToShortDateString(); ;rn foreach (DataRow dr in ds(day).Rows)rn rn c.Controls.Clear();rn c.Controls.Add(new LiteralControl("" + e.Day.Date.Day + ""));rn rn c.Controls.Add(new LiteralControl(" " + txt));rn rn rn catch (Exception exe)rn rn Response.Write(exe.ToString());rn rn rn rnrnrn这样输入以后日期都能显示,也能跳转到想要的日期,但是标明的特殊节日一个都不能显示,请教高手指教?rn就是如开头的这种日期 : arr[1][1] = "元旦节";......rnrn还有为什么能够控制月份在12个月,日期每31天就反复循环呢?问题应该是出在这里:rn protected void Page_void(object sender, EventArgs e)rn rn arr = new string[13][];rn for (int i = 0; i < 13; i++)rn rn arr[i] = new string[32];rn rnrn请教高手指教?rnrnrn

没有更多推荐了,返回首页