homepage Welcome to WebmasterWorld Guest from 67.202.56.112
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
Newbie SQL Question
Newbie SQL Question
jonny0000




msg:4154726
 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




msg:4154891
 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




msg:4167026
 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:4167282
 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




msg:4167304
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved