Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




How Can I Print Out Multiple Text Input Boxes?


How Can I Print Out Multiple Text Input Boxes. The function below prints out three text boxes. The code below is static, cannot accept user input, and therefore cannot be changed. What I need to do is write a function or maybe a class that can accept user input and print or echo a different number of text boxes, depending on the user input.

The name variable for each of the textboxes needs to have a different name. For example, the name for the first text box would be something like "name=textfield1", the second would be "name=textfield2", and so forth. PHP Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Spaces In <input Text> Boxes.
When I submit a form where a user has typed a space into the input box, then check that value in the action .php file, only the text before the first space is displayed. How can I get all of the text sent?

eg

Code:
<form name="form2" method="post" action="temp.php">
<input type="text" name="name">
<input type="submit" name="Submit" value="Submit">
</form>

Then in temp.php
Code:
echo "Username = $name";

If the user enters "Greg Bennet" into the text field, I get back "Username = Greg".

Keep Text In Text Boxes After Form Is Rewritten
I'm trying to make a form that does the following:

(1) the user answers a question by typing in a text box
(2) a response is then written below the form, saying whether the answer is right or wrong and, perhaps making a comment of some kind
(3) the user's answer remains visible in the original text box

I've managed to write some code that does the first two things, but despite many attempts and much searching for code examples, I've failed to find a way of getting the answer to reappear in the text box when the page is rewritten.

This is my code:

Multiple Multiple Select Boxes
I'm looking to have multiple multiple-select-boxes on a page. But I
can only get the contents from the last selected value within a box,
via PHP. I've tried numerous methods. What am I doing wrong?

You can see ALL the values present in the url:
http://myserver/test.php?notify_use..._updcats=Update
e.g.......

Multiple Drop Down Boxes
I want to create two multiple drop down boxes, the first will display all the company names, once this has been selected all the stock information for that company will appear in the second drop down boxes.

An Array Of Text Boxes
I have the full code in a php script where I essentially display a form with checkboxes, and 2 text boxes associated with each checkbox to record grades ( marks and remarks ). The form displays correctly and the checkboxes I select do pass the correct id numbers for the students to be graded, also the numeric data in the first textbox is correctly transmitted HOWEVER the data in the second textbox gets randomly truncated.

e.g, if the "remarks" textbox has 'hello', it gets truncated to 'o'. It seems I'm not resetting something or there is another simple oversight somewhere, perhaps the script treating the data as a string rather than as an array Code:

Dynamic Text Boxes
I have a form where field techs can close out service calls, Time in, time out, work done, who the tech is....ect...

Currently I have 20 fields for parts..... Part1 / Part1QTY....and so on to Part10 / Part10QTY.... the form emails, and it also feeds data into MySQL... so everything is working fine...

What I would like to do, is stream line it...so there is only 2 fields...part_number and qty....and when techs needs to enter more parts then click on a button that creates 2 new sets of text boxes for input....
thus allowing me to have them enter more the just 10 parts and qty's.

I thought about, maybe having a secondary form on my HTML page, with different sets of submit buttons, and they can enter 1 part at a time... but I could not get the secondary form Submit button to not clear the data in the primary form...so that didn't work for me.! I'm am basically stuck here... there maybe one or two other issues I have...but those are not so critical.

I do have a great deal of MS Access experience but this PHP is a totally different monster. For those who know access, it's very easy to add a new record in a subform and just keep adding records...which is sort of what I'm trying to do here.

Handling Multiple Check Boxes
I have a PHP generated page which displays X many records. Each record has
a checkbox preceding it. The user checks several checkboxes, and hits a
delete button. All the corresponding records will be deleted.

But I'm running into difficulty...

Right now the NAME property of each check box is the primary key of the
corresponding record. Hence if I know which checkboxes are checked, I
simply use DELETE using the NAME value.

Generally speaking, how do I get the server side to see which check boxes
were checked?

The check box names may not be sequential, if any records have been deleted
previously, and the first check box might be a number greater than 0.

Is there an easy mechanism to do this? Some kind of built in cnotrol array
allowing me to loop over every check box that was on the form submitted?

I could store the last and first checkbox number in a hidden input, then
loop starting/ending at those values, but that may loop over a lot of
controls that do not exist.

