Heim  >  Fragen und Antworten  >  Hauptteil

Bitte werfen Sie einen Blick darauf und bringen Sie mir diesen Neuling bei.

QQ截图20170722144814.png

Ich habe jetzt eine Tabelle wie diese, die aus der Datenbank gelesen wird. Das Folgende ist der PHP-Code. Der Effekt, den ich jetzt benötige, besteht darin, die Farben entsprechend zu unterteilen Tierkreiszeichen (zum Beispiel: 01, 13, 25, 37 und 49 gehören zu Hahn, schreiben Sie einfach „Hahn“ unter das Alter mit rotem Hintergrund. 02, 14, 26 und 38 gehören zu „Affe“, schreiben Sie einfach „Affe“ unter das Alter , mit blauem Hintergrund...), hier ist das Rendering, das ich mit PS gemacht habe. Kann mir jemand helfen? Ich hoffe, Gott kann mir einen Rat geben

大浪淘金大浪淘金2617 Tage vor1166

Antworte allen(4)Ich werde antworten

  • 立伟

    立伟2017-07-26 15:56:06

    写12个样式 例如 hou   ji或者 1  2 等等   设置12生肖例如 hou   ji或者 1  2 等等  循环的时候直接也设置样式就可以了

    Antwort
    0
  • 辕天

    辕天2017-07-24 23:07:34

    <?php
    /*
     * Created on 2017-7-24
     * 十二生肖显示
     * To change the template for this generated file go to
     * Window - Preferences - PHPeclipse - PHP - Code Templates
     */
      error_reporting(0);
    	function num($no){
    		$num = $no % 12; //取模判断生肖,0-11数字对应具体的生肖。测试以1为鼠开始,12对应猪。
    		switch ($num) {
    			case 1:
    				echo "<div style='background-color:#CC3366'>".$no."<br>鼠</div>";
    				break;
    			case 2:
    				echo "<div style='background-color:#FF0000'>".$no."<br>牛</div>";
    				break;
    			case 3:
    				echo "<div style='background-color:#00FF00'>".$no."<br>虎</div>";
    				break;
    			case 4:
    				echo "<div style='background-color:#0000FF'>".$no."<br>兔</div>";
    				break;
    			case 5:
    				echo "<div style='background-color:#FFFF00'>".$no."<br>龙</div>";
    				break;
    			case 6:
    				echo "<div style='background-color:#00FFFF'>".$no."<br>蛇</div>";
    				break;
    			case 7:
    				echo "<div style='background-color:#FF00FF'>".$no."<br>马</div>";
    				break;
    			case 8:
    				echo "<div style='background-color:#C0C0C0'>".$no."<br>羊</div>";
    				break;
    			case 9:
    				echo "<div style='background-color:#7FFFD4'>".$no."<br>猴</div>";
    				break;
    			case 10:
    				echo "<div style='background-color:#8A2BE2'>".$no."<br>鸡</div>";
    				break;
    			case 11:
    				echo "<div style='background-color:#A52A2A'>".$no."<br>狗</div>";
    				break;
    			case 0:
    				echo "<div style='background-color:#FAEBD7'>".$no."<br>猪</div>";
    				break;
    			default:
    				echo "<div style='background-color:#F0F8FF'>".$no."读取数据出错!</div>";
    				break;
    		}
    	}
    
    ?>
    <table border=1; width="600px;">
    	<tr><th>Number</th><th>No.1</th><th>No.2</th><th>No.3</th><th>No.4</th><th>No.5</th><th>No.5</th><th>No.7</th><th>操 作</th></tr>
    	<tr style="text-align:center">
    		<td>Num1</td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><a href="#">修改</a>&nbsp;&nbsp;<a href="#">删除</a></td>
    	</tr>
    	<tr style="text-align:center">
    		<td>Num2</td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><a href="#">修改</a>&nbsp;&nbsp;<a href="#">删除</a></td>
    	</tr>
    	<tr style="text-align:center">
    		<td>Num3</td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><a href="#">修改</a>&nbsp;&nbsp;<a href="#">删除</a></td>
    	</tr>
    	<tr style="text-align:center">
    		<td>Num4</td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><a href="#">修改</a>&nbsp;&nbsp;<a href="#">删除</a></td>
    	</tr>
    	<tr style="text-align:center">
    		<td>Num5</td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><a href="#">修改</a>&nbsp;&nbsp;<a href="#">删除</a></td>
    	</tr>
    	<tr style="text-align:center">
    		<td>Num6</td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><a href="#">修改</a>&nbsp;&nbsp;<a href="#">删除</a></td>
    	</tr>
    	<tr style="text-align:center">
    		<td>Num7</td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><?php num(rand(1,49));?></td>
    		<td><a href="#">修改</a>&nbsp;&nbsp;<a href="#">删除</a></td>
    	</tr>
    </table>


    Antwort
    0
  • 辕天

    辕天2017-07-24 22:54:26

    设置十二种颜色,并让每种颜色对应一个1-12中的数字(及生肖)。测试的数据随机生成1-49,可能有重复。20170701.png
    一个方法 num($no); $no为取得数据。
    20170702.png

    为方便测试,数据全部为随机生成1-49的数。

    20170703.png

    Antwort
    1
  • 辕天

    思路大致是这样的,具体的话还可以再优化一下,方法内的参数对应的生肖最好是可以自定义设置。

    辕天 · 2017-07-24 23:06:08
  • ringa_lee

    ringa_lee2017-07-22 15:59:20

    你得找到其中的规律,他们每个数之间的差都是12。属鸡是从1逐次加12,而属猴是从2开始逐次加12。

    Antwort
    0
  • StornierenAntwort