PHP - Won't Echo Out Text After Space In Textbox
I have some problem when I want to echo out a text which is retrieve from my database and place it inside a text box but it stops showing when there's a space.
If I echo it out outside of the textbox, then there's no problem. May I know how to resolve this problem. Thanks Similar Tutorials I want to add a space after $item in the below statement so that there is more space between the output of Item and Qty. Hi i have this edit form that allows user to mofy data but the problems on the text box is that it deletes the rest of the data after the space from the first word i tried to increase the size of the varChars on mysql but did no work why it happens how can i stop from happening?? this the form input <input type="text" name="name" id="name" class='text_box' value="<?php echo $_GET['name'];?>"/> I have a text box for users to enter new text in. The box also contains text that is determined by a variable that is created from a mysql query and some other added text. I want to make a portion of the added text within the textbox bold. How would I achieve this with php? Code: [Select] <?php result = mysql_query("SELECT `something` FROM `table` WHERE `this` = '$that'"); row = mysql_fetch_row($result); $variable = $row[0]; $text = "<strong>Here is the text that I want bold</strong> $variable"; echo "<textarea name=\"textbox\">"; echo "$text"; echo "</textarea> ?> Doing this gives me this result in the textbox: "<strong>Here is the text that I want bold</strong> This is what the variable text says." Any ideas? Hi im new to php. what im trying to do is echo the result out to a textbox and can't seem to figure it out. I can echo the result to my screen just fine,its when i try to echo it oout to the textbox i cant figure out. I have added my code below. Thanks will Code: [Select] <?php //DATABASE CONNECTION// include 'include/test.php'; $team = $_POST["Team"]; $COUNT = 'COUNT(id)'; $query = "SELECT COUNT(id) FROM `teamrosters` WHERE TEAM = '$team' "; $result = mysql_query($query); // Print out result while($row = mysql_fetch_array($result)) { echo 'ROSTER COUNT: '. $row [$COUNT]; } echo mysql_error() ?> <h1 class="will"><span class="will">Welcome to B410 Team Rosters Page</span></h1> <p class="will"><span class="will">Just pick the team from the drop down menu you wan't to see and hit summit</span></p> <p> </p> <form action="formsummit.php" method="post" name="form1" id="form1"> <label for="Team" class="will">Team</label> <select name="Team" id="Team"> <option value="Auburn">Auburn</option> <option value="Texas">Texas</option> <option value="OSU">OSU</option> <option value="USC">USC</option> <option value="UCLA">UCLA</option> <option value="Vandy">Vandy</option> <option value="Michigan">Michigan</option> <option value="Texas AM">Texas AM</option> <option value="Texas Tech">Texas Tech</option> <option value="Colorado">Colorado</option> <option value="Washington">Wasington</option> <option value="Iowa ST">Iowa ST</option> </select> <input type="submit" name="summit" id="summit" value="Submit" /> <label for="text">avg team speed</label> <input type="text" name="text" id="text" value=" <?php echo $row ['COUNT(id)'];?> " /> </form> How would I open a text file from another server and echo it. http://mysite.com/news/feed.txt Hi guys I have created a profile page where users can update their profile. what I need to do is to echo back the users details in the inout text I have name and telephone number any ideas how to do it? here is my code <?php session_start(); include ("global.php"); //username session $_SESSION['username']=='$username'; $username=$_SESSION['username']; //welcome messaage echo "Welcome, " .$_SESSION['username']."!<p>"; if ($_POST['register']) { //get form data $name = addslashes(strip_tags($_POST['name'])); $telephonenumber = addslashes(strip_tags($_POST['telephonenumber'])); $query = "UPDATE users SET name = ' $name' WHERE username='$username'"; $result = mysql_query($query); $query = "UPDATE users SET telephonenumber = ' $telephonenumber' WHERE username='$username'"; $result = mysql_query($query); } ?> <form action='updateprofile.php' method='POST'> Company Name:<br /> <input type='text' name='name'><p /> <input type='text' name='telephonenumber'><p /> <input type='submit' name='register' value='Register'> </form> _______ the reason i want to do this is because when user is updating the name field the empty input text for telephone number ovverides the telephone number field in the database. I would aprreciate your help guys, Hi All, If someone types in my textarea without any hard returns, it echos the entire text on a single line, which expands my site very very far and screws up the layout. how can I echo the text but limit the number of characters per line before I insert my own line break? The code is just: Code: [Select] echo $message; I have a .txt file containing hundreds of lines of Names (e.g. Brad, Jennifer, etc.) What coding can I use to only echo the first 20? Hello, I am having a problem with a link text when ever there is a text that has multiple words. (e.g. 2 Cor prints out with the white space but when I click on the text the url is printed without the text as 2Cor and so it doesn't find a match) here is my code: Code: [Select] <?php if($_GET['book'] == ''){ $books = $wpdb->get_results(" SELECT book_name FROM {$wpdb->prefix}sb_books_sermons LEFT JOIN {$wpdb->prefix}sb_books ON {$wpdb->prefix}sb_books_sermons.book_name = name GROUP BY book_name ORDER BY {$wpdb->prefix}sb_books.id ASC "); foreach($books as $book){ echo '<li><div class="droidlist"><a href="bible/?book='.htmlentities($book->book_name).'">'.$book->book_name.'</a></div></li>'."\n\t"; } } Good day to everybody ! I'm working on a small to-do list. I have created a text editor to add no todo to it. Here is the code : <script> //modified version of http://www.webmasterworld.com/forum91/4686.htm //myField accepts an object reference, myValue accepts the text string to add function insertAtCursor(myField, myValue) { //fixed scroll position textAreaScrollPosition = myField.scrollTop; //IE support if (document.selection) { myField.focus(); //in effect we are creating a text range with zero //length at the cursor location and replacing it //with myValue sel = document.selection.createRange(); sel.text = myValue; //Mozilla/Firefox/Netscape 7+ support } else if (myField.selectionStart || myField.selectionStart == '0') { myField.focus(); //Here we get the start and end points of the //selection. Then we create substrings up to the //start of the selection and from the end point //of the selection to the end of the field value. //Then we concatenate the first substring, myValue, //and the second substring to get the new value. var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); myField.setSelectionRange(endPos+myValue.length, endPos+myValue.length); } else { myField.value += myValue; } //fixed scroll position myField.scrollTop = textAreaScrollPosition; } </script> <form action="ajoutage.php" method="post" name="ajout" id="ajout"> <table cellpadding="0" cellspacing"0" border="0"> <input type="hidden" name="sujet" value="<?PHP echo $_GET['sujet']; ?>"/> <input type="hidden" name="categorie" value="<?PHP echo $_GET['categorie']; ?>"/> <tr><td width="85px">Titre : </td><td><input type="text" name="titre"/></td> <td></td> <td>Ajouteur : </td><td align="right"><input type="text" name="ajouteur" value="<?PHP echo $qui; ?>"/></td> </tr> <tr><td width="85px">Sujet : </td><td><input type="text" name="sujet"/></td> <td></td> <td>Status : </td><td align="right"><input type="text" name="status"/></td> </tr> <tr><td width="85px">Catégorie : </td><td><input type="text" name="categorie"/></td> <td></td> <td>Niveau : </td><td align="right"><input type="text" name="niveau"/></td> </tr> <tr><td colspan="5">Tâche : <a href="#" onClick="insertAtCursor(document.ajout.tache, '<tr><td></td>\n<td>*&0&*</td>\n</tr>\n')">Progress</a> | <a href="#" onClick="insertAtCursor(document.ajout.tache, '<tr colspan=3>\n<td></td>\n</tr>\n')">Pleinne</a> | <br><textarea name="tache" id="tache" cols="70" rows="20" wrap="off" spellcheck="false"></textarea></td> </tr> <tr><td colspan="5"><input type="submit" value="Ajouter"/></td></tr> </table> </form> It works very fine, as you can see there is to links that is use to add some text in the textarea, where ever the cursor is. Where it starts : I have also created another form to modify the todo's once they are created. The only problem here is that my 2 links for adding text to the textarea don't work at all, they do nothng, no error shown, no text added. Here is the code use to modify the todos once created: <script type="text/javascript"> //modified version of http://www.webmasterworld.com/forum91/4686.htm //myField accepts an object reference, myValue accepts the text string to add function insertAtCursor(myField, myValue) { //fixed scroll position textAreaScrollPosition = myField.scrollTop; //IE support if (document.selection) { myField.focus(); //in effect we are creating a text range with zero //length at the cursor location and replacing it //with myValue sel = document.selection.createRange(); sel.text = myValue; //Mozilla/Firefox/Netscape 7+ support } else if (myField.selectionStart || myField.selectionStart == '0') { myField.focus(); //Here we get the start and end points of the //selection. Then we create substrings up to the //start of the selection and from the end point //of the selection to the end of the field value. //Then we concatenate the first substring, myValue, //and the second substring to get the new value. var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); myField.setSelectionRange(endPos+myValue.length, endPos+myValue.length); } else { myField.value += myValue; } //fixed scroll position myField.scrollTop = textAreaScrollPosition; } </script> <?php $con = mysql_connect("localhost","XXXXXX","XXXXXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("XXXXXX", $con); $id = $_GET['id']; $qui = $_GET['qui']; $sujet = $_GET['sujet']; $categorie = $_GET['categorie']; $result = mysql_query("SELECT * FROM todo where id='$id'"); while($row = mysql_fetch_array($result)) { echo " <form action=\"modifiage.php\" name=\"ajout\" id=\"ajout\" method=\"post\"> <table cellpadding=\"0\" cellspacing\"0\" border=\"0\"> <input type=\"hidden\" name=\"id\" value=\"" . $row['id'] . "\"/> <input type=\"hidden\" name=\"qui\" value=\"" . $row['ajouteur'] . "\"/> <input type=\"hidden\" name=\"sujet\" value=\"" . $row['sujet'] . "\"/> <input type=\"hidden\" name=\"categorie\" value=\"" . $row['categorie'] . "\"/> <tr><td width=\"85px\">Titre : </td><td><input type=\"text\" name=\"titre\" value=\"" . $row['titre'] . "\"/></td> <td></td> <td>Ajouteur : </td><td align=\"right\"><input type=\"text\" name=\"ajouteur\" value=\"" . $row['ajouteur'] . "\"/></td> </tr> <tr><td width=\"85px\">Sujet : </td><td><input type=\"text\" name=\"sujet\" value=\"" . $row['sujet'] . "\"/></td> <td></td> <td>Status : </td><td align=\"right\"><input type=\"text\" name=\"status\" value=\"" . $row['status'] . "\"/></td> </tr> <tr><td width=\"85px\">Catégorie : </td><td><input type=\"text\" name=\"categorie\" value=\"" . $row['categorie'] . "\"/></td> <td></td> <td>Niveau : </td><td align=\"right\"><input type=\"text\" name=\"niveau\" value=\"" . $row['niveau'] . "\"/></td> </tr> <tr> "; $tache = $row['tache']; $tache = str_replace("<div class=\"progress-containers\"><div style=\"width:","*&",$tache); $tache = str_replace("%\"><br></div></div>","&*",$tache); $onmouse = '<tr onMouseOver="this.className=**highlight**" onMouseOut="this.className=**normal**"><td>'; $tache = str_replace($onmouse,"<tr><td>",$tache); echo " <td colspan=\"5\">Tâche : <a href=\"#\" onClick=\"insertAtCursor(document.ajout.tache, '<tr><td></td>\n<td>*&0&*</td>\n</tr>\n')\">Progress</a> | <a href=\"#\" onClick=\"insertAtCursor(document.ajout.tache, '<tr colspan=3>\n<td></td>\n</tr>\n')\">Pleinne</a> | <br><textarea name=\"tache\" id=\"tache\" cols=\"70\" rows=\"20\" wrap=\"off\" spellcheck=\"false\">" . $tache . "</textarea></td> </tr> <tr><td colspan=\"5\"><input type=\"submit\" value=\"Modifier\"/></td> </tr> </table> </form> "; } mysql_close($con); ?> Hi, Have a text file that is being read. I want to print the contents however I want each line of the text file to appear on a new line in the browser. So far $str = file_get_contents('records.txt'); $lines = explode("\n", $str); echo $lines[0]; Help appreciated Hello, I have the following code writting IP,session, and date to a text file (it works) but I want to add a white space after the IP address. fwrite($fp, $_SERVER['REMOTE_ADDR']. $_SESSION["sess_name"]. " $dateTime\r\n"); At the moment it prints like this 16.17.51.41SESSION_ID 2011/01/23 12:53:32 thanks in advance. I have a form on my website with a text area input field. I am looking for a php function that can strip the formating from the Text and take out line breaks and paragraphs so that when i retrieve the information from database i can change it from this _____________________________________ FANTASTIC BARGAINS ALL SPRING / SUMMMER 2010 ...... STOCK NOW REDUCED to this FANTASTIC BARGAINS ALL SPRING / SUMMMER 2010...... STOCK NOW REDUCED does anyone know what fucntion i could use for this? i have this so far but it doesnt seem to be working $descr = ''; if(strlen($row['description']) > DESCR_LIMIT) { $descr = (substr($row['description'], 0, DESCR_LIMIT).'...'); } else { $descr = $row['description']; } $descr = preg_replace("/(\r\n)+/", " ", $descr); $descr = preg_replace("/ +/", " ", $descr); $status .= $descr; OK, have no idea what's going on... I've done this a million times... why wont this output!?? I must have a major brain meltdown and dont know it yet!!! Code: [Select] <?php // this echoes just fine: echo $_POST['testfield']; // but this wont echo: echo if (isset($_POST['testfield'])) { $_POST['testfield'] = $test; } echo $test; /// or even this DOESNT echo either!: $_POST['testfield'] = $test; echo $test; ?> I have a table with postcodes in it. At some point some of the codes will be entered with spaces (LA12 5TH) and some without (LA17HU) what i need is a function to check if there is a space, if not - count back 3 characters from the end of the string and insert a space. I don't know which string function to use - looked at pad but that seems to be for either end of string and not the middle - any ideas? Hi All, I'm trying to echo the response from an SLA query, the query works and returns the data when I test it on an SQL application.. but when I run it on my webpage it won't echo the result. Please help? <?php $mysqli = mysqli_connect("removed", "removed", "removed", "removed"); $sql = "SELECT posts.message FROM posts INNER JOIN threads ON posts.pid=threads.firstpost WHERE threads.firstpost='1'"; $result = mysqli_query($mysqli, $sql); echo {$result['message']}; ?> I have a log system that allows 10 logs on each side(Left and right). I am trying to make it so that the left side has the 10 most recent logs, then the right as the next 10. Any ideas? So I need to echo a row from my database with php, but where i need to echo is already inside an echo. This is my part of my code: $con = mysql_connect("$host","$username","$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("main", $con); $result = mysql_query("SELECT * FROM Vendor"); while($row = mysql_fetch_array($result)) { //I need to echo right here .................. but I get a blank page when I try this. Please Help. echo '<option value=$row['vendor_id']>'; echo $row['vendor_id']; echo '</option>'; } mysql_close($con); Result: A Blank page. Thanks in advance! Hi
I try to echo out random lines of a html file and want after submit password to whole content of the same html file. I have two Problems.
1st Problem When I echo out the random lines of the html file I don't get just the text but the code of the html file as well. I don't want that. I just want the text. How to do that?
for($x = 1;$x<=40;$x++) { $lines = file("$filename.html"); echo $lines[rand(0, count($lines)-1)]."<br>"; }I tried instead of "file("$filename.html");" "readfile("$filename.html");" But then I get the random lines plus the whole content. Is there anything else I can use instead of file so that I get the random lines of text without the html code?P.S file_get_contents doesn't work either have tried that one. 2nd Problem: As you could see in my first problem I have a file called $filename.html. After I submit the value of a password I want the whole content. But it is like the program did forget what $filename.html is. How can I make the program remember what $filename.html is? Or with other words how to get the whole content of the html file? My code: if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ $my_file = file_get_contents("$filename.html"); echo $my_file; } else{ echo "You entered wrong password"; } }If the password isn't correct I get: You entered wrong password. If the password is correct I get nothing. I probably need to create a path to the file "$filename.html", but I don't know exactly how to do that. Hi all i have been trying for 6 hours to write some code that will show a text box and the user puts in there id then it provides a link with the id in the middle of it so say the id is 111555 the link is http://example.com.au/data/users/111555/2011/1/1 i want the user to insert their id and do if the id 343034 the link is http://example.com.au/data/users/343034/2011/1/1 can any one give me the code to this i have gotten no where from tutorials please matt |