PHP - Echo Sql Query To Text Box
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> Similar TutorialsHi 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']}; ?> like so... echo" $query = mysql_query("SELECT * FROM table WHERE memberID = ".$User['memberID'].""); "; ?????????????? Hey guys,
I am stuck on this piece of code. Within the function I am using I need to include an mysql query. I am not sure how to insert it within the echo. Currently the query works but the code stops once close the '' and </ul> and </section> are cut out.
Please note that there is alot more code within the echo, not just the section and ul. Just simplified it for my question.
Any help would be appreciated.
Thanks
This serves more or less a meaningless purpose for my testing, but I've been trying to echo out the names of the tables that are being used in my UPDATE and SELECT queries and I have yet found a way to do this.. Did some research on php.net and Google and did not find anything that seems to directly address this.. My guess is it's so stupid simple, I probably will have an answer by the time I wake up.. But id there are any suggestions on this, Id be glad to take. Good Afternoon Team, Am sitting with something simple using the language below. If I copy the echo output of my query as included below it works perfectly in phpmyadmin but doesn't work on a website. Variables all seem to echo consistently/correctly and POST checks seem to verify this is working correctly as well. I worry the error comes with the syntax I used in combining the sql queries. That, or perhaps LAST_INSERT_ID does not work in the php script as well as it does in phpmyadmin. All help appreciated.
if(isset($_POST[`region_id`])) {
here is my code... please help <form method="get" action="shit3.php"> <input maxlength="50" size="50" type="text" name="q"> <input type="submit" value="SEARCH"> </form> <?php if (@$_GET['q']) { $var = $_GET['q'] ; $trimmed = trim($var); $limit=1; if ($trimmed == "") { echo "Please enter a search..."; exit; } if (!isset($var)) { echo "Container not found!"; exit; } mysql_connect("localhost", "xxx", "yyy") or die(mysql_error()); mysql_query("SET NAMES 'cp1251'"); mysql_select_db("agaexpor_container") or die("Unable to select database"); //select which database we're using $query = "select * from containertracking where vin like \"%$trimmed%\" order by vin"; $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); if (empty($s)) { $s=0; } $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); $count = 1 + $s ; while ($row= mysql_fetch_array($result)) { $vin = $row["vin"]; $container = $row["container"]; echo "$count.) VIN: $vin <br />"; echo "container is: $container <br />"; $count++ ; } } ?> How would I open a text file from another server and echo it. http://mysite.com/news/feed.txt 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 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 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? 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, 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 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); ?> 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 am querying... $sql = "SELECT `messages_inbox`.`message_id`, `users`.`firstname`, `users`.`lastname`, `users`.`username` AS `from`, '${user_info['username']}' AS `to`, `subject`, LENGTH(`files`) AS `len`, 'inbox' AS `box`, DATE_FORMAT(`messages_inbox`.`time` ,'%T %D-%M-%Y') AS `time` "; $sql .= "FROM `messages_inbox` INNER JOIN `users` ON `messages_inbox`.`from_id` = `users`.`id` WHERE `to_id` = ${user_info['uid']} AND `messages_inbox`.`deleted` = 0 ORDER BY `messages_inbox`.`message_id` DESC"; and I am trying to output $displayName = ucwords("${message['firstname']} ${message['lastname']}"); by using $messages = pm_fetch_all($_GET['box']); I know my fetch works but for some reason firstname and lastname are only returning the logged in users first name and last name, not the person who sent the message. Hi, very simple i'm sure... i have a code for a text box to pull info into from a mysql table. easy enough: Code: [Select] <?php echo "<input type=\"text\" id=\"b_info\" name=\"b_info\" value=\"$b_info\" style=\"width: 327px\" /text>"; ?> but suppose i dont just want a "line of text" i want one of those boxes with the scroll bar down the side (lol like the one im writing this in ) how do i change the above code to do it? i though doing this: Code: [Select] <?php echo "<input type=\"textarea\" id=\"b_info\" name=\"b_info\" value=\"$b_info\" style=\"width: 327px\" style=\"height: 185px\" /textarea>"; ?> would work, but obviously not, all ive done is make the box bigger easy workaround? Thanks Hi, I'm new to PHP/MySQL and need some help getting my query to work for my selection list: The selection list is built with: <form action='processformmissing.php' method='POST'> <fieldset> <legend>Choose Department</legend> <select name='depart'> <option value=''></option> <?php while ($row = mysqli_fetch_array($result)) { extract($row); echo "<option value='$department'>$department</option>\n"; } ?> </select> <p><input type='submit' value='Select Department' /></p> </fieldset> </form> The data is then sent to: $depart = $_POST['depart']; $deptlike = "%".$depart."%"; echo "<p>$depart</p>"; echo "<p>$deptlike</p>"; $query = "SELECT * FROM lifecerts INNER JOIN employees ON lifecerts.cid = employees.cid WHERE department LIKE '$deptlike' ORDER BY employees.name"; Hitting the submit button from my selection list form seems to be working fine because when I echo my data ($depart and $deptlike) it is giving me the correct value, but the query doesn't give me any results. However, if my post data comes from a text box instead of a selection list, my query works fine. Any thoughts on what I'm doing wrong??? Many thanks! 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 have just one question (I have searched for an answer for this but have not been able to locate one): How do you go about changing the text on a "Submit Query" button to display simply "Submit"? Below is the current code for the page that displays said button. Thank-you in advance for any help or direction. <?php include 'connection.php'; $query = "SELECT * FROM people"; $result = mysql_query($query) or die(mysql_error()); while ($person = mysql_fetch_array($result)){ echo $person ['name']; echo $person ['descrip']; } ?> <H1>Add Your Review:</H1> <form action="create.php" method="post"> Subject <input type="text" name="inputName" value=""/> </br > Review <textarea cols="50" rows="4" name="inputDesc" value=""/></textarea> </br > <input type= "submit" name= "submit"/> </form> <html> <head></head> <body> <p>The current second is <span style='font-size:16px;font-weight:bold;color:red;position:absolute;right:25px;'><?php echo time(); ?></span> on this computer.</p> </body> </html> |