I have a database where I use the while() command to iterate through each
row and their resultant arrays to populate a table as the while() command
is executed.
I would like to have in the database a "pointer" that says something like
$MyString, but in the PHP $MyString is given a URL of an image. So every
time during the while() command it comes across the text $MyString it
instead substitutes it for the URL instead of echoing $MyString.
I have tried putting the URL of the image in a few fields directly into the
database, whilst this method does work, it is not the solution I want as
the database fields would start becoming large to cope with the URL instead
of a short VARCHAR declaration.
Does anyone have an idea how to get the text to be substituted while the
while() command is going through an array? The array cannot be "messed"
around with, it has to stay in the order it is being read out of for
display into a table.
My current code looks like:
$Yes = '<img src="tick.png"> ';
while ($row = @mysql_fetch_ar ray($result))
{
$FName = $row['FeatureName'];
$AccountType1 = $row['Coll-1'];
$AccountType2 = $row['Coll-2'];
$AccountType3 = $row['Coll-3'];
$AccountType4 = $row['Coll-4'];
$entry .= "<tr class=\"BottomL ine\"><td
style=\"text-align:left;\">< B>$FName</B></td><td>$Account Type1</td>
etc.etc.
}
Thanks
Dariusz 6 1672
"Dariusz" <ng@lycaus.plus YOURSHIT.com> wrote in message
news:41******** *************** @ptn-nntp-reader01.plus.n et... I have a database where I use the while() command to iterate through each row and their resultant arrays to populate a table as the while() command is executed.
I would like to have in the database a "pointer" that says something like $MyString, but in the PHP $MyString is given a URL of an image. So every time during the while() command it comes across the text $MyString it instead substitutes it for the URL instead of echoing $MyString.
I had a hard time following this and still don't know what it means.
I have tried putting the URL of the image in a few fields directly into
the database, whilst this method does work, it is not the solution I want as the database fields would start becoming large to cope with the URL
instead of a short VARCHAR declaration.
This makes no sense to me. What are you trying to store where?
Does anyone have an idea how to get the text to be substituted while the while() command is going through an array? The array cannot be "messed" around with, it has to stay in the order it is being read out of for display into a table.
The text from where?
My current code looks like:
$Yes = '<img src="tick.png"> ';
This is the only reference I see to an IMG tag.
while ($row = @mysql_fetch_ar ray($result)) { $FName = $row['FeatureName']; $AccountType1 = $row['Coll-1']; $AccountType2 = $row['Coll-2']; $AccountType3 = $row['Coll-3']; $AccountType4 = $row['Coll-4'];
Which of these fields is giving you trouble? What's in them?
$entry .= "<tr class=\"BottomL ine\"><td style=\"text-align:left;\">< B>$FName</B></td><td>$Account Type1</td> etc.etc. }
I didn't see $MyString anywhere in that example. Nor did I see an example of
the expected input and output.
Try again with a clearer example. Short, complete. I, for one, have no idea
what you tried to ask.
- Virgil
*** Dariusz escribió/wrote (Tue, 14 Sep 2004 15:43:16 GMT): I would like to have in the database a "pointer" that says something like $MyString, but in the PHP $MyString is given a URL of an image. So every time during the while() command it comes across the text $MyString it instead substitutes it for the URL instead of echoing $MyString.
Do you mean str_replace() ??
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Las dudas informáticas recibidas por correo irán directas a la papelera
-+ I'm not a free help desk, please don't e-mail me your questions
--
In article <L1************ ****@newssvr22. news.prodigy.co m>, "Virgil Green" <vj*@DESPAMobsy dian.com> wrote:
Okay, I'll try re-writing the text.
Basically, if I have in the database "$MyString" entered as text, when the
while() loop is processing the array to make a HTML table, every time it
comes across "$MyString" text from ANY part of ANY array, it should write
the contents of the $MyString variable already declared instead of just
writing the text "$MyString" into the table which the loop constructs as it
reads the database. The way the table is constructed can't be changed.
So when the PHP is processed, the HTML should read:
<td><img src="yes.png"></td>
<td>sometext</td>
<td>moretext</td>
<td><img src="yes.png"></td>
and not
<td>$MyString </td>
<td>sometext</td>
<td>moretext</td>
<td>$MyString </td>
Hope that is a bit clearer.
Dariusz
> So when the PHP is processed, the HTML should read: <td><img src="yes.png"></td> <td>sometext</td> <td>moretext</td> <td><img src="yes.png"></td>
and not
<td>$MyString </td> <td>sometext</td> <td>moretext</td> <td>$MyString </td>
echo or print or whatever command you use with double quotes"text" instead
of single quotes 'text'.
$name="Dariusz" ;
echo 'Hi, my name is $name';
results in: Hi, my name is $name
but
echo "Hi, my name is $name";
results in Hi, my name is Dariusz
Polaris.
In article <41************ **********@drea der2.news.tisca li.nl>, "Polaris" <as*********@ho tmail.com> wrote: echo or print or whatever command you use with double quotes"text" instead of single quotes 'text'.
I have already thought of this problem, but it was not it.
However, I have since done a LOT of digging and found a partial solution
which if solved would be ideal.
Current code:
while ($row = @mysql_fetch_ar ray($result))
{
$FName = $row['FeatureName'];
if (in_array("Yes" , $row))
{
$row = '<img src="tick.png" width="38" height="18">';
}
$AccountType1 = $row['Coll-1'];
$AccountType2 = $row['Coll-2'];
$AccountType3 = $row['Coll-3'];
$AccountType4 = $row['Coll-4'];
$display_entry .= "<tr class=\"BottomL ine\">
<tdstyle=\"te xt-align:left;\">< B>$FName</B></td>
<td>$AccountTyp e1</td>
<td>$AccountTyp e2</td>
<td>$AccountTyp e3</td>
etc...
So now as the array is being read, every time the word "Yes" is
encountered, it is replaced in Coll-1, Coll-2, Coll-3, Coll-4. The problem
is though that is is not 100% working. Instead of replacing the entire
string (which in this case is a URL for an image), it is just echoing "<"
(minus quotes). Playing about I find that it is only echoing the first
character of the string.
So I have a table that had a lot of Yes's replaced by < instead of the url
which would show that graphic.
Any suggestions?
Dariusz
"Dariusz" <ng@lycaus.plus YOURSHIT.com> wrote in message
news:41******** *************** @ptn-nntp-reader02.plus.n et... In article <L1************ ****@newssvr22. news.prodigy.co m>, "Virgil Green"
<vj*@DESPAMobsy dian.com> wrote: Okay, I'll try re-writing the text.
Basically, if I have in the database "$MyString" entered as text, when the while() loop is processing the array to make a HTML table, every time it comes across "$MyString" text from ANY part of ANY array, it should write the contents of the $MyString variable already declared instead of just writing the text "$MyString" into the table which the loop constructs as
it reads the database. The way the table is constructed can't be changed.
So when the PHP is processed, the HTML should read:
<td><img src="yes.png"></td> <td>sometext</td> <td>moretext</td> <td><img src="yes.png"></td>
and not
<td>$MyString </td> <td>sometext</td> <td>moretext</td> <td>$MyString </td>
Hope that is a bit clearer.
Just barely. Where did the text '<img src="yes.php">' come from? Is the
variable name you want to use always $MyString? Is that the only variable?
Are you trying to use any "variable" placed inside the data in your
database? Where does $MyString get populated?
That said, I suspect you want to use a regular expression to find any string
in your data that starts with $ up to the next space. That can then be
extracted into a variable. You can then use $$ syntax to reference a field
of the same name. That can be used to so a str_replace into the original
data.
$myfield = (some regular expression extraction I don't want to look up right
now);
$mydata = $$myfield;
$newdata = str_replace($my field, $mydata, $dbfdata);
echo $newdata;
Just a thought and a guess. No testing has even been attempted.
- Virgil This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Damien Renwick |
last post by:
I have a php script which simply stops midway through a while loop
that processes records returned by a MySQL query. The HTML page
continues trying to load the page but the php has stopped running and
eventually I get a timeout. The script is running in my development
environment which consists of php 4.3.4, Apache 1.3.28 and MySQL
4.0.17, installed on Windows XP with Service Pack 2.
I suspect that there may be a problem with my...
|
by: Christian.Gruber |
last post by:
>Description:
It would be nice if general query logging could be switched on and off
while the MySQL server is running, and not only at startup time.
While debugging an application that uses foreign database access
libraries, this would be very helpful. One could switch on logging,
perform an activity, switch off logging, and look what has happened.
Otherwise, the server has to be restarted to change logging, which
is a bit annoying......
|
by: Moritz Steiner |
last post by:
Ok, but this only works for the current session, if I close and restart =
the client the settings are reset...
-----Urspr=FCngliche Nachricht-----
Von: Victoria Reznichenko =20
Gesendet: Mittwoch, 16. Juli 2003 11:19
An: mysql@lists.mysql.com
Betreff: Re: switch query logging while the server is running
|
by: Sagar, Sanjeev |
last post by:
------_=_NextPart_000_01C34BD8.C9973A3A
Content-Type: text/plain
Hello All,
I am using Mysql 4.0.13-max-log on Solaris 2.8
If I run mysqldump like below
/usr/local/mysql/bin/mysqldump -u root -pabc -d -r
|
by: Brian Reichert |
last post by:
On another mailing list, there is a discussion about whether or not
it is adequate/proper to manage the MySQL server process via a
watchdog script (namely, DJB's daemontools).
The point behind this watchdog script is to launch a service (such
as mysqld) in the foreground, and notice if that process exits. An
auxilary tool will send this managed process a SIGTERM, to request
shutdown.
It has been working for me under FreeBSD, and the...
| |
by: James E Koehler |
last post by:
I can't get the WHILE statement to work in MySQL.
The version of MySQL that I am using is:
Ver 12.16 Distrib 4.0.6-gamma, for Win95/Win98 (i32)
running on Windows MX.
Here is the relevant section from the manual:
20.1.9.7 WHILE Statement
|
by: Haffi |
last post by:
hi,
I have a proplem creating a new user and/or adding additional
information for root user in MySQL Administrator 1.0.19. When I do I
get this message: error while storing the user information.
Never the less, when I close the Admin program and open it again, the
changes I tryed to make are saved, (althoug the program asked me if I
wanted to save changes and I said no)
|
by: Trygve Lorentzen |
last post by:
Hi,
my webservice is running on Win2000 SP4, IIS 5.0 fully patched, connecting
to a MySQL database and mainly returning Typed DataSet's from webmethods.
After running for a while, generally a few days, the webservice stops
responding and the .NET windows app client fails with no informative error
message. When I try to run any webmethod from the webservice locally in the
browser I first get a "This page cannot be display IE error...
|
by: gooderthanyou |
last post by:
Alright i've looked a ton of topics and most of them are unresolved...
configure: error: Cannot find MySQL header files under usr/local/mysql.
Note that the MySQL client library is not bundled anymore!
I gunzipped mysql, did tar -xvf to the resulting tar, moved the mysql
folder to usr/local/... and I been able to log into mysql and all that
good stuff so I guess its installed. just when I try to configure php
with mysql it gives me...
|
by: hikinchi |
last post by:
i have problem to connect vb and mysql...
1) i want to build program to compare data from text file and from mysql. I don't know how to use command from vb to through into mysql..
anyone can help me...
2) my data output always duplicate. I think my command do while have a problem...
this is my script...
Private Sub cmdBaca_Click()
|
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,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |