2013-04-02 28 views
-1

<form name="form1"/>PHP SQL recordeseet無法通過可變

<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","PASS");

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'];

mysql_close($con);

?>

<?php echo $jval; ?>

<?php echo $fld1; ?>

如果我更換$result2 = mysql_query("SELECT * FROM tblprocode where code='". $jval."';");

<?php echo $abc; ?> // its print as D50

<?php echo $jval; ?> // its print as D50

<?php echo $fld1; ?> // its not print, its blank

如果我更換$result2 = mysql_query("SELECT * FROM tblprocode where code='". $c."';");

<?php echo $abc; ?> // its print as D50

<?php echo $jval; ?> // its print as D50

<?php echo $fld1; ?> // its print record data

請幫我什麼是錯誤的?

回答

0

我認爲你應該使用trim功能$jval = trim($abc);

+0

感謝你的幫助,它不是成功, '<?PHP' '$ CON =的mysql_connect( 「localhost」,則 「abc_one」,」通過「);' 'mysql_select_db(」abc_one「,$ con);' 'echo'abc is_'。$ abc; echo'abc is_'。$ abc; //顯示爲abc is_D50abc is_D50因此沒有TRIM ISSUE' '$ result2 = mysql_query(「SELECT * FROM tblprocode where code ='」。$ c。「';」);' '$ tab = mysql_fetch_array( $ RESULT2);' '$ FLD1 = $標籤[ '卡'];' 'mysql_close($ CON);' '>' ' // ITS PRINT AS D10' '<?php echo $ fld1; ?> //其空白' – user2235050

+0

**謝謝你的幫助,但它不成功**'echo'abc is_'。$ abc; echo'abc is_'。$ abc; //顯示爲abc is_D50abc is_D50,所以不需要TRIM ISSUE' – user2235050