Jump to content

calling php inside php


gaurav.iit

Recommended Posts

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.....

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.