Sorry folks, I’m really new to this and struggling.
I’m using MODX evolution and mySQL.
Here’s what I am trying to do:
1) Create a chunk with 2 colunm table where the rows will be created dynamically by the results of a simple mysql result.
2) Create a snippet that will do the mysql call and return the resultant rows.
I have a snippet that works just fine as long as I format the output of the sql query and hard code the table in the php. I DON’T WANT HTML IN PHP CODE! Here is the functioning snippet, and what I am trying to avoid doing.
$sql = "SELECT * FROM " . $tbl;
mysql_real_escape_string($sql);
$result=mysql_query($sql);
if (!$result)
{
$message = ’Invalid query: ’ . mysql_error() . "\n";
$message .= ’Whole query: ’ . $query;
die($message);
}
echo ’<table id="tb1" border=0 cellspacing=3 cellpadding=1 width=50% BGCOLOR="#FF9933" CELLSPACING=3 CELLPADDING=1>’;
while ($row = mysql_fetch_assoc($result))
{
echo "<tr>";
echo "<td width=50%>";
echo "<b>" . $row[’name’] . "</b>
";
echo $row[’description’] . "</br>";
echo "<p></p>";
echo "</td>";
echo "<td width=10% align=right>";
echo "<b>" . $row[’price’] . "</b>";
echo "</td>";
}
echo ’</table>’;
I’m really stuck on this.
I could really use the help on this!
Thanks
Robert
You sir, are a gentleman and a scholar!
Exactly what I was looking for. Now things are in perspective!
THANK YOU!