Connecting Tech Pros Worldwide Help | Site Map

Echo in Echo

  #1  
Old November 13th, 2008, 11:45 AM
ZT.Ph34rl3ss@gmail.com
Guest
 
Posts: n/a
Hi there,

First of thank you for reading.
I have the following issue.

I'm filling a select list dynamically with mysql and want the names
that are retrieved from de database to be changed by a DEFINE that
stated in other php file..
The first part works the names al get in the list but the DEFINE isn't
happening which is logic cause you have only one echo which is the
name from the database.
But putting an echo around that one doesn't work, does any of you have
a idea how to solve my issue.

Code:

<select id="objectTypeSelect" tabindex="2">
<?php
do {
?>
<option value=" <?php echo $row_getObjectTypes['id']?>"><?php echo
$row_getObjectTypes["shortname"] ?></option>
<?php
} while ($row_getObjectTypes = mysql_fetch_assoc($getObjectTypes));
$rows = mysql_num_rows($getObjectTypes);
if($rows 0) {
mysql_data_seek($getObjectTypes, 0);
$row_getObjectTypes = mysql_fetch_assoc($getObjectTypes);
}
?>
</select>


Thank you

Sincerely,

Jeroen
  #2  
Old November 13th, 2008, 12:15 PM
Robin
Guest
 
Posts: n/a

re: Echo in Echo


ZT.Ph34rl3ss@gmail.com wrote:
Quote:
Code:
>
<select id="objectTypeSelect" tabindex="2">
<?php
do {
?>
<option value=" <?php echo $row_getObjectTypes['id']?>"><?php echo
$row_getObjectTypes["shortname"] ?></option>
<?php
} while ($row_getObjectTypes = mysql_fetch_assoc($getObjectTypes));
$rows = mysql_num_rows($getObjectTypes);
if($rows 0) {
mysql_data_seek($getObjectTypes, 0);
$row_getObjectTypes = mysql_fetch_assoc($getObjectTypes);
}
?>
</select>
Shouldn't you be using a "while {...}" loop rather than a "do {...}
while" loop? You appear to be using $row_getObjectTypes in the echo
before assigning it with mysql_fetch_assoc. Unless you've already done
the mysql_fetch_assoc outside the code shown.

Also, why are you then doing a check if there are any rows in the result
afterwards? Surely, you need to check beforehand so you can prevent an
empty select input?

Robin
  #3  
Old November 13th, 2008, 12:45 PM
ph34rl3ss
Guest
 
Posts: n/a

re: Echo in Echo


On Nov 13, 12:41*pm, "ZT.Ph34rl...@gmail.com" <ZT.Ph34rl...@gmail.com>
wrote:
Quote:
Hi there,
>
First of thank you for reading.
I have the following issue.
>
I'm filling a select list dynamically with mysql and want the names
that are retrieved from de database to be changed by a DEFINE that
stated in other php file..
The first part works the names al get in the list but the DEFINE isn't
happening which is logic cause you have only one echo which is the
name from the database.
But putting an echo around that one doesn't work, does any of you have
a idea how to solve my issue.
>
Code:
>
* *<select id="objectTypeSelect" tabindex="2">
* <?php
do {
?>
* <option value=" <?php echo $row_getObjectTypes['id']?>"><?php echo
$row_getObjectTypes["shortname"] ?></option>
* <?php} while ($row_getObjectTypes = mysql_fetch_assoc($getObjectTypes));
>
* $rows = mysql_num_rows($getObjectTypes);
* if($rows 0) {
* * * mysql_data_seek($getObjectTypes, 0);
* * * * * $row_getObjectTypes = mysql_fetch_assoc($getObjectTypes);
* }
?>
</select>
>
Thank you
>
Sincerely,
>
Jeroen
Solved it : )

If anyone is interested in the solution the echo needed to be like
this:

<?php echo constant ($row_getObjectTypes["shortname"]) ?>

Greets,

J
  #4  
Old November 13th, 2008, 01:05 PM
=?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?=
Guest
 
Posts: n/a

re: Echo in Echo


ph34rl3ss escribió:
Quote:
On Nov 13, 12:41 pm, "ZT.Ph34rl...@gmail.com" <ZT.Ph34rl...@gmail.com>
wrote:
Quote:
>Hi there,
>>
>First of thank you for reading.
>I have the following issue.
>>
>I'm filling a select list dynamically with mysql and want the names
>that are retrieved from de database to be changed by a DEFINE that
>stated in other php file..
>The first part works the names al get in the list but the DEFINE isn't
>happening which is logic cause you have only one echo which is the
>name from the database.
>But putting an echo around that one doesn't work, does any of you have
>a idea how to solve my issue.
>>
>Code:
>>
> <select id="objectTypeSelect" tabindex="2">
> <?php
>do {
>?>
> <option value=" <?php echo $row_getObjectTypes['id']?>"><?php echo
>$row_getObjectTypes["shortname"] ?></option>
> <?php} while ($row_getObjectTypes = mysql_fetch_assoc($getObjectTypes));
>>
> $rows = mysql_num_rows($getObjectTypes);
> if($rows 0) {
> mysql_data_seek($getObjectTypes, 0);
> $row_getObjectTypes = mysql_fetch_assoc($getObjectTypes);
> }
>?>
></select>
>>
>Thank you
>>
>Sincerely,
>>
>Jeroen
>
Solved it : )
>
If anyone is interested in the solution the echo needed to be like
this:
>
<?php echo constant ($row_getObjectTypes["shortname"]) ?>
>
Greets,
>
J
From the solution, I presume the question needed to be like this:

"How can I get the value of a PHP constant from a variable that contains
its name?"

;-P



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
nesting JS in echo's Request-1 answers 32 November 11th, 2008 03:45 PM
HELP IN TURNING OFF ECHO IN SERIAL PORT IN CSHARP Nasif answers 3 September 12th, 2007 09:35 AM
Object properties in echo() JS Bangs answers 1 July 16th, 2005 11:38 PM