abolinhas
asked on
Customize mysql values in select box
Dear Experts,
I want to customize the mysql values of my select box for this:
I already have this query
And the result are
Can you help me ?
Best regards
André Bolinhas
I want to customize the mysql values of my select box for this:
"drc='row'" - (include "" and ')
I already have this query
<option value='<?php echo '"drc='.$row['drc'].'"'?>'><?php echo '$row['dico']' ?></option>
And the result are
"drc=row" - (missing the ' in row)
Can you help me ?
Best regards
André Bolinhas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
do not understand why you have drc= in value varible
<option value=drc="'<?php echo $row['drc']; ?>"><?php echo $row['dico']; ?></option>
or
echo "<option value=drc=\"{$row['drc']}\">{$row['dico']}</option>";
Assuming this is part of a <select><option> HTML string, can you please show us a representation of what you want for the end product? The more I look at this, the less it makes sense to me. Thanks, ~Ray
ASKER
Thanks, this tip solve my problem.
The accepted solution cannot possibly solve the problem because it creates a PHP parse error. I will ask a moderator to reopen the question. A tested and working answer was posted at ID:37023971.
Copied and pasted from the accepted "solution"...
http://www.laprbass.com/RAY_temp_abolinhas.php
Outputs:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING , expecting ',' or ';' in /home/websitet/public_html /RAY_temp_ abolinhas. php on line 5
It is always a good idea to test the solutions posted by the experts here at EE. I test my code before I post it, but as you can see here not everyone takes the time and effort to prepare a test. And unfortunately you do not have any way of knowing whether the proposed solutions are any good unless you test them yourself. Caveat Emptor.
Best of luck with your project, ~Ray
http://www.laprbass.com/RAY_temp_abolinhas.php
Outputs:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
It is always a good idea to test the solutions posted by the experts here at EE. I test my code before I post it, but as you can see here not everyone takes the time and effort to prepare a test. And unfortunately you do not have any way of knowing whether the proposed solutions are any good unless you test them yourself. Caveat Emptor.
Best of luck with your project, ~Ray
<?php // RAY_temp_abolinhas.php
// DROP INTO HTML AND TEST THE ACCEPTED SOLUTION
?>
<option value='<?php echo '"drc=/''.$row['drc'].'/'"'?>'><?php echo '$row['dico']' ?></option>
Correct answers are posted at http:#37023957 and http:#37023971
Escape the single quote you want to add with /.
Not 100% sure of the syntax you'll need but it would be something like this.
<option value='<?php echo '"drc=/''.$row['drc'].'/'"'?>'><?php echo '$row['dico']' ?></option>
I've tried to highlight what i added in bold but not sure if it's clear.
You could also try using chr(39).
Finally you could use CHAR and CONCAT in the MySQl query to return the value plus quotes instead of just the value:
CONCAT(CHAR(39), drc, CHAR(39))
If any of those work I'd probably go for the last one.