Jump to content

Recommended Posts

Hi, i am trying to add php variables inside the java but its not really working

i saw some place that it works.......

 

 

<TABLE border="0" cellspacing="0" cellpadding="0">
 <TR>
   <TD>
  <form name="Oneslideform" >
    <DIV align="center">
	  <TABLE width="150" border="1" cellspacing="0" cellpadding="4" bordercolor="#330099">
	    <TR>
		  <TD bgcolor="#330099">
		    <DIV align="center"><B><FONT color="#FFFFFF">Image Slideshow</FONT></B></DIV>
		  </TD>
	    </TR>
	    <TR>
		  <TD bgcolor="#FFFFFF">
		    <DIV align="center"><A href="javascript:Onetransport()"><IMG src="slideimage1.gif" width="90" height="90" name="Oneshow" border="0"></A></DIV>
		  </TD>
	    </TR>
	    <TR>
		  <TD bgcolor="#330099">
		    <DIV align="center">
			  <SELECT name="Oneslide" onchange="Onechange();">
			    <OPTION value="slideimage1.gif">Image 1</OPTION>
			    <OPTION value="<?php echo $image2; ?>">Image 2</OPTION>
			    <OPTION value="slideimage3.gif">Image 3</OPTION>
			  </SELECT>
  </DIV>
		  </TD>
	    </TR>
	    <TR>
		  <TD bgcolor="#330099">
		    <DIV align="center">
			  <INPUT type=button onclick="Oneprevious();" value="<<" title="Previous">
			  <INPUT type=button name="Oneslidebutton" onclick="Oneap(this.value);" value="Start" title="AutoPlay">
			  <INPUT type=button onclick="Onenext();" value=">>" title="Next">
	  </DIV>
		  </TD>
	    </TR>
	  </TABLE>
    </DIV>
  </form>
   </TD>
 </TR>
</TABLE>
<p>This free script provided by<br />
<a href="http://javascriptkit.com">Javascript
Kit</a></p>

Link to comment
https://forums.phpfreaks.com/topic/270464-php-code-in-java/
Share on other sites

There is no java anywhere on the page. You are also not using php anywhere inside the javascript. There is no way to help unless you reveal the functions you're using

 

 

If you check there is a small php coding inside

 

<OPTION value="<?php echo $image2; ?>">Image 2</OPTION>

 

and i have coped this complete script from

 

http://www.javascriptkit.com/script/script2/3slide.shtml

 

Can you please check

Link to comment
https://forums.phpfreaks.com/topic/270464-php-code-in-java/#findComment-1391107
Share on other sites

1) That's not Java, that's javascript.

2) What does "but its not really working" mean? What's supposed to happen? Errors? Please elaborate.

 

I mean when i am giving complete URL of image then it show the image...

But when i am give php variable then its not show the image

 

The displayed fields look like this in browser

 

image 1

">image 2 (here is php coding)

image 3

 

<SELECT name="Oneslide" onchange="Onechange();">
			 <OPTION value="http://localhost/images/dsadas.jpg">Image 1</OPTION>
			 <option value="<?php echo $image2; ?>">Image 2</option>
			 <OPTION value="slideimage3.gif">Image 3</OPTION>
			 </SELECT>

Edited by arunpatal
Link to comment
https://forums.phpfreaks.com/topic/270464-php-code-in-java/#findComment-1391113
Share on other sites

Have a look at the page source and see what you have for the contents of $image in that option value

 

It is Image.........

 

<?php $image1= '<a href="inventory_images/' . $img1 . '.jpg"><img style="border:#666 1px solid;" src="inventory_images/' . $img1 . '.jpg" alt="' . $product_name . '" width="80" height="80" border="1" /></a>'; ?>

 

But it dose not show that image

 

  <form name="Oneslideform" >
<DIV align="center"><A href=""><IMG src="slideimage1.gif" width="90" height="90" name="Oneshow" border="0"></A></DIV>
		  </TD>
	    </TR>
<TR>
		  <TD bgcolor="#330099">
		    <DIV align="center">
		    <SELECT name="Oneslide" onchange="Onechange();">
			    <OPTION value="http://localhost/inventory_images/dsadas.jpg">Image 1</OPTION>
						 <option value="<?php echo $image1; ?>"</option>
		  <OPTION value="slideimage3.gif">Image 3</OPTION>
			  </SELECT>

Link to comment
https://forums.phpfreaks.com/topic/270464-php-code-in-java/#findComment-1391124
Share on other sites

You're using a and img tags? I'm not too sure that would work...why not just enter the image name as they are doing in the example they provided

 

I have a variable which is $image1

 

<?php $image1= '<a href="inventory_images/' . $img1 . '.jpg"><img style="border:#666 1px solid;" src="inventory_images/' . $img1 . '.jpg" alt="' . $product_name . '" width="80" height="80" border="1" /></a>'; ?>

 

 

 

Now i want to add this variable inside form.

This is from look like

 

<form name="Oneslideform" >

<DIV align="center"><A href=""><IMG src="slideimage1.gif" width="90" height="90" name="Oneshow" border="0"></A></DIV>

</TD>

</TR>

<TR>

<TD bgcolor="#330099">

