Page 1 of 3
New at programming-need help on adding code for a form
Posted: Sat Jun 26, 2004 5:28 pm
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]
Posted: Sun Jun 27, 2004 10:05 am
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).
Hope it helps,
Scorphus.
Posted: Sun Jun 27, 2004 7:19 pm
by Lucnet
Thanks, I will test it tonight.
Posted: Tue Jun 29, 2004 7:12 pm
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);
Posted: Tue Jun 29, 2004 8:32 pm
by scorphus

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.
Posted: Tue Jun 29, 2004 8:42 pm
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.
Posted: Tue Jun 29, 2004 8:52 pm
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.

Posted: Tue Jun 29, 2004 9:27 pm
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.
Posted: Wed Jun 30, 2004 8:49 am
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.
Posted: Wed Jun 30, 2004 5:23 pm
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.
Posted: Thu Jul 01, 2004 10:19 pm
by Lucnet
Any other ideas?
Posted: Fri Jul 02, 2004 9:53 am
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.
Posted: Fri Jul 02, 2004 8:31 pm
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.
Posted: Sat Jul 03, 2004 8:27 pm
by scorphus
Well, I'm sure you know this is more a design than a PHP issue
See what I've got:
http://scorphus.no-ip.com/lab/testimonials/ , think this might work for you

The solution is involving only CSS.
Hope that helps. Regards,
Scorphus.
Posted: Sun Jul 04, 2004 5:59 am
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.