Welcome to WebmasterWorld Guest from 54.167.0.111

Forum Moderators: open

Message Too Old, No Replies

Newbie SQL Question

Newbie SQL Question

     

jonny0000

11:06 am on Jun 18, 2010 (gmt 0)

5+ Year Member



Using something like the following echo statement how do I ensure three paired datasets are returned?

echo("

" . $row["CD"]. "
" . $row["CD"]. "
" . $row["CD"]. "
<br>
" . $row["title"]. "
" . $row["title"]. "
" . $row["title"]. "

");
}

rocknbil

4:07 pm on Jun 18, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



A little more info is required: 1) SQL, mySQL, or some other flavor? 2) What is your select statement?

jonny0000

8:26 am on Jul 9, 2010 (gmt 0)

5+ Year Member



I was using MySql.

Just to update on the problem the problem I was having was returning sets of three records at a time which couldnt be done.

This was so I could integrate it into the HTML easily Using Separate Background Color <div> elements to auto set line height. (http://buildinternet.com/2009/07/four-methods-to-create-equal-height-columns/)

I used a single cell HTML calling the record and some PHP to wrap the row tags after every three records were called.

Any other solutions I overlooked please add them on.

abcorn

5:22 pm on Jul 9, 2010 (gmt 0)

5+ Year Member



If you're trying to get three values from the "cd" column then three values from the "title column", that match each other, you can do that using this:

$cd1 = $row["cd"];
$title1 = $row["title"];
$cd2 = $row["cd"];
$title2 = $row["title"];
$cd3 = $row["cd"];
$title3 = $row["title"];

echo("

" . $cd1. "
" . $cd2. "
" . $cd3. "
<br>
" . $title1. "
" . $title2. "
" . $title3. "

");


Does that answer your question?

rocknbil

5:53 pm on Jul 9, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Just to update on the problem the problem I was having was returning sets of three records at a time which couldnt be done.


How so? Show us your select statement. :-)

$table_rows = null; // to squelch concatenation warnings

$query = "select * from table";

$result = mysql_query($query);
while ($row=mysql_fetch_array($result)) {
$table_rows .= '<li>' . $row['CD'] . ' ' . $row['title'] . '</li>';
}

echo "<ul>$table_rows</ul>";
 

Featured Threads

Hot Threads This Week

Hot Threads This Month