Jump to content

Recommended Posts

<form name="form1"/>
<input type="text" name="code1" value="D50" size="7" maxlength="10" onblur="chkidpro(this.value,'provider1');" />
<input type="text" name="code2" value="" size="7" maxlength="10"/>
<form/>

<script type="text/javascript">

var jvalue = form1.code1.value;
<?php $abc = "<script>document.write(jvalue)</script>"?>
</script>

<?PHP
$con = mysql_connect("localhost","abc_one","12345678");
mysql_select_db("abc_one", $con);

$c= "D50";

$jval = $abc;

$result2 = mysql_query("SELECT * FROM tblprocode where code='". $c."';");

$tab = mysql_fetch_array($result2);
$fld1 = $tab['card'];
$fld2 ='25';
mysql_close($con);
 ?>

<?php echo $jval; ?>
<?php echo $fld1; ?>

 

 

PROBLEM IS IF I REPLACE VARIABLE $c FOR $jval WILL NOT WORK

 

$result2 = mysql_query("SELECT * FROM tblprocode where code='". $jval."';");

 

ITS PRINT LIKE THIS

 

<?php echo $jval; ?>  PRINT AS D50
<?php echo $fld1; ?> NOTHING ITS BLANK

 

IF I REPLACE VARIABLE $c FOR $jval WILL NOT WORK

 

$result2 = mysql_query("SELECT * FROM tblprocode where code='". $c."';");

 

ITS PRINT LIKE THIS

 

<?php echo $jval; ?>  PRINT AS D50
<?php echo $fld1; ?> PRINT RECORD DATA

 

Link to comment
https://forums.phpfreaks.com/topic/276421-php-variable-problem/
Share on other sites

Please put your code in [ code ] [ /code ] tags...

 

Also, I have no idea why you are trying to write JS in PHP in JS here

 

<script type="text/javascript">

var jvalue = form1.code1.value;
<?php $abc = "<script>document.write(jvalue)</script>"?>
</script>

 

Why dont you use Ajax?

Edited by DaveyK

i want to use input box name code1 typed text, should search sql recordset and display in textbox code2.value

 

example : code1 input box if typed as D10 should display in code2 input box as DIAL 10

 

<?php echo $jval; ?> // its printing data
<?php echo $fld1; ?> // its printing data

<?php echo $abc; ?> // its printing data

 

but sql quary not passing value
 

Please put your code in [ code ] [ /code ] tags...

 

Also, I have no idea why you are trying to write JS in PHP in JS here

 

<script type="text/javascript">

var jvalue = form1.code1.value;
<?php $abc = "<script>document.write(jvalue)</script>"?>
</script>

 

Why dont you use Ajax?

 

Thank you for your suggestion, i'm not advanced user, please help me what was the wrong ??

 

i want to use input box name code1 typed text, should search sql recordset and display in textbox code2.value

 

example : code1 input box if typed as D10 should display in code2 input box as DIAL 10

 

<?php echo $jval; ?> // its printing data

<?php echo $fld1; ?> // its printing data

<?php echo $abc; ?> // its printing data

 

but sql quary not passing value

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.