<DIV align="center">

<SELECT name="Oneslide" onchange="Onechange();">

<OPTION value="http://localhost/inventory_images/dsadas.jpg">Image 1</OPTION>

<option value="<?php echo $image1; ?>">Image 1</option>

<OPTION value="slideimage3.gif">Image 3</OPTION>

</SELECT>

</form>

 

But this form dose not show the image from this variable ($image1)

It do show the Image1 which is direct URL to image.

 

How can i show this variable in this form..........

Link to comment
https://forums.phpfreaks.com/topic/270464-php-code-in-java/#findComment-1391129
Share on other sites

This thing dose not work for me..........

 

PHP variable to Form variable:

 

<form name="myform4">

<input type="hidden" name="formvar" value="<?php $phpvar=10; echo $phpvar; ?>"> // PHP code inside HTML!!

</form>

 

Source: http://www.skytopia.com/project/articles/compsci/form.html

Link to comment
https://forums.phpfreaks.com/topic/270464-php-code-in-java/#findComment-1391134
Share on other sites

OK I try to explain..........

 

This is the code for complete page.

Here there are 4 image variables

$img1

$img2

$img3

$img4

 

I want to show these Images like in this example

 

http://www.javascrip...t2/3slide.shtml

 

Please help me with this.........

 

 

<?php
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php
// Check to see the URL variable is set and that it exists in the database
if (isset($_GET['id'])) {
// Connect to the MySQL database
include "storescripts/connect_to_mysql.php";
$id = preg_replace('#[^0-9]#i', '', $_GET['id']);
// Use this var to check to see if this ID exists, if yes then get the product
// details, if no then exit this script and give message why
$sql = mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
// get all the product details
while($row = mysql_fetch_array($sql)){
$product_name = $row["product_name"];
$price = $row["price"];
$img1 = $row["img1"];
$img2 = $row["img2"];
$img3 = $row["img3"];
$img4 = $row["img4"];
$details = $row["details"];
$category = $row["category"];
$subcategory = $row["subcategory"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
	 }

} else {
echo "That item does not exist.";
 exit();
}

} else {
echo "Data to render this page is missing.";
exit();
}
mysql_close();
?>
<!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><?php echo $product_name; ?></title>
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
</head>
<body>
<div align="center" id="mainWrapper">
<?php include_once("template_header.php");?>
<div id="pageContent">
<table width="100%" border="0" cellspacing="0" cellpadding="15">
<tr>




<td width="12%" valign="top"><div style='float:left;'><img src="inventory_images/<?php echo $id; ?>.jpg" width="81" height="100"		 alt="<?php echo $product_name; ?>" /><br />
 <a href="inventory_images/<?php echo $id; ?>.jpg">Full Size</a><br />

 <p>

 <img src="inventory_images/<?php echo $img1; ?>.jpg" width="81" height="100" alt="<?php echo $product_name; ?>" /><br />
 <a href="inventory_images/<?php echo $img1; ?>.jpg">Full Size</a>
 </div></td>





 <td width="12%" valign="top"><div style='float:left;'><img src="inventory_images/<?php echo $img2; ?>.jpg" width="81" height="100"	 alt="<?php echo $product_name; ?>" /><br />
 <a href="inventory_images/<?php echo $img2; ?>.jpg">Full Size</a><br />

 <p>

 <img src="inventory_images/<?php echo $img3; ?>.jpg" width="81" height="100" alt="<?php echo $product_name; ?>" /><br />
 <a href="inventory_images/<?php echo $img3; ?>.jpg">Full Size</a>
 </div></td>





<td width="76%" valign="top"><h3><?php echo $product_name; ?></h3>
 <p><?php echo "$".$price; ?><br />
 <br />
 <?php echo "$subcategory $category"; ?> <br />
<br />
 <?php echo $details; ?>
<br />
 </p>
 <form id="form1" name="form1" method="post" action="cart.php">
 <input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" />
 <input type="submit" name="button" id="button" value="Add to Shopping Cart" />
 </form>
 </td>
</tr>
</table>
</div>
<?php include_once("template_footer.php");?>
</div>
</body>
</html>

Edited by arunpatal
Link to comment
https://forums.phpfreaks.com/topic/270464-php-code-in-java/#findComment-1391136
Share on other sites

Are you browsing to the file using a URL in your browser? What exactly does the address bar of your browser show for this page?

 

URL look like this http://localhost/product.php?id=4

I first have to select item from index.php page and it takes me to this product.php page

Link to comment
https://forums.phpfreaks.com/topic/270464-php-code-in-java/#findComment-1391145
Share on other sites

URL look like this http://localhost/product.php?id=4

I first have to select item from index.php page and it takes me to this product.php page

 

PHP must be parsed server-side. It is not parsed by client.

Why are you using PHP?

 

func_server_web.png

^ Should explain how it works.

 

You use Javascript or HTML5 or something like that for client-side scripting.

Things that the server decide and is dynamic etc can be done by for example PHP, or actually Java.

http://en.wikipedia.org/wiki/Server-side_scripting

Edited by MMDE
Link to comment
https://forums.phpfreaks.com/topic/270464-php-code-in-java/#findComment-1391181
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.