Re: putting database results in a 5x1 table



Eddie Biscomb wrote:

> I have a db of tens of thousands of entries. It's not too hard to pull
> all the entries and build a table that displays them one at a time, but
> in my case, that will be a huge waste of space. What I want to do is
> put one record in each of the columns. I thinks it's possible to do
> because I have seen very elaborate thumbnail gallery scripts to do this.
> I just want to be able to put two or three strings of text from each
> record into each row, and a checkbox. Here's sample of what I mean:
>
> <table width="76%" border="1" cellspacing="1" cellpadding="1">
> <tr>
> <td>$record1Line1<br>$record1$Line2<br>
> <input type="checkbox" name="$record1checkbox" value="checkbox"></td>
> <td>$record2Line1<br>$record2$Line2<br>
> <input type="checkbox" name="$record2checkbox" value="checkbox"></td>
> <td>$record3Line1<br>$record3$Line2<br>
> <input type="checkbox" name="$record3checkbox" value="checkbox"></td>
> <td>$record4Line1<br>$record4$Line2<br>
> <input type="checkbox" name="$record3checkbox" value="checkbox"></td>
> <td>$record5Line1<br>$record5$Line2<br>
> <input type="checkbox" name="$record5checkbox" value="checkbox"></td>
> </tr>
> </table>
>
> I want to pull about 200 records at a time from the db and display as
> described above. How can I tell php to take five records from my result
> set and display above, then loop through the result set until I'm done?
>
> Thanks much for any guidance you can offer.
>
> Ed

Set $numRows to how many records you have retrieved total...

for($i=0;$i<$numRows;$i=$i+5){
echo '<tr>';
for($j=$i;$j<($i+5);$j++){
$line1='record'.$j.'Line1';
$line2='record'.$j.'Line2';
$checkbox='record'.$j.'checkbox';
echo '<td>',${$line1},'<br>',${$line2},'<br>',
${$checkbox},'</td>';
}
echo '</tr>',"\n";
}

Try it - maybe I'm just too tired, but it looks ok from here (not tested
of course)... That is assuming that you actually have the variable names
set up as you had indicated in that block of HTML...

I would be more inclined to have the SQL return 3 columns per row so I
could just use something like: $row[0], $row[1], $row[2] for the
variables...

--
Justin Koivisto, ZCE - justin@xxxxxxxxx
http://koivi.com
.



Relevant Pages

  • putting database results in a 5x1 table
    ... It's not too hard to pull all the entries and build a table that displays them one at a time, but in my case, that will be a huge waste of space. ... How can I tell php to take five records from my result set and display above, then loop through the result set until I'm done? ...
    (comp.lang.php)
  • putting db results in a 5 x 1 table
    ... It's not too hard to pull all the entries and build a table that displays them one at a time, but in my case, that will be a huge waste of space. ... How can I tell php to take five records from my result set and display above, then loop through the result set until I'm done? ...
    (php.general)
  • Re: Outlook Address Book and Word
    ... guess the question would be is there anyway that I can pull information from ... display via. ... Dim oApp As Outlook.Application ... Dim oItm As ContactItem ...
    (microsoft.public.word.vba.general)
  • RE: Referrencing to a diff cell
    ... just a possibility of 2 entries, or can there be more on out to the ... ALLthe lists that when i update the indivial pages, ... data validation for the first column. ... I can get it to pull down and use absolute column, but when pull sideways, ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Windows Mail (Vista) taking a long time to display Contacts when sending email
    ... He has not added/deleted any entries since the last time that it ... opened - If he opens the contacts list explicitly from the Windows ... but 10 seconds to display the list when it's ... exporting them as nothing will change with a simple move though it might ...
    (uk.comp.misc)