473,698 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

substitution in variables

I am trying to write a small function to display a recordset in
tabular form. I want to define a row only once but then display the
relevant data for each row but I got "undefined variable" when I tried
the following:

I do not necessarily want to display all fields in a recordset so my
row might look like this

$row = "<tr><td>". $rs->Fields[0]->value."</td><td>".$rs->Fields[3]->value."<td></tr>"

while (!$rs->EOF)
{
echo $row;
}
If I define the row like this then the substitution of the variables
takes place immediately and so all rows will be the same as the first.
So what I thought I'd try to do was:

$fldname1 = "rs->Fields[0]->value";
$fldname2 = "rs->Fields[3]->value";
while (!$rs->EOF)
{
$row = "<tr><td>".$$fl dname1."</td><td>".$$fldn ame2."<td></tr>"
}

but here I get an undefined variable :rs->Fields(0)->value error.

I know it looks like I could just put the $row assignment within my
loop in the top example but in fact this row statement is built up
using a more complicated function which I don't want to have to call
for every record as the basic structure will be the same, it's just
the values in the middle that change.

thanks
Phil
Jul 17 '05 #1
1 1919

"Phil Hancey" <ph*****@2bytes .co.uk> wrote in message
news:53******** *************** ***@posting.goo gle.com...
I am trying to write a small function to display a recordset in
tabular form. I want to define a row only once but then display the
relevant data for each row but I got "undefined variable" when I tried
the following:

I do not necessarily want to display all fields in a recordset so my
row might look like this

$row = "<tr><td>". $rs->Fields[0]->value."</td><td>".$rs->Fields[3]->value."<td></tr"

while (!$rs->EOF)
{
echo $row;
}


Use a function:

function PrintRow($col1, $col2) {
echo "<tr><td>$c ol1</td><td>$col2<td ></tr>";
}

while (!$rs->EOF) {
PrintRow($rs->Fields[0]->value, $rs->Fields[3]->value);
}

COM will crash your server by the way.
Jul 17 '05 #2

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

Similar topics

6
1954
by: Paddy | last post by:
Hi, I got tripped up on the way eval works with respect to modules and so wrote a test. It seems that a function carries around knowledge of the globals() present when it was defined. (The .func_globals attribute)? When evaluated using eval(...) the embedded globals can be overridden with
0
1778
by: Justin | last post by:
Hi, First off, I must apologise for cross posting. I am having difficulty creating a pdf document using perl cgi to do substitution for multiline pdf form fields. I created a pdf template/file with substitution variables. The file is then read and variables substituted using pattern matching. When I view the pdf multiline form field using acrobat, the field seems to be truncated. Upon view the properties of the multiline text field, I...
1
5151
by: Jacob Grydholt Jensen | last post by:
I am trying to learn iSQL*Plus for the 1Z0-007 exam. I am having a bit of problems with the substitution variables. My understanding was that they behave as in SQL*Plus, but my experiments beg to differ. I log on to the sample schema 'hr' and enter the following statements: -- statements begin set verify on define name = K%
0
1608
by: EJ | last post by:
Is there a way to specify a substitution variable that can be used in several places in the app.config file (like you can do in Ant/NAnt build files)? For example, if there is part of a file path that I specify in several of the appSettings key values, can I somehow specify that path once, and just insert a substitution variable of some sort (e.g., "${path}") and have it get substituted at run-time? I could just separate them into...
1
3503
by: Brian Newman | last post by:
I have a form with five rows of text boxes, displaying data. For certain reasons, I can't bind these directly to data records, so I'm using code to load the data into an object, then manually get each field value and assign it to each text box. The text boxes are named like this: txtSPctTrees1 txtSPctShrubs1 txt(etc)1 ... txtSPctTrees2 txtSPctShrubs2 txt(etc)2 ... txtSPctTrees3 ... ....
4
12074
by: Ian | last post by:
Hi, Hopefully a simple question but my brain is hurting... I want to make a regex substitution, using search and replace patterns contained in variables. What I want to do is: $f = "fred.abc"; $f =~ s/(.*)\.abc/$1.def/; print "$f\n";
7
6634
by: MtiPaulo | last post by:
I know FoxPro has excellent macro substitution but I am trying to find through MS Access. Wondering if MS Access has Macro Substitution? I will give you my basic example. In FoxPro Language Code For i = 1 to 5 strCmd = "Client" + Alltrim(Str(i)) + "=" + Alltrim(Str(i)) &strCmd && Client1 = 1 Next
2
2008
by: comp.lang.php | last post by:
I am trying to replace within the HTML string $html the following: With Where I'm replacing "action=move_image" with "action=<?= $_REQUEST ?>"
3
5612
by: Skip | last post by:
OK, I'm a novice in JS but have lots of coding experience. I am trying to accomplish something that would seem somewhat simple - BUT IT'S NOT. I have a basic window that calls another window with window.open and passes in 1 value using a querystring i.e., www.myhome.com/mypage?video=BAK-Extension Now when the window opens, I can capture the passed value in a JS function. But if I want to use that in the body of the HTML in a
0
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9028
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7728
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.