does it's possible to retrieve data from a javascript ?? coz js is a client side script and php is a server side how can i get value of my js??
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function buttonPress(str)
{
var str;
alert(str);
}
</script>
</head>
<?php session_start();
error_reporting(E_ALL ^ E_NOTICE);
include "dbconfig.php";
$id=$_SESSION["valid_user"];
?>
<body>
<form name="Item Search" method="post" action="search.php">
Item Search:<br>
<label>
<input name="swords" type="text" size="30" maxlength="30">
</label>
<br>
<label>
<input name="search" type="submit" id="search" value="Search">
</label>
<a href="logout.php">Logout</a>
</form>
<?php
if (!$_POST['search']){
//determining the number of lenght of words
}else{
$searchwords = addslashes(htmlspecialchars($_POST['swords']));
if (strlen($searchwords) < 2){
echo "Your search must contain at least 3 characters. Please try again.<br><input type=button value='Back' onClick='history.go(-1)'>";
}else{
$words = explode(' ',$searchwords);
$totalwords = count($words);
$i = 0;
$searchstring = "";
while ($i != $totalwords){
if ($i != 0 and $i != $wordcount){
$searchstring .= " and ";;
}
$searchstring .= "b_name LIKE '%$words[$i]%'";
$searchstring1 .= "b_author LIKE '%$words[$i]%'";
$i = $i + 1;
}
$starrow=10;
//getting query
$query = mysql_query("SELECT DISTINCT * FROM book where $searchstring or $searchstring1 LIMIT $starrow");
if (mysql_num_rows($query) == 0){
echo "No results were found.<br><input type=button value='Back' onClick='history.go(-1)'>";
}else{
echo("<FORM METHOD=post id=form3>");
echo("<H4 ALIGN=left>Books found matching search criteria :</H4><BR>");
echo("</TABLE>");
//code in displaying the table
echo("<TABLE width='70%' border='2' cellpadding='3' ALIGN=CENTER name='test' >");
echo("<TR bgcolor='B0C4DE'>");
echo("<TH>Sr.No</TH>");
echo("<TH>Title Of Book</TH>");
echo("<TH>Author Name</TH>");
echo("<TH>Number of Copies</TH>");
echo("<TH>Borrow</TH>");
echo("</TR>");
//searching using title of book
$count=0; $i=1; while ($row = mysql_fetch_assoc($query)){
echo("<TR id='$i' bgcolor='B0C4DE'>");
$sr_num=$row['b_sr_num'];
echo ("<td><input name=data id=data type=text id=data readonly=readonly value=$sr_num></td>");
echo ('<td>'.$row['b_name'].'</td>');
echo ('<td>'.$row['b_author'].'</td>');
echo ('<td>'.$row['b_avail'].'</td>');
if($row['b_avail']>0)
{
if (!$_SESSION["valid_user"])
{
// User not logged in, redirect to login page
echo("<td>Available</td>");
}else
echo("<td><INPUT TYPE=button id=show name=show value=add onClick= buttonPress('$sr_num')></td>");
}else
echo("<td>No stock of book</td>");
echo("</TR>");
$i=$i+1; }
echo("</TABLE>");
echo("<DIV ALIGN=CENTER><INPUT TYPE=SUBMIT NAME=Next VALUE=Next>");
echo("<INPUT TYPE=SUBMIT NAME=Previous VALUE=Previous></DIV>");
echo("</FORM>");
}
}
}
?>
<form>
<div align="right">
<table width="200" border="1">
<tr>
<td colspan="2"><center>Reserve Books</center></td>
</tr>
<tr>
<td width="92"><?php echo '<script type="text/javascript"> buttonPress(str)</script>'; ?></td>
<td width="92"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</div>
</form>
</body>
</html>