gaurav.iit Posted December 28, 2011 Share Posted December 28, 2011 i have a database which contains a table named girls with three columns ...Serial(int) name(text) hits(int) <?php error_reporting(E_ALL ^ E_NOTICE); $con = mysql_connect("localhost","gaurav",""); mysql_selectdb("website",$con); $index1 = rand(1,$count); $sql = mysql_query("SELECT * FROM girls WHERE Serial=$index1"); $row = mysql_fetch_array($sql); $name1 = $row['name']; $hits1 = $row['hits']; echo <<<ECO <html> <script language="javascript"> increment(){ // some php code to increase the hits in database where name = $name1 } </script> <input type="button" value="increment" onclick="increment();" name="button"> </html> ECO; ?> sorry for the code to be really haphazard..i jst started with php.....now i dont know wat code to put to increment the hits in increment function since it would also use varialble $name1 and $index1..... Quote Link to comment https://forums.phpfreaks.com/topic/253940-calling-php-inside-php/ Share on other sites More sharing options...
trq Posted December 28, 2011 Share Posted December 28, 2011 Pardon? Quote Link to comment https://forums.phpfreaks.com/topic/253940-calling-php-inside-php/#findComment-1301801 Share on other sites More sharing options...
gaurav.iit Posted December 28, 2011 Author Share Posted December 28, 2011 inside the increment function i need to run some php commands for incrementing the hits column in the database using the $name1 and $serial variables.. now simply writing the php commands inside the increment doesnt workk...wat shud i do.. Quote Link to comment https://forums.phpfreaks.com/topic/253940-calling-php-inside-php/#findComment-1301819 Share on other sites More sharing options...
trq Posted December 28, 2011 Share Posted December 28, 2011 You should post the code that "doesn't work" and a description of what "doesn't work" actually means. You should also post code in tags like everybody else here does. Quote Link to comment https://forums.phpfreaks.com/topic/253940-calling-php-inside-php/#findComment-1301824 Share on other sites More sharing options...
trq Posted December 28, 2011 Share Posted December 28, 2011 You should also be aware that Javascript executes on the client (the browser) while PHP executes on the server. It stands to reason therefor that you cannot execute php within a Javascript function. If you want to go down that path you can look into Ajax, but without knowing the difference between server side and client sode programming it's not going to be something that can be easily described in a single forum post / reply. Quote Link to comment https://forums.phpfreaks.com/topic/253940-calling-php-inside-php/#findComment-1301825 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.