New at programming-need help on adding code for a form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

New at programming-need help on adding code for a form

Post by Lucnet »

I am writing a script and I am useing php. Little sample below:

Code: Select all

0  $pagecontent.="<table width=750>";
1  $pagecontent.="<tr bgcolor=#CCCCCC>";
2  $pagecontent.="<td>{$link_display}</td>";
3  $pagecontent.="<td><a href='mailto:{$email}'>{$email}</a></td>";
4  $pagecontent.="<td><a href='{$company}'>{$company}</a></td>";
5  $pagecontent.="<td>{$testimonials}</td>";
6  $pagecontent.="<td>[ <a href='?id={$formdata->id&action=approve'>Approve</a> | ";
I am useing the code above to display on a page. On line 5, the amount of text thats displayed will depend totally on the client who submits the information. It may just be 10 characters or it could be 200. What I am wanting is something like a drop down. Something to where it wont change the layout of my pages table. Because the way I am useing the php is if the text is less then 20 characters my table wont change form from top to bottom, but if it is bigger then 20 characters it will widen. So if I could come up with a drop down of some sort that will allow me to put the variable of {$testimonials} from line 5. I would be set I think.

Thanks in advance.

[moderatorial=Weirdan] use

Code: Select all

[/b] tags around your code [/moderatorial] [/color]
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

You could use the [php_man]wordwrap[/php_man]() function instead of a drop-down menu (what I think would be some impracticable).
The [url=http://www.php.net/wordwrap#AEN119402]example 2[/url] of the [url=http://www.php.net/wordwrap]wordwrap() function reference[/url] wrote:Example 2. wordwrap() example

Code: Select all

<?php
$text = "A very long woooooooooooord.";
$newtext = wordwrap($text, 8, "\n", 1);

echo "$newtext\n";
?>
This example would display:

Code: Select all

A very
long
wooooooo
ooooord.
Hope it helps,
Scorphus.
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Post by Lucnet »

Thanks, I will test it tonight.
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Post by Lucnet »

That doesn't seems to work for me, because I am tring to get a string to show in that text area. Like this

Code: Select all

$text = "{$testimonials}"; $newtext = wordwrap($text, 8, "\n", 1);
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

:roll: Not quite sure about what you understand or not, but try changing from this:

Code: Select all

5  $pagecontent.="<td>{$testimonials}</td>";
to this:

Code: Select all

5  $pagecontent.="<td>" . wordwrap($testimonials, 8, "\n", 1) . "</td>";
What is your level of knowledge about programming and PHP?

Regards,
Scorphus.
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Post by Lucnet »

I have never done php from scratch. I have always modified a little bit. I really don't understand how things work in php. SO I would have to say I am very new. The way I am making this code is by useing peices of different codes and compiling them into one. Which is pretty hard when I have no idea what I am doing.
User avatar
brewmiser
Forum Commoner
Posts: 74
Joined: Mon Aug 18, 2003 12:50 pm
Location: Dallas, TEXAS

Post by brewmiser »

Just don't let it get you down. I have never programmed a thing until about a year ago. I sat down and said that I was going to learn how to build a webpage. The next thing I knew I was makeing smart web pages and learning all about databases.

PHP is great and not to hard to learn as far as most languages go. Just keep a good PHP book by your bedside, http://www.php.net at your finger tips and phpdn as a a bookmark.......

.......the rest is history. :D
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Post by Lucnet »

I get an error when I use that.

Error page:
_________


Warning: Unexpected character in input: ''' (ASCII=92) state=1 in


_____________

I think it has to do with the \n in the code you gave me.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Try this:

Code: Select all

<?php
//...
$pagecontent.="<table width=750>";
$pagecontent.="<tr bgcolor=#CCCCCC>";
$pagecontent.="<td>{$link_display}</td>";
$pagecontent.="<td><a href='mailto:{$email}'>{$email}</a></td>";
$pagecontent.="<td><a href='{$company}'>{$company}</a></td>";
$newtest=wordwrap($testimonials, 20, "\n", 1);
$pagecontent.="<td>{$newtest}</td>";
$pagecontent.="<td>[ <a href='?id={$formdata->id&action=approve'>Approve</a> | ";
//...
?>
Please post the entire error message if you get any.

Also, please post the output for the following code:

Code: Select all

<?php
echo '<pre>';
echo 'PHP Version: '.phpversion()."\n";
echo 'Display Errors: '.(ini_get('display_errors') == '1' ? 'On' : 'Off')."\n";
echo 'Error Level: '.(ini_get('error_reporting') == '2047' ? 'E_ALL' : 'Not E_ALL')."\n";
echo 'Register Globals: '.(ini_get('register_globals') == '' ? 'Off' : 'On')."\n";
echo '</pre>';

/*
PHP Version: ?.?.?
Display Errors: ?
Error Level: ?
Register Globals: ?
*/
?>
Regards,
Scorphus.
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Post by Lucnet »

When I add the code above. I don't get any error. The code doesn't display anything. It is just blank.

Code: Select all

PHP Version: 4.3.3
Display Errors: On
Error Level: Not E_ALL
Register Globals: On
If you wanna look you can see what it looks like here.
http://www.lsscripts.com/projects/testi ... in/new.php
Don't laugh, I know if pretty newbie. But hey, I am.
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Post by Lucnet »

Any other ideas?
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

I tried http://www.lsscripts.com/projects/testi ... in/new.php but http://www.lsscripts.com seems to be down.

Well, I better take a look to it, entirely. Could you please post the entire page here?

Thanks,
Scorphus.
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Post by Lucnet »

Here is another place http://lucnetsolutions.com/feedback

Go to the admin folder to see what I am talking about. Under the testimonials is what I am tring to keep from get so tall.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Well, I'm sure you know this is more a design than a PHP issue :wink:

See what I've got: http://scorphus.no-ip.com/lab/testimonials/ , think this might work for you :roll: The solution is involving only CSS.

Hope that helps. Regards,
Scorphus.
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Post by Lucnet »

I like what you did except that if a person puts in a real long testimonial the approval page will streach way of the page and you have to scroll way over. If you notice where you put the testimonial in. See how it is scrollable. That is what I am wanting. If this script was just going to be for me I wouldn't mind. I am planning for this to be my first GPL if I can get it working and looking decend.

Thanks for you help thus far. It is greatly appreciated.
Post Reply