elabuwa Posted September 24, 2009 Share Posted September 24, 2009 Hey guys, again I'm stuck on this simple code. I might have missed something so want your help. Basically, my issue is this. The textbox cusadd is supposed to have the customers address. But when the page is displayed only the first word is entered in the text box automatically. But if echo the string, the entire value is shown. My code is below. The bolded section is where i need your help. <?php ob_start(); $database = $_COOKIE["database"]; $password = $_COOKIE["password"]; $username = $_COOKIE["username"]; $host="localhost"; // Host name $db_name=$database; // Database name $tbl_name="cards"; // Table name mysql_connect("$host", "$username", "$password")or die(mysql_error()); mysql_select_db("$database")or die(mysql_error()); $nama = $_GET["nama"]; $ty = "customer"; //$query="SELECT * FROM $tbl_name WHERE nama = '$nama' AND type = '$ty'"; $query="SELECT addy,tel FROM $tbl_name WHERE nama = '$nama' AND typer = '$ty'"; $result=mysql_query($query); $num=mysql_num_rows($result); while($row = mysql_fetch_array($result)) { $cusadd = $row['addy']; $custel = $row['tel']; } echo "<form name='edit_php' id='form' method='post' action = 'customer_editor.php'>"; echo "<table width='763' height = '65' border='1' bordercolor='#ECE9D8' bgcolor='#CC0033'>"; //echo "<table width="763" height="65" border="1" bordercolor='#ECE9D8' bgcolor='#CC0033' >"; echo "<tr>"; $a = "Edit Customer Details : " . $nama ; echo "<td align='center' valign='middle'><span class='style2 style1'><span class='style7'>".$a."</span></span></td>"; echo "</tr>"; echo "</table>"; echo "<br>"; //echo "<label><strong class='style3 style6'>Old Account Number :</strong><br />"; echo "<br>"; echo "<input type='hidden' name='nama_old' id='nama_old' value=".$nama.">"; echo "<br>"; echo "<br>"; echo "<label><strong class='style3 style6'>New customer Name :</strong><br />"; echo "<br>"; echo "<input type='text' name='nama' id='nama' value=".$nama.">"; echo "<br>"; echo "<p class='style4'>Please enter the new address.</p>"; echo "<br>"; echo "<label><strong class='style3 style6'>Customer Address :</strong><br />"; echo "<br>"; echo "<input type='text' name='cusadd' id='cusadd' value=".$cusadd."/input>"; echo $cusadd; exit; echo "<p class='style4'>Please enter the new address.</p>"; echo "<br>"; echo "<label><strong class='style3 style6'>Telephone :</strong><br />"; echo "<br>"; echo "<input type='text' name='custel' id='custel' value=".$custel.">"; echo "<p class='style4'>Please enter the new telephone number.</p>"; echo "<input type='submit' name='update_cuscard' id='submitter' value='Edit Customer' />"; echo "</form>"; ?> If you can help me out on this I'd appreciate it very much. FYI php is working fine, the file has a .php extension. All other text boxes load fine exept for this ( I didnt test the cusname text box) how ever if i get the solution for the current one then the its gonna be the same for cusname. thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/175398-solved-text-box-not-having-the-entire-string-value/ Share on other sites More sharing options...
elabuwa Posted September 24, 2009 Author Share Posted September 24, 2009 I tried the below code with no luck as well. echo "<input type='text' name='cusadd' id='cusadd' value=".htmlspecialchars($cusadd)."/>"; Quote Link to comment https://forums.phpfreaks.com/topic/175398-solved-text-box-not-having-the-entire-string-value/#findComment-924272 Share on other sites More sharing options...
knsito Posted September 24, 2009 Share Posted September 24, 2009 The address is only on one line or multiple lines? You probably want textarea not text. http://www.w3schools.com/TAGS/tag_textarea.asp I tried the below code with no luck as well. echo "<input type='text' name='cusadd' id='cusadd' value=".htmlspecialchars($cusadd)."/>"; Quote Link to comment https://forums.phpfreaks.com/topic/175398-solved-text-box-not-having-the-entire-string-value/#findComment-924274 Share on other sites More sharing options...
PFMaBiSmAd Posted September 24, 2009 Share Posted September 24, 2009 The value='...' attribute needs to be enclosed in quotes and you should use htmlentities() with the 2nd parameter set to ENT_QUOTES Quote Link to comment https://forums.phpfreaks.com/topic/175398-solved-text-box-not-having-the-entire-string-value/#findComment-924277 Share on other sites More sharing options...
elabuwa Posted September 25, 2009 Author Share Posted September 25, 2009 Knsito, PFMaBismAd ; thank you guys. both of your tips worked like a charm. the below code worked. echo "<textarea name='cusadd' id='cusadd' cols='45' rows='5' value = ".htmlentities($cusadd,ENT_QUOTES)."/textarea>"; thank thank you again guys Quote Link to comment https://forums.phpfreaks.com/topic/175398-solved-text-box-not-having-the-entire-string-value/#findComment-924564 Share on other sites More sharing options...
elabuwa Posted September 25, 2009 Author Share Posted September 25, 2009 ok tried the following but still with no luck :( $nama1 = htmlentities($cusadd,ENT_QUOTES); echo $nama1; echo "<textarea name='cus_add' id='cus_add' cols='45' rows='5'- -value='" . $nama1 . "'</textarea>"; the problem is no value loads up to the text area. i kinda wanted to delete the above post but apparently i cant. i thought it worked for a while but when i suddenly refreshed the page it didnt work and so did all the retries of loading the page from scratch. Quote Link to comment https://forums.phpfreaks.com/topic/175398-solved-text-box-not-having-the-entire-string-value/#findComment-924578 Share on other sites More sharing options...
PFMaBiSmAd Posted September 25, 2009 Share Posted September 25, 2009 The value="..." attribute only applies to your original type='text' field. It is not used for a <textarea></textarea> For a textarea, you output the content between the two tags. Quote Link to comment https://forums.phpfreaks.com/topic/175398-solved-text-box-not-having-the-entire-string-value/#findComment-924581 Share on other sites More sharing options...
knsito Posted September 25, 2009 Share Posted September 25, 2009 Like this <textarea textarea name="cusadd" id="cusadd" cols="45" rows="5"> --- Your Text Here --- </textarea> BTW I think the standard for attributes is to use double quotes, not single. (maybe it doesnt matter.. I dont remember :\) ok tried the following but still with no luck :( $nama1 = htmlentities($cusadd,ENT_QUOTES); echo $nama1; echo "<textarea name='cus_add' id='cus_add' cols='45' rows='5'- -value='" . $nama1 . "'</textarea>"; the problem is no value loads up to the text area. i kinda wanted to delete the above post but apparently i cant. i thought it worked for a while but when i suddenly refreshed the page it didnt work and so did all the retries of loading the page from scratch. Quote Link to comment https://forums.phpfreaks.com/topic/175398-solved-text-box-not-having-the-entire-string-value/#findComment-924808 Share on other sites More sharing options...
elabuwa Posted September 26, 2009 Author Share Posted September 26, 2009 kewl guys it worked. thank you Quote Link to comment https://forums.phpfreaks.com/topic/175398-solved-text-box-not-having-the-entire-string-value/#findComment-925299 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.