homepage Welcome to WebmasterWorld Guest from 54.166.39.179
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Newbie SQL Question
Newbie SQL Question
jonny0000

5+ Year Member



 
Msg#: 4154724 posted 11:06 am on Jun 18, 2010 (gmt 0)

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

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



 
Msg#: 4154724 posted 4:07 pm on Jun 18, 2010 (gmt 0)

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

jonny0000

5+ Year Member



 
Msg#: 4154724 posted 8:26 am on Jul 9, 2010 (gmt 0)

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



 
Msg#: 4154724 posted 5:22 pm on Jul 9, 2010 (gmt 0)

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

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



 
Msg#: 4154724 posted 5:53 pm on Jul 9, 2010 (gmt 0)

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>";

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved