473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Echo in Echo

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
Nov 13 '08 #1
3 1628
ZT**********@gmail.com wrote:
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
Nov 13 '08 #2
On Nov 13, 12:41*pm, "ZT.Ph34rl...@gmail.com" <ZT.Ph34rl...@gmail.com>
wrote:
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
Nov 13 '08 #3
ph34rl3ss escribió:
On Nov 13, 12:41 pm, "ZT.Ph34rl...@gmail.com" <ZT.Ph34rl...@gmail.com>
wrote:
>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
--
Nov 13 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
Right now, over at www.monkeyclaus.org, the following script is getting to the 9th run through and dying after the line: echo "..."; You'll admit that is a strange place to die. I've hit...
3
by: Michael Flanagan | last post by:
Of course "echo" is working, but I've got a case where php doesn't seem to be sending out the result of an "echo." I'm probably doing something wrong, but I can't see it. I've got the following...
6
by: Marco | last post by:
I have a couple pages that have tables, whats best use echo to produce the full table with the variables or is it best to just make the table in plain html and use <?php echo ('$va'l); ?> when i...
9
by: Domestos | last post by:
Here an unusual one... Say i am writing a few lines of code in php script as so... <?php echo '<table>'; echo '<tr>'; echo '<td> blah blah </td>'; echo '</tr>'; echo '</table>';
9
by: windandwaves | last post by:
Hi Folk My question is: echo all the time vs echo at the end - what is faster Let me explain I used to write pages like this: echo "<head> ";
25
by: Jon Slaughter | last post by:
I have some code that loads up some php/html files and does a few things to them and ultimately returns an html file with some php code in it. I then pass that file onto the user by using echo. Of...
4
by: rawky1976 | last post by:
Hi, I have a hyperlink which goes to the page below and passes the PK_ID from a query into 'userid'. From this we query the DB and then echo a table with a form; only the textboxes are already...
1
by: sheel331 | last post by:
Hello, I am new to coding in PHP, and had a question about a simple thing: I am trying to echo out the elements of an array for a sidenav in one of my HTML pages, and I can't seem to figure out...
11
by: Twayne | last post by:
Hi, Irrelevant question time, probably: Is there any advantage/reason to use one format over the other for the following two types of echo statements? 1. echo "error is " . $error; 2. ...
32
by: Request-1 | last post by:
hi folks, html coder here, new and terrified * of php!! aaaaaa! i'm trying to bury a JS script to rotate a photo, in a page i converted from html to php. the conversion went well, it was to...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.