<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0'>
	<channel>
		<title>cotonti.com : Help with outputting select statement results!</title>
		<link>https://www.cotonti.com</link>
		<description>Last topic posts</description>
		<generator>Cotonti</generator>
		<language>en</language>
		<pubDate>Sun, 03 May 2026 14:34:13 -0000</pubDate>

		<item>
			<title>Hodges</title>
			<description><![CDATA[<p>Thank you! I knew it had to be a simple mistake.</p>
]]></description>
			<pubDate>Sun, 26 Jan 2014 15:18:07 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/forums?m=posts&q=7671&d=0#post39088]]></link>
		</item>
		<item>
			<title>Twiebie</title>
			<description><![CDATA[<p>On line 2 you've put the first row in $row and then you started looping through the result.</p>

<p>Use fetchAll() like so:</p>

<pre class="brush:php;">
$sql = $db-&gt;query("SELECT * FROM cot_test ORDER BY test_title ASC");

foreach ($sql-&gt;fetchAll() as $row)
{
    echo $row['test_title'];
    echo "&lt;br&gt;";
}
</pre>

<p> </p>
]]></description>
			<pubDate>Sun, 26 Jan 2014 15:08:56 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/forums?m=posts&q=7671&d=0#post39087]]></link>
		</item>
		<item>
			<title>Hodges</title>
			<description><![CDATA[<p>Hi there,</p>

<p>I'm working on a plugin and I've run into something bizarre I can't figure out.</p>

<p>I've got the following exmaple DB table:</p>

<pre class="brush:sql;">
CREATE TABLE IF NOT EXISTS `cot_test` (
  `test_id` int(10) NOT NULL auto_increment,
  `test_title` varchar(255) character set latin1 NOT NULL,
  PRIMARY KEY  (`test_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ;

INSERT INTO `cot_test` (`test_id`, `test_title`) VALUES
(1, 'one'),
(2, 'two'),
(3, 'three'),
(4, 'four'),
(5, 'five');</pre>

<p>And I've got this simple script to output the column 'test_title' in ascending order.</p>

<pre class="brush:php;">
$sql = $db-&gt;query("SELECT * FROM cot_test ORDER BY test_title ASC");
$row = $sql-&gt;fetch();
foreach($sql as $row)
	{
	$numberselect .= $row['test_title']."&lt;br /&gt;";
	}</pre>

<p>If I run the above SQL statement in phpMyAdmin I get:</p>

<blockquote>
<p>five<br />
four<br />
one<br /><span style="line-height:1.6em;">three</span><br /><span style="line-height:1.6em;">two</span></p>
</blockquote>

<p>If I run the script as part of my plugin I get:</p>

<blockquote>
<p><span style="font-family:Georgia, Times, 'Times New Roman', serif;font-style:italic;">four</span><br style="font-family:Georgia, Times, 'Times New Roman', serif;font-style:italic;" /><span style="font-family:Georgia, Times, 'Times New Roman', serif;font-style:italic;">one</span><br style="font-family:Georgia, Times, 'Times New Roman', serif;font-style:italic;" /><span style="font-family:Georgia, Times, 'Times New Roman', serif;font-style:italic;line-height:1.6em;">three</span><br /><span style="font-family:Georgia, Times, 'Times New Roman', serif;font-style:italic;line-height:1.6em;">two</span></p>
</blockquote>

<p>The first row is always missing!! What silly mistake am I making?</p>
]]></description>
			<pubDate>Sun, 26 Jan 2014 14:38:17 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/forums?m=posts&q=7671&d=0#post39086]]></link>
		</item>
	</channel>
</rss>