Dynamic Text Boxes With While Loop?
Basically I have a dynamic number of categories. Each of these categories requires a text box, therefore I have a dynamic number of text boxes. My question is if there is anyway using a while loop that this can be done?

<?
while ($nextcat = array.php($categories))
{
echo $nextcat;
$varname = $strip_tags($nextcat)
?>
<input type = textarea name = <? $varname ?>>
<? } ?>

Passing Values From Text Boxes
what I'm trying to do is pass some values from text boxes, yes it may sound simple, but let me explain more... I've got a form, and what I want to do is that when you enter a new question and select a existing category from the drop down box, it then inserts the values into the database no problem. However if enter a new question, and a new category, then submit the info, I get a null value. The Code...

Punctuation Marks In PHP Text Boxes
I am not a PHP user; I manage the server/ network for our business.
We've employed web developers (chosen because they're friends of the
MD) to build us a site and they've used PHP & MySQL to do it.

The problem we have is that if we use an apostrophe when writing a
product description or product title in the back office of our site,
when that data is then used or carried through to another part of the
site eg. a live product page or an order summary page, the apostrophe
has a backslash before it. We have run into other issues with the use
of various punctuation marks in the text fields of the back end of the
site and have always been told by the developers that it is a fault of
PHP and is common with PHP text fields.

Now, as I said, I'm not a PHP user and certainly no expert. But I have
installed and used Mambo Server, Wordpress, phpBB and a couple of other
PHP MySQL products through my own curiosity and have done so
successfully and have never experienced any of the issues we seem to be
facing with these text boxes. I am growing increasingly suspicious of
the level of competence of the developers and feel that they are making
excuses for their inability. Can anyone tell me, from what I've said
here, whether my suspicions are justified or is it the case that PHP is
limited in these areas?

Filtering Selection In Multiple Drop Down Boxes
I want to allow a user to conduct a search on a database using multiple drop down boxes.
On the first page they will have a drop box filled with records from field A. Once they select which one they want, a second drop down box will then appear with records from field B which are present for field A (a filter).

What I want though is that the first dwon down box still appears on the second page, but shows the record that the user selected. What is happening now is that when the second page comes up, the first box shows the default selection rather than the selection that the user chose. My code for the drop down boxes is: PHP Code:

Dynamic Number Of Text Boxes/insert
On page one I ask 'How many boxes do you want?' and I have a simple form - the code is below:

<form action="addhouses.php" method="post">
<input type="text" name="numimages" size="3">
<input type="submit" name="submit" value="Submit">
</form>

On the next page I want to display how ever many boxes they said on the previous page.
Let's say they choose 4 - there are then 4 boxes which allow you to browse to files on your computer. Clicking submit on this page takes you to the third page which uploads the files and inserts the filenames into the database. Currently the code I have on the third page works fine for a static number of defined boxes. It is: PHP Code:

Auto-populating Multiple Boxes... Php And Pg_fetch_array Problem?
There is a nice tool using jquery/php to populate multiple select boxes out
there, it must be a very stupid question but I?m trying to apply this tool to get data from postgreSQL, but I always get an empty [] value. It means that the...

Select Menu OnChange To Update Text Boxes
I've a select menu filled from mySql, So when I change the selection.. I want to change 3 text boxes also by the same row of database that is = to the row of the select menu.

So i tried a lot but failed.. cuz I cant send to javascript the updated values when the selected menu change.

Multiple Screen Print Out!
I'm a beginning PHP programmer. And I have a problem to write some code.
I have a database (mysql) filled with Funny SMS messages.
Problem:
I want to print out the content of the database on the screen but I can only print them on screen without page breaks. This means if there are 100 messages in the database they all apppear on one page and I want only 5 messages a page with a NEXT button so people can see the next 5 messages.

Multiple Queries That Print To The Same Table?
I have a query that is hitting the same table for the same info just by different means.

1st query looks info up by position.
2nd query looks info up by name.

At this moment the 2nd query works. If I free the result for the 2nd query before it starts then the 1st query works and the second one doesn't. Code:

