Simple Question, from database into a table
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
It makes sense, though it seems somewhat insecure to use eval() on data coming from the database mixed with input coming from the script.
What you want to do is grab all of your data that belongs in your var ($myvar for example) up front by appending the var with the data.
In this example, the $delim is not the important thing. What is important is the dot operator ('.') that is used before the equal sign ('='). What this does is append the string you are assigning to the end of what is already in the variable. This essentially lets you grow the string until you are ready to output it.
What you want to do is grab all of your data that belongs in your var ($myvar for example) up front by appending the var with the data.
Code: Select all
<?php
$myvar = '';
for ($i = 0; $i < 30; $i++)
{
$delim = ($i == 29) ? '' : ' grows into ';
$myvar .= $i . $delim;
}
echo $myvar;
?>