如果产品值为1(Checked = 1),我如何列出产品? [英] How Could I List Out Product, If The Product Value Is 1(Checked =1)

查看:42
本文介绍了如果产品值为1(Checked = 1),我如何列出产品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下php代码是复选框插入数据库。



< input type =checkboxname =homepagevalue = 1<?php echo($ row1 ['homepage'] == 1)? 'checked =checked':''; ?> /> 





此代码工作正常。

这是编辑页面代码的一部分,我把它命名为proEdit.php。





我的问题是如何编写代码,如果复选框(主页)值= 1然后列出产品,以下是我的代码



<?php 
@session_start();
?>

< html>
< head>
< title> De Closet |家庭及LT; /标题>
< link rel =icontype =image / pnghref =images / set5.png/>
< link rel =stylesheettype =text / csshref =css / lstyle.css/>
< link rel =stylesheettype =text / csshref =css / catalog.css/>
< link rel =stylesheettype =text / csshref =css / button.css/>

< / head>
< body>

<?php
include(oHeader.php);
?>

<?php
include(config.php);

$ queryPromo =SELECT * FROM promo;

$ resultPromo = mysql_query($ queryPromo);

while($ rowPromo = mysql_fetch_array($ resultPromo))
{
echo'< div id =promo>';
echo'< img src =data:image / jpeg; base64,'。base64_encode($ rowPromo [image])。'width =940pxheight =260px/>';
echo'< / div>';
}
?>

< p>
< div id =cslay>
<?php
include(oSide.php);
?>

< div id =content>
<?php
include(config.php);

$ query =SELECT * FROM product ORDER BY id DESC;
$ result = mysql_query($ query);

while($ row = mysql_fetch_array($ result))
{
?>
< div id =product>
< a href =pDetails.php?id =<?php echo $ row ['id'];?>>
< img src =data:image / jpeg; base64,<?php echo base64_encode($ row [prodImage]);?> width =190pxheight =190px/>
< / a>
< p>
<?php echo $ row [prodID]; ?>
< / p>
< p><?php echo $ row [prodName]; ?>< / p为H.
< p> RM<?php echo $ row [prodPrice]; ?>< / p为H.
< p>
< a href =pDetails.php?id =<?php echo $ row ['id'];?> class =button>产品详情< / a>
< / p>
< / div>

<?php
}

?>
< / div>

< div id =blay5>
< / div>

< / div>
< / p>
<?php
include(oBottom.php);
?>
< / body>
< / html>





这是我的主页代码,我把它命名为index.php

无论我勾选(选中)产品,它都会显示在此页面(主页)

如果选中复选框,我应该如何编写代码,然后该产品将显示在主页(index.php) )。



谢谢

问候。

解决方案

row1 ['主页'] == 1)? 'checked =checked':''; ?> />





此代码工作正常。

这是编辑页面代码的一部分,我把它命名为proEdit.php。





我的问题是如何编写代码,如果复选框(主页)值= 1然后列出产品,以下是我的代码



<?php 
@session_start();
?>

< html>
< head>
< title> De Closet |家庭及LT; /标题>
< link rel =icontype =image / pnghref =images / set5.png/>
< link rel =stylesheettype =text / csshref =css / lstyle.css/>
< link rel =stylesheettype =text / csshref =css / catalog.css/>
< link rel =stylesheettype =text / csshref =css / button.css/>

< / head>
< body>

<?php
include(oHeader.php);
?>

<?php
include(config.php);


queryPromo =SELECT * FROM promo;


resultPromo =的mysql_query(

the following php code is checkbox insert to database.

<input type="checkbox" name="homepage" value="1" <?php echo ($row1['homepage'] == 1) ? 'checked="checked"' : ''; ?>/>



this code work fine.
this is part of edit page code, i name it as proEdit.php.


My problem is how to write the code for , if checkbox(homepage) value = 1 then list out the product, following is my code

<?php
	@session_start();
?>

<html>
	<head>
		<title>De Closet | Home</title>
		<link rel="icon" type="image/png" href="images/set5.png" />
		<link rel="stylesheet" type="text/css" href="css/lstyle.css" />
		<link rel="stylesheet" type="text/css" href="css/catalog.css" />
		<link rel="stylesheet" type="text/css" href="css/button.css" />

	</head>
	<body>

		<?php
			include("oHeader.php");
		?>

		<?php
			include("config.php");

			$queryPromo="SELECT * FROM promo";

			$resultPromo=mysql_query($queryPromo);

			while($rowPromo=mysql_fetch_array($resultPromo))
			{
				echo '<div id="promo">';
				echo '<img src="data:image/jpeg;base64,'.base64_encode($rowPromo["image"]).'" width="940px" height="260px" />';
				echo '</div>';
			}
		?>

		<p>
			<div id="cslay">
				<?php
					include("oSide.php");
				?>

				<div id="content">
					<?php
						include("config.php");

						$query="SELECT * FROM product ORDER BY id DESC";
						$result=mysql_query($query);
						
						while($row=mysql_fetch_array($result))
						{
							?>
							<div id="product">
								<a href="pDetails.php?id=<?php echo $row['id']; ?>">
									<img src="data:image/jpeg;base64,<?php echo base64_encode($row["prodImage"]);?>" width="190px" height="190px" />
								</a>
								<p>
									<?php echo $row["prodID"]; ?>
								</p>
								<p><?php echo $row["prodName"]; ?></p>
								<p>RM<?php echo $row["prodPrice"]; ?></p>
								<p>
									<a href="pDetails.php?id=<?php echo $row['id']; ?>" class="button">Product Details</a>
								</p>
							</div>

							<?php
						}
						
					?>
				</div>

				<div id="blay5">
				</div>

			</div>
		</p>
		<?php
			include("oBottom.php");
		?>
	</body>
</html>



This is my homepage code, i name it as index.php
whatever i tick(checked) the product,it will show out at this page(homepage)
How should i write the code if checkbox checked then this product will show at homepage(index.php).

Thanks
Regards.

解决方案

row1['homepage'] == 1) ? 'checked="checked"' : ''; ?>/>



this code work fine.
this is part of edit page code, i name it as proEdit.php.


My problem is how to write the code for , if checkbox(homepage) value = 1 then list out the product, following is my code

<?php
	@session_start();
?>

<html>
	<head>
		<title>De Closet | Home</title>
		<link rel="icon" type="image/png" href="images/set5.png" />
		<link rel="stylesheet" type="text/css" href="css/lstyle.css" />
		<link rel="stylesheet" type="text/css" href="css/catalog.css" />
		<link rel="stylesheet" type="text/css" href="css/button.css" />

	</head>
	<body>

		<?php
			include("oHeader.php");
		?>

		<?php
			include("config.php");


queryPromo="SELECT * FROM promo";


resultPromo=mysql_query(


这篇关于如果产品值为1(Checked = 1),我如何列出产品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