Javascript和PHP的混合编程

本文探讨了JavaScript和PHP的混合编程,虽然它们各自独立,但在实际应用中可以相互配合。通过在HTML框架内使用这两种语言,可以创建出更丰富的交互式网页。关键在于理解它们在网页源代码中的表现形式,以及如何在不影响彼此的情况下协同工作。

其实没什么难道

写一起就行了

但是其实是各写个的,不要影响就行,程序如下:

<pre name="code" class="html">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
function output(param) {
	//alert($('#myimage').attr('value'));
	var radiovalue=$('input[name="aaa"]:checked').val();
	//alert(radiovalue);
	$.ajax({
		type: "GET",
		//method: "Get",
		dataType: "json",
		data:{"radio": radiovalue,"imageid":$('#myimage').attr('value')},
		url: "Save.php",
		success: function(data){
			window.location.reload();
		}
	});
}
</script>
<?php  
$m = new Mongo();

// select a database
$db = $m->FourS2;

// select a collection (analogous to a relational database's table)
$collection = $db->imagelist;

$post = $collection->findOne();

//element for each image
$imageid = $post['_id'];
$imageurl = $post['Url'];
$venueid = $post['Venue_id'];
$venueurl = $post['Venue_url'];
$venuename = $post['Venue_name'];

$strimageurl = '<center><img src=" '.$imageurl.' " width="400" height="400"></center><br>';
$strimageid = '<center><div id="myimage" value="'.$imageid.'">Image_ID : '.$imageid.'</div></center>';
$strvenueid = '<center><div>Venue_ID : '.$venueid.'</div></center>';
$strvenuename = '<center><div>Venue_Name : '.$venuename.'</div></center>';
$strvenueurl = '<center><a href="'.$venueurl.'">Venue_Url:'.$venueurl.'</a></center>';
//$imageurl = explode(" ", $imageurl); 

//输出结果 
echo $strimageurl;
echo $strimageid;
echo $strvenueid;
echo $strvenuename;
echo $strvenueurl;
echo '<center><input type="radio" name="aaa" value="1"/> Yes<input type="radio" name="aaa" value="0" /> No
<input type="button" style="width:70" width=70 value="next" onclick="output(this)"/></center>';
// iterate through the results
//echo var_dump($cursor);

?>

文件名是什么都无所谓。

当你看网页源代码,你就只能看到html的代码了。

当做是两个工具就行。整体的框架还是在html里面。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值