Multiple Tables Print To One Page
Is it possible to print information from multiple databases on one page/form.  For example, I want to print information that is in three databases, and I want to be able to print a few related fields on one page.  Is that possible?

When To Clean Input Text
I was wondering what people do with text provided by the user in a
form. Some cleaning needs to be done at some stage if you are going to
be putting it in a database or displaying it etc. But when is the time
to do that?

Do you clean it as soon as you get it?
Do you pass around the original text and clean it when you use it?

What about magic slashes? You need to addslashes before using in a db
statement, but you need to strip them when displaying. When do you do
that?

Text Area Input Box With PHP
I have a text area box on one page. PHP sets the information that is inputted into the text area into a variable. When I print this info to the screen via echo, it does't have the line retain the formatting that the user had in the text area. It has no line breaks, it runs everything together.

Input Text Issues
Whenever I receive input from an HTML text field or and HTML text area
with " or ' meaning double or singe quotes into a php variable and
then print or echo it back out to the user in html I get these
characters accompanies by a . Why is this and how can I get rid of it.

$submitform->body=@$_POST['body']; <<<< there are no in the input.

print("body - ".$submitform->body."<br>"); <<<< but here there will
be slashes for all ' or " .

Text Input With Links, Etc..
I hope you can give me a few pointers on this issue.

I'd like visitors to my website to be able to enter text to be viewed on the
site - a bit like a bulletin board or forum. I can do this for regular text
easily by simply populating a 'TEXT' field within my MySQL database and
grabbing it back when rendering the site using PHP. However, I'd also like
visitors to be able to put in URL links or email items that can be clicked.
How would I go about doing this?.I've seen this sort of thing on forums
where words can be selected and a URL applied, but I have no idea how to do
this and how this information (ie. the link and the associated text) would
be stored in the database field(s).
Any ideas?. Are there any PHP examples available for this sort of thing?.

Input SQL Data Through Text Box And Get Nothing?
I want to add SQL command through a textbox in the form using post
method,but when i execute the following file, nothing is added to the
database.
I can add
$sqlol = "update acc_account
set user_name='k'
where accountid=1";
to the database if it was added to the file but when i use $result =
mysql_query($sql); which execute the query, it get nothing. However,
the $sql statement do print out on the screen using print.

<?php
$conn=mysql_connect('localhost', 'shytr8');

if(!$conn)
{print "Error- Could not connect to MYSQL";
exit;}

$er=mysql_select_db("test");

if(!$er){
print "Error- Could not create er";
$query = "CREATE DATABASE test";
mysql_query($query);}

$sql=$_POST[SQLcommand];
$result = mysql_query($sql);
?>

Checking Input Text?
I wondered if this script seemed correct? The user should enter a
userid and password in two text fields, and then pass these values to
the method login_user.

Could I ask, is there any approach to, once the user clicks the submit
button to test the userid and password has been entered, and the text
fields are not empty.

<?php

function login_form(){
?>
<html>
<head>
<title></title>
</head>

<body>

<div align="center">
<form method="post">
<table border="1">
<tr>
<th align="right">E-mail</th>
<td nowrap>
<input name="userid" size="25">
</td>
</tr>
<tr>
<th align="right">Password</th>
<td nowrap>
<input name="password" size="25">
</td>
</tr>
<tr>
<td align="center">
<input type="submit" name="submit" value="Login">
</td>
</tr>
</table>
</form>
<div>
</body>
</html>
<?php
}

