|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||||||
|
||||||||
|
TRIM SPACES WHEN DISPLAYED
Hello,
I get 4 fields from 2 different tables when I treat each line and fill a <select><option> tag, spaces are trimmed out unaligning the output. I tried str_pad() and substr(), have managed to use Monospace fonts for the select output, and I have also asigned the field values to a var before making it a part of the Options. I'm persuing an aligned option list: php Code:
I have requested your help with the following code, although the vars in the code don't reflect the example: php Code:
Thank you, Freddy |
|
#2
|
|||
|
|||
|
RE: TRIM SPACES WHEN DISPLAYED
Try this:
<code> <? $string = $str_replace(" ", " ", $string); ?> </code> |
|
#3
|
|||
|
|||
|
RE: TRIM SPACES WHEN DISPLAYED
The problem is that in the web page, the browser ignores white space more than a single space. To enter multiple spaces, you need to use ' '. However, if you just tried padding with this, it wouldn't work, since it sees ' ' as 5 chars not 1. Thus you will need to run an str_replace() function on the variables:
|
|
#4
|
|||
|
|||
|
RE: TRIM SPACES WHEN DISPLAYED
Sorry... That should of couse be:
Code:
<?
$string = str_replace(" ", " ", $string);
?>
|
|
#5
|
|||||
|
|||||
|
RE: TRIM SPACES WHEN DISPLAYED
The visual result I get is great; but I'm not retreiving data from the mysql SELECT statement after the str_replace function. The variable used for the SQL statement is transformed to a length of 10 that may not be the original length
php Code:
I still get a value of 10 in strlen($id). Help help. Thank you for your help, Freddy |
|
#6
|
|||
|
|||
|
RE: TRIM SPACES WHEN DISPLAYED
I'm not quite sure what you are saying the problem is? I thought what you were trying to do was to visually align the <option>s in the <select> dropdown? What are you trying to do now?
|
|
#7
|
|||
|
|||
|
RE: TRIM SPACES WHEN DISPLAYED
OK, I think I understand. You're problem is trying to get back to the initial variable. Yes? I'm just playing around now trying to get it to work...
|
|
#8
|
|||
|
|||
|
RE: TRIM SPACES WHEN DISPLAYED
|
|
#9
|
|||
|
|||
|
RE: TRIM SPACES WHEN DISPLAYED
Thank you for replying:
I had a select option that when SELECTED by the user got "explode"d to some vars and I got the selected ID code, then I used this ID to query MySQL and the existing data got retreived. The alignment in the select/option did not work, now the alignment is very good, but no data is retreived from the query. Thank you in advance. |
|
#10
|
|||
|
|||
|
RE: TRIM SPACES WHEN DISPLAYED
What was the exact command you were using to explode the string? Post it here along with an example of what it does start with and return, along with what you want it to start with and return.
|
|
#11
|
|||
|
|||
|
RE: TRIM SPACES WHEN DISPLAYED
|