Connecting Tech Pros Worldwide Help | Site Map

Layout of mySQl query

  #1  
Old July 17th, 2005, 10:57 AM
knoak
Guest
 
Posts: n/a
Yes, that works great! Thanks a bunch!
Too bad i don't understand this (yet) completely...

But thanks a lot!

Greetings knoakske
  #2  
Old July 17th, 2005, 10:57 AM
Pedro Graca
Guest
 
Posts: n/a

re: Layout of mySQl query


[Why didn't you quote the previous posts?]
[Yes, I know Google groups suck]

knoak wrote:[color=blue]
> Yes, that works great! Thanks a bunch!
> Too bad i don't understand this (yet) completely...[/color]

[previous posts pasted back in]
[color=blue]
> $result = mysql_query("SELECT * FROM datatable WHERE item=$searchterm
> ORDER BY item ASC",$db);[/color]

## start the table
echo '<table class="search_result" summary="search result">';

## initialize control variable
## $control will either be 0 or 1
## 0 means we're about to output the first column
## 1 means we're about to output the second column
$column = 0;

## for every record selected
while ($row = mysql_fetch_array($result)) {

## start a table row if it is the first column
if (!$column) echo '<tr>';
## print the data
echo '<td>', $row['whatever'], '</td>';
## end the row if it is not the first column
if ($column) echo '</tr>';

## swap between 1 and 0 every time this line executes
$column = !$column;
}

## if there were an odd number of records selected we will
## be left with an empty last cell -- fill it
if ($column) echo '<td>(empty cell)</td></tr>';

## end the table
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!
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
html table cell validation by mysql query results aas4mis answers 2 September 19th, 2008 06:12 PM
Problem with layout mySQL query knoak answers 1 July 17th, 2005 11:03 AM
Layout of mySQl query knoak answers 1 July 17th, 2005 10:58 AM
Layout of mySQl query knoak answers 1 July 17th, 2005 10:56 AM