Oh, I get it. I have been very poor at explaining my problem.
I have a table, table1, in which I have standard text for letters. I
would like to put data from table2 in the letters, so that the data
is automatically placed in the letter through code in the standard
text. It sounds complicated, I know, but I hope I make myself clear.
English is not my native language.
What happens is, that the $show_var IS displayed. What I in my
frustration haven't conveyed properly is, that the text in table1 in
the the form
ordinary text to output to html ".
$var_from_the_result_query_on_table2." some more html text
shows up just like that, no data from table2 is processed. I know
that I am probably using the wrong function, but I can't seem to find
one.
And the reason I use SELECT * is that there is more than one field I
need to output. There is only one in the example so that the post
wouldn't be to voluminous.
Niels Riis Kristensen
(nrk@xxxxxxxxxxxxxx)
NRK Group
- Electronic Music Engraving
- Webhosting
- Dynamic Web design
- E-Lists hosting
On 31/05/2005, at 22.53, replies-lists-php@xxxxxxxxxxxxxxxxxxxxx wrote:
which are you saying doesn't work?
- outputting the value of "$show_var" in the html that follows
or
- outputting values from this query:
mysql_query("SELECT * FROM table2 WHERE kind LIKE '20'")
from what i can tell, you never actually retrieve values from this
second query.
if the issue is displaying "$show_var", you should put a debug in
between these two points, e.g.:
{
$show_var = $record['text'];
}
$debug = 4;
if ($debug > 3) {
print "show_var: $show_var<P>\n";
}
$result = mysql_query("SELECT * FROM table2 WHERE kind LIKE '20'");
so that you actually know that your first data query/retrieval has
worked.
separately, why are you doing a "select * " when, in the first case
at least, you seem to only want the value from the field "text". if
you only want values from specific fields you should enumerate them
on the select as a "select * " is very inefficient. also, using the
"like" operator, when you really should be using the "=" operator
isn't efficient either.
------------ Original Message ------------
Date: Tuesday, May 31, 2005 09:18:42 PM +0200
From: Niels Riis Kristensen <nrk@xxxxxxxxxxxxxx>
To: php-general@xxxxxxxxxxxxx
Cc:
Subject: Variables in stored txt
Hi. I have a problem that consist of a desire to use preformatted
text in a while-loop while inserting data from another search. The
code is as follows:
________________
$get_var1 = mysql_query("SELECT * FROM table1 WHERE id LIKE '1'
LIMIT 1");
while($record=mysql_fetch_assoc($get_var1))
{
$show_var = $record['text'];
}
$result = mysql_query("SELECT * FROM table2 WHERE kind LIKE '20'");
while($record=mysql_fetch_assoc($result))
{
echo " <html>
<head>
<meta http-equiv='content-type' content='text/
html;charset=iso-8859-1'>
<title>test</title>
</head>
<body bgcolor='#ffffff'>
<table width='100%' border='0' cellspacing='2'
cellpadding='0' height='50'>
<tr>
<td><img
src='../../../Media/HMLogo.gif' alt='' height='40' width='147'
border='0'></td>
<td></td>
<td></td>
</tr>
</table>
<table width='100%' border='0' cellspacing='2'
cellpadding='0'>
<tr height='526'>
<td width='100%' height='600'>
".$show_var."
</td>
</tr>
</table>
</body>
</html>";
print "
<script type='text/javascript'>
window.print();
</script>";
}
_________________
Needles to say, I hope, that it doesn't work!
Niels Riis Kristensen
(nrk@xxxxxxxxxxxxxx)
NRK Group
- Electronic Music Engraving
- Webhosting
- Dynamic Web design
- E-Lists hosting
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---------- End Original Message ----------
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php