By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,384 Members | 671 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

Layout of mySQl query

P: n/a
hi there,

I have set up a mySQL DB, and i want to create
a sort of a search engine for it. So users can
search for something in the DB, and the result can
be 16 items, but could also be 91, or any other number.
It all depends on the search term.

What i want is to divide the search result over 2 collumns.
Ordered from left to right, top to bottom.
A result should look like this:

Aa Ab
Ah Ba
Bb Cd
Dr De
etc etc

the result should be presented in a HTML-table. My question is how
do split up the results into two collumns?

All i have for the query is:
$result = mysql_query("SELECT * FROM datatable WHERE item=$searchterm
ORDER BY item ASC",$db);

Thanks a lot!
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
knoak wrote:
My question is how
do split up the results into two collumns?

All i have for the query is:
$result = mysql_query("SELECT * FROM datatable WHERE item=$searchterm
ORDER BY item ASC",$db);


echo '<table class="search_result" summary="search result">';
$column = 0;
while ($row = mysql_fetch_array($result)) {
if (!$column) echo '<tr>';
echo '<td>', $row['whatever'], '</td>';
if ($column) echo '</tr>';
$column = !$column;
}
if ($column) echo '<td>(empty cell)</td></tr>';
echo '</table>';

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.