Has a file php I want to modify it This is an increase in the value - stat - When you load appearance file Is it possible to make it more than the value stat When the process of opening another site (popup) And I want the work piece in the same file and not another file <?php include("config.php"); $get_pop = @mysql_query("SELECT `id`, `pop`, `url` FROM `popup` where pop > 0 and act='on' ORDER BY RAND() LIMIT 1"); while($pop = @mysql_fetch_array($get_pop)) { $id = $pop['id']; $url = $pop['url']; } $get_pop = mysql_query("UPDATE `popup` SET `stat` = stat + 1 WHERE `id` = $id"); ?> var openx<? echo $id;?> = false; function opena<? echo $id;?>(url) { if ( openx<? echo $id;?> == true ) { return true; } win = window.open(url, 'open<? echo $id;?>', 'toolbar,status,resizable,scrollbars,menubar,location,height=750,width=1000'); if ( win ) { win.blur(); openx<? echo $id;?> = true; } return win; } function setCookie(name, value, time) { var expires = new Date(); expires.setTime( expires.getTime() + time ); document.cookie = name + '=' + value + '; expires=' + expires.toGMTString(); } function getCookie(name) { var cookies = document.cookie.toString().split('; '); var cookie, c_name, c_value; for (var n=0; n<cookies.length; n++) { cookie = cookies[n].split('='); c_name = cookie[0]; c_value = cookie[1]; if ( c_name == name ) { return c_value; } } return null; } function openz<? echo $id;?>() { if ( document.attachEvent ) { document.attachEvent( 'onclick', checkx<? echo $id;?> ); } else if ( document.addEventListener ) { document.addEventListener( 'click', checkx<? echo $id;?>, false ); } } function checkx<? echo $id;?>(e) { if ( !getCookie('copenx<? echo $id;?>') ) { var e = e || window.event; var win = opena<? echo $id;?>('<? echo $url;?>'); setCookie('copenx<? echo $id;?>', 1, 0*60*1000); } } openz<? echo $id;?>(); PHP: I want to implement it $get_pop = mysql_query("UPDATE `popup` SET `stat` = stat + 1 WHERE `id` = $id"); PHP: If you open the other site The inside of JavaScript code openz<? echo $id;?>(); Waiting for your suggestions
Hi, @d3mk, Please, check INSERT ... ON DUPLICATE KEY UPDATE Syntax and you'll do this yourself in one line of code. Regards Hint: You've to add unique key.
I can not find in the website solves the problem Or you did not understand my intention When you click on the page shows another site And when the other site shows It performs the following $get_pop = mysql_query("UPDATE `popup` SET `stat` = stat + 1 WHERE `id` = $id");