Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2006-01-04, 11:10 PM
Junior Member
 
Join Date: Jan 2006
Posts: 16
sheldongold
Default

Hello all - once again I am seeking a wee bit of assitance...

ok. at the moment if a listtype = 3 then it'll create a dropdown list of the product. incidentally if it is = 2 then it creates a product header and if it's = 1 then it shows it as a normal product.

Now I'm probably going about this the wrong way but if I can do it this way then great cos I've kinda got it figured in my head ok... just not in code..

Now, I want to be able to distinguish whether 'listtype' = 3 and 'title' = previous 'title' and previous 'listtype' = 2

this will be to detect the first dropdown item, create a new table row, start the <select> and create the first <option> entry.

Next I want to test if 'listtype' = 3 and 'title' = previous 'title' and 'title' = next 'title'

to just create all the inbetween <option> entries.

and finally test if 'listtype' = 3 and 'title' = previous 'title' and 'title' != next 'title'

to add the final <option>, close the </select> and close the table row.


my curent basic selection is:
Code:
elseif ($row['listtype'] == '3')
  {
   echo  '<tr><td></td><td>';
   echo  '<select size="1"><option value="';
   echo  $row['productid'];
   echo  '">';
   echo  $row['description'];
   echo  '</select></td></tr>';
   }
as you can see this is just to check I've got the basic syntax right, I'm just not sure how to compare the records. If you need anything else from me in order to help please let me know - I'm here all night... Also, if this doesn't make any sense please let me know that too and I'll try to explain myself a liitle more clearly.

Thanks
Sheldon
Reply With Quote
  #2 (permalink)  
Old 2006-01-05, 01:44 AM
Junior Member
 
Join Date: Jan 2006
Posts: 16
sheldongold
Default

Something like this is what I'm after - but something like this that works...

Code:
  elseif ($row['listtype'] == '3')
  {
  $nextrow = next($row);
  $prevrow = prev($row);
  if (($row['title'] == $prevrow['title']) && ($row['listtype'] == $prevrow['listtype']))
  {
    echo  '<tr><td></td><td>';
    echo  '<select size="1">
        <option value="';
    echo  $row['productid'];
    echo  '">';
    echo  $row['description'];
  }
  elseif (($row['title'] == $prevrow['title']) && ($row['title'] == $nextrow['title']))
  {
    echo  '<option value="';
    echo  $row['productid'];
    echo  '">';
    echo  $row['description'];
  }
  elseif (($row['title'] == $prevrow['title']) && ($row['title'] != $nextrow['title']))
  {
    echo  '<option value="';
    echo  $row['productid'];
    echo  '">';
    echo  $row['description'];
    echo  '</select></td></tr>';
  }
 }
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:00 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.