login_form();
$user_info = login_user($_POST['userid'], $_POST['password'];
?>

Dynamic Multiple Input Processing
I am creating a simple "or so I thought" php/mysql survey.
There are 3 types of Surveys, with different questions. 1 for Clients,
1 for Employees, 1 for Peers.
Questions for each survey are created, editable, removable, and drag/
drop sortable.
Options to these questions are dynamic themselves.

Basically, everything works except when I try to Insert the data into
the answers table.

The one question I'm looking for is how would one process the data
based on the respective question_id's?
Sending it to another page would require an excessive amount of _POST
variables, and like i said before, there are different questions for
each survey.

or would this work? (it doesn't seem to process)
if($submit){
for($i=$start; $i<=$end; $i++){
$query[$i] = "INSERT INTO answer(ansresult, ansdesc, idquestion,
idsurvey) VALUES('q_$i','exp_$i','$idquestion','$surveyType' )";
$result[$i]= mysql_query($query[$i]);
if($result[$i]){$success++;}
}

$msg = sprintf("Success: %d, Questions: %d",$success,$end-$start);
echo($msg);
}

Double Quotes In Text Input
I accept text, add_slashes, and store it in my MySQL DB. When I display
the text, I normally strip_slashes and also strip_tags. This all works
excepts for a field with double quotes. e.g.

"My Book's Title" is very simple

When I display this field, it is totally blank. What's the solution?

Wiki Style Text Input
I have a text file called test.txt which is I am trying to get to load
into a webpage. This is simple enough, but I am trying to make it so
that it recognises certain formatting, similar to how wikipedia pages
work.

so, my text file contains ONLY the following:

This is /just/ some test text *to see* if the PHP works
and to /*evaluate*/ what it actually does

The intention is that /just/ will show as italic, *to see* will show as
bold and /*evaluate*/ will show as bold italic.

Creating the text inside the page works fine.

<?php
$s = 'hello. /this/ works *bolding* works. /*Both work*/!'
$search = array ( '@/(.*?)/@si',
'@*(.*?)*@si');
$replace = array ( '<i>1</i>',
'<b>1</b>');
echo preg_replace($search, $replace, $s);
?>

However when I try and read from a text file using

$s = file('./wiki.txt');
$search = array ( '@/(.*?)/@si',
'@*(.*?)*@si');
$replace = array ( '<i>1</i>',
'<b>1</b>');
echo preg_replace($search, $replace, $s);
?>

All that is shown is the single word 'Array'. This confuses me a lot as

<?
$s = file('./test.txt');
print_r($s);
?>

shows that the text is being read into the page
Array ( [0] => This is /just/ some test text *to see* if the PHP works
[1] => and to /*evaluate*/ what it actually does )

How Can I Insert A Deafult Value In An Input Text Box?
for example if I have a box where you should put a date how do I keep
today date inside that box as default?

Simple Looped Text Input
I'm trying to build a website with a simple text input option. After the input, the input is checked and acted upon accordingly. This is followed by a new input line.

For example:
> input: test

"test" is not known to me

> input: _

So far, I've been trying things with the "do-while" loop (see code below), but so far, all I seem to get is a fixed input box and the "respons" being displayed below it. Code:

Returning Text Input Type As Array
I'd like to make all the text inputs in this form to be part of an array. The reasoning is that the form is built dynamically so there are times when there are 4 inputs while other times it's 12. When the form is submitted I need those inputs to be error checked and such.

Updating Text File With Textarea Input
i am creating an admin page for a person to update a page of their website through a web browser. the problem that i am having is the formatting of the inputted data into the textarea box. when it is displayed, all the returns and breaks are removed and the data is all in one line. i have been experimenting with nl2br() but i am not sure where to put it.

Text Input Of Date And Timestamp Fields
I'm working on a PHP frontend for a PostgreSQL db and I'm looking for the
best way to create date or timestamp inputs. Let's take a date in the
format yyyy-mm-dd as an example. This is too error prone, I know my users
will do it wrong

<input type="text" name="fieldname">

Right now I'm thinking about something like this:

<input type="text" size="4" name="y_fieldname">-
<input type="text" size="2" name="m_fieldname">-
<input type="text" size="2" name="d_fieldname">

but this is IMO a very ugly solution, because after the SUBMIT I have to
glue all the parts together before inserting the values into the db.
Something like this:

<input type="text" format="yyyy-mm-dd" name="fieldname">

Displaying Text Fields On User Input
How would I echo a particular amount of text fields depending on how many the user selects from a drop down menu that I have already created. For example say the user selects 4 or whatever other number from a drop down menu how would I echo 4 or whatever the amount of text fields for a user to input text into? An example would be an airline website were you select how many people are travelling and then it echo fields for those people to enter their names.

Tag In Smarty Which Enables Us To Get The Input Type=text
Is there any tag in Smarty which enables us to get the input type=text alongwith the value filled from a variable?

i.e. a tag such as html_text such that I get input type=text alongwith value?

Text Input Box Automatically Escapes Quotation Mark
Text Input Box Automatically Escapes Quotation Mark

The text input box below works fine with text. However, when a single or double quotation mark (i.e. ' or ") is entered the code below outputs an escape mark. For example, if the word DevShed is entered into the text box then executed the code simply outputs the word DevShed. But if the word DevShed is put in quotation marks, like so "DevShed", and executed the code outputs the following: "DevShed".

My question is this: How can I keep the PHP code from automatically escaping quotation marks when the form text input box is executed?

Clearing The Input Text Field After Submiting The Form To A New Page
I have a page with a form with an input text field ... and when a user types his/hers ID ... and submits the form - his/hers page opens in a NEW window .... but the value (ID) that was written in the original window remains.

I want to make sure that the form input field on the original page becomes "invisible" - by refreshing/reloading the original page or just by clearing the input form after submission.

For now I have put in a meta refresh tag in the head of the html file ... but that is not the solution ... becouse I only need a one time refresh/reload of the page ... and this is to happen right after the input text value is being submitted.

Detecting URL's And Html Tags In Text, Input From Form
Is it possible to check text and set a PHP variable if someone inputs links, <h1></h1> ect. and other html tags when filling out your form mail or guestbooks?

Php Template For Multiple Text Files
I have over 800 text files. I need one php template webpage that can pull in text of requested file on request in url. Example:

http://www.gothinia.com/chronicle/epos.php3?title=Title_Of_Text_File_With_Story.txt

would place text of Title_Of_Text_File_With_Story.txt inside template called epos.php3
what code will do this in a simple effiencient manner?

Editing Multiple Text Elements
I'd like to edit multiple rows with one click by the user. Basically I'd print out <input type=text name=fieldname value=$value> for each record in the table. When the user clicks submit PHP will then loop through each row updating where necessary.

Breaking Up Text For Multiple Pages
I was recently put in charge of heading up my company's website, and
while I have a lot of experience on the design side of things, I'm
still very new to the programming side. When I started, the website had
just gotten a revision, but the site was an utter mess, so I've been
trying to fix it up. As I've gone along, I've learned some aspects of
PHP, but my knowledge is still very limited.

Here is the problem I'm trying to fix. A backend is used to enter
information into our MySQL database, and then a page template pulls it
out to make the page. For our reviews, the PHP coding currently breaks
up the review's text so that it can be places across multiple pages.
The problem is, the way the text breaking was set up, the end of one
page and the beginning of the next are totally chaotic, with breaks
often coming mid-sentence.

Here is what I'd love: other coding automatically puts an HTML break at
the end of paragraphs, and then another in the space between one
paragraph and the next. I'd love to have the code search for when those
double breaks come up, and then break up the text after, say, every
sixth pair of HTML breaks. I'd also like the option to break the text
myself by putting in some sort of text code in the original text. At
this point, though, anything that can make the breaks more elegant
would be a huge improvement.

I really appreciate any help anybody can give me in this one. Please
remember that I know very little of PHP, and I'm not much of a
programmer anyhow, so things that you may take for granted that people
would understand about PHP, I might not know.

I tried to pull out what I thought was the current coding for the text
break. Here it is. I'd also like to get rid of the part1/part2 factor.
Before, they had the text breaking to help in fitting into the layout
around an image, but I've fixed that so I no longer need the break. So,
that portion no longer needs to be a factor.

if ($page == ""){
$page = 1;
}
$no_letters = strlen($Game_Full_Story);
$times = ($no_letters / 3800) +1;
$Game_Full_Story = wordwrap($Game_Full_Story,3800,"*#^");
$Game_Full_Story = explode ("*#^", $Game_Full_Story);
$pages = array();
for ($i=0; $i<$times ; $i++){
$part[$i] = $Game_Full_Story[$i];
if ($i != 0){
array_push($pages, $i);
}
}
$page = $page-1;
$story = $part[$page];
if (strlen($story) < 460){
$parts1 = $story;
}else{
$story = wordwrap($story,460,"*#^");
$story = explode ("*#^", $story);
$parts1 = $story[0];
$count = count($story);
$parts2="";
for ($i=1; $i<$count; $i++){
$parts2 .=$story[$i];
$parts2 .=" ";
}
}

Text Field Eats Up Multiple Words!!??
I pass a variable in my url which is let's say two words separated by a space.
now if i just echo($variable) then i get both the words as they are.. separated by a space... but on the other hand if i put that same variable inside a text field.. i.e <input type=text name=bla value=$variable> i get only the first word of the variable

e.g.
$variable = "hello there";

displayed normaly i get:
hello there

displayed inside a text field i get:
hello

i tried using different things like urldecode/urlencode/rawurl blabla/ the best i could get to display was a hello+there
so is there any solution to displaying $variable as it is inside a text field.. by the way it displayed fine if i use a textarea but i need to use a normal text type input.

Populate MySQL With Multiple Text Box Entries
I have about 300 rows of mysql data which I have chosen to diplay with a text box at the end of each row, that is available for adding comments. I would like to be able to add comments to entries and then have an update scripte that would take the text box, named "MC" and place the data in its row identified by a hidden field which would corrrespond to the Primary Key of the MySQL Database. I've done something similar using check box arrays, ie. Checkbox name="MC[]"

My question is whether I can write a script that would test for a value in the corresponding text box, and update the MySQL data accordingly. I have also provided in my display script that if the MC column is already populated in MySQL it will not display in the form.

Help On A Multiple Keyword Search On A TEXT Field Type
Working on a php/mysql driven site which requires me to have a search facility based on multiple keywords. I read the tutorial "quick and dirty search engine". What i want to know is :

1. Is there any SQL query i could perform which could to almost the same thing ( i dont really need the accuracy ) ?

2. Any other methods of achieving it?

Display Results From Text File In Multiple Pages
i use a string, eg "&&&" to mark pages in a text file. i use $count to count the above string. how can i display the contents of this file in multiple pages (by identifying the above string or any other method)?

Multiple Checkbox Query Using Text As Values Not Numbers
I've been looking to create a query based on multiple checkbox results (select results from multiple cities) and the only examples I've found so far use numbers as the values like the one below; Code:

Display Results From Text File In Multiple Pages
i use a string, eg "&&&" to mark pages in a text file. i use $count to count the above string. how can i display the contents of this file in multiple pages (by identifying the above string or any other method)?

$_POST Behavior From Input=submit Vs Input-type=button
I have been trying to solve an annoying behavior with PHP (I think).
Maybe some of you have encountered the same and have some ideas.

I have an html form and I use an <input type="button"> element with
the onClick event that calls a javascript funtion. Once the script's
content has been processed, I execute the form.submit() directive.

I would like to combine the html form and the PHP script into one, and
use action="<?php echo($PHP_SELF) ?>".

When the html form has <input type="button" name="theButton"
value="thisisthetrigger" onclick="doThis(this.form)">but PHP cannot
'read' the value of $_POST["theButton"] after form.submit().

If I substitute the <input type="button"> for <input type="submit">
then PHP reads the value just fine. Some may argue to just use the
latter option, but that will cost me a trip back to the server to
basically do a lot of validation that can be very easily accomplished
on the client side.

Array Query - For Adding Alt Text To Multiple Image Upload Form
I've set up a form for uploading multiple images and I am writing the urls to a database, which is queried and outputs the images on a web page. This works fine, however, I also want to add alt/title text for each image upload but can't quite seem to get it working. I'm pretty new to PHP so my knowledge of how to use arrays is fairly limited. Code:

Multiple File Upload From Client Pc To Server Without Using <input Type="file"> Cont
I am working on a application which requires me to upload the contents of all the files from a particular folder in clent pc to the server.

In my code i just want to mention the folder name which may contain any number of files.Folder name will always be fixed.
I dont want to use <input type=file > control.

Is there any way i can achieve this using FTP or any other way in PHP.Any help will be greatly appreciated.

Print Function Won't Print?
I have been using echo in PHP but I saw most examples use the print function so I tried it, but It wouldn't display anything on the page, I am trying this on a localhost. I used echo instead and it works...so I was just wondering what is it that I haven't setup that the print function isn't working.

This was the code i using:

session_start();
print($counter);
$counter++;
session_register("counter");


Copyright © 2005-08 www.BigResource.com, All rights reserved