Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Data Issue

New Here ,
Jul 26, 2006 Jul 26, 2006

Copy link to clipboard

Copied

Hi,

I am doing a dynamic application for a company that sells printers. I am using MySQL and PHP. On the first page, I need to list each printer series and the features of the series. This is my problem - They had an internal database that has each printer listed in it, along with the printer series it belongs to and the features of each series - it is all in one table. So even if two printers belong to the same series, with same series features, it is repeated - no separate linked table for the series and its features.

This is what I cannot figure out. The printer item number is listed and each of the features has it's own column. So if a printer has a certain feature - it gets a "YES" in the database table. There are about 20 features that each printer item may or may not have. How do I write a record set that pulls up any features that has a "YES" for that series, but on the actual page print what the feature is? So if my printer item number 1000 has YES in the "doub_tray" column and "YES" in the "duplex" column, how do I get it to list:
FEATURES:
* DOUBLE TRAY
* DUPLEX PRINTING

on the actual web page? Will I have to have a separate recordset for each feature??

Thanks!
TOPICS
Server side applications

Views

330
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 26, 2006 Jul 26, 2006

Copy link to clipboard

Copied

You should be able to pull in all of your printer records in one SQL
statement, and then seperate them out programatically.

I started on some code below, but probably need to know more before we go
further.

1. Do you know what printer categories you have, or are they generated from
a list? Or are they just entered into the printer descirption? Are they
standard, defined, or just a text field?

2. How are the printers being printed on the page? Do you have an example
page? Can you show me what you *want* to do or what improvements you're
wanting to make over an existing page?

3. It sounds like you just need to list the *series* of printers, not the
actual printers themselves, is this true? You just want to show what each
series has?

/*This function will add features to an array */
function add_feature($feature){
if ($featureName == "YES"){
features[] = $featureName;
}
return features;
}

//This will loop through your recordset to get all of your informaiton and
sort it out.
do{
$printerID = rs info;
$double_tray = rs_doub_tray
/* Set all of your variables in your do statement. You could also use an
"extract" but it's easier this way with DW recordsets, I think */





"tccdover" <webforumsuser@macromedia.com> wrote in message
news:ea8e4b$7b9$1@forums.macromedia.com...
> Hi,
>
> I am doing a dynamic application for a company that sells printers. I am
> using MySQL and PHP. On the first page, I need to list each printer
> series and
> the features of the series. This is my problem - They had an internal
> database
> that has each printer listed in it, along with the printer series it
> belongs to
> and the features of each series - it is all in one table. So even if two
> printers belong to the same series, with same series features, it is
> repeated -
> no separate linked table for the series and its features.
>
> This is what I cannot figure out. The printer item number is listed and
> each
> of the features has it's own column. So if a printer has a certain
> feature -
> it gets a "YES" in the database table. There are about 20 features that
> each
> printer item may or may not have. How do I write a record set that pulls
> up
> any features that has a "YES" for that series, but on the actual page
> print
> what the feature is? So if my printer item number 1000 has YES in the
> "doub_tray" column and "YES" in the "duplex" column, how do I get it to
> list:
> FEATURES:
> * DOUBLE TRAY
> * DUPLEX PRINTING
>
> on the actual web page? Will I have to have a separate recordset for each
> feature??
>
> Thanks!
>
>


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 26, 2006 Jul 26, 2006

Copy link to clipboard

Copied

Hi!
Thanks for the detailed reply – I added more information, hopefully it will clarify my problem:

Each entry in the database is essentially an entry for a printer item number. Each item number has both a model number (model numbers can have more than one item number, depending on how many ink cartridges and such they may have) and a printer series number. I start with the Printer Series page – which lists out all the different series and some basic features of the series. This page was fairly easy because the features of the series have actual values – like duty_cycle has a value of 2000, so I can list Duty Cycle on the page and have the value come up next to it. This page also lists all the models that belong in the series and then has links to the information about each model.

This is where I get a bit confused (okay, a lot confused!) The features of the models are more like yes and no questions – does it have security locks? Yes or No. So for each feature the column would be labels like this “secr_locks” and the value in the column would either be Y or N. If the answer is Y, I want it to print on the page “Security Locks” under a heading I have put statically on the page that is called “Features” For each column that has a Y in it, I want it to list the real wording of the feature – one after another in a list form.

I guess I am looking for a way to say: If “secr_locks” = Y, then print “Security Locks” for each feature in a certain model. Does that make sense?
Thanks!!
julie

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 27, 2006 Jul 27, 2006

Copy link to clipboard

Copied


> Each entry in the database is essentially an entry for a printer item
> number.
> Each item number has both a model number (model numbers can have more than
> one
> item number, depending on how many ink cartridges and such they may have)
> and a
> printer series number.

OK, so each record is for printer item numbers, but you are looking for
printer series numbers. I should mention here that a database redesign
would be the best way to do things. I don't know how many records you're
storing, but seperting out your printer series and models would most likely
be ideal.

If you don't want to do this, then you can just sort through and pull the
info out of every record. Just note that as your database grows, this will
be a more consuming process, and will only grow in size.

I start with the Printer Series page ? which lists out
> all the different series and some basic features of the series. This page
> was
> fairly easy because the features of the series have actual values ? like
> duty_cycle has a value of 2000, so I can list Duty Cycle on the page and
> have
> the value come up next to it. This page also lists all the models that
> belong
> in the series and then has links to the information about each model.

OK. Again - if you have a page url it would help. I'm not sure how this ^
is laid out.

> This is where I get a bit confused (okay, a lot confused!) The features
> of
> the models are more like yes and no questions ? does it have security
> locks?
> Yes or No. So for each feature the column would be labels like this
> ?secr_locks? and the value in the column would either be Y or N. If the
> answer
> is Y, I want it to print on the page ?Security Locks? under a heading I
> have
> put statically on the page that is called ?Features? For each column that
> has
> a Y in it, I want it to list the real wording of the feature ? one after
> another in a list form.

Are all of them Y/N answers? If so, then just create a function that checks
the value and prints something out.

You could also put all of your "features" into an array, and then print that
array out in a list - again w/o knowing the format or seeing what yur page
looks like, it's whatever you want to do.

This functio will add features to an array.

/*This function will add features to an array */
function add_feature($feature){
if ($featureName == "YES"){
features[] = $featureName;
}
return features;
}

function print_array($array){
echo '<ul>';
foreach($array as $id=>key){
echo '<li>$key</li>';
}
echo '</ul>';

Or you coudl just print them as it is:

function print_features($feature, $name){
if ($features == 'YES'){
echo $name;
}
}

In the first example, it will print a list of your features all at once.
This would need to be done once, after you have compiled it. It may not be
your best solution right now (with the way the rest of your code is setup).

In the second solution, you would just have your featuers setup like this:

<tr>
<td>PrinterName</td><td>Printer Serial Number</td><td><?php
print_features(rs_FeatureField, "Name To Print"); ?></td><td><?php
print_features(rs_FeatureFieldNext, "New Name To Print"); ?></td>

HTH,

Jon


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2006 Aug 14, 2006

Copy link to clipboard

Copied

Okay - now I have to admit, I am totally lost! I am new to php, being an asp person (and not really so good at that!)

Let me take two features (Conv_Fonts_Flg and Ppr_Tray_Lock_Flg) and this is how I would get them to show on the page:

<td><?php print_features(rs_Conv_Fonts_Flg, "Security and Convenience Font"); ?></td>
<td><?php print_features(rs_Ppr_Tray_Lock_Flg, " Paper Tray Lock"); ?></td>

And then am I putting this in the top of the document:

/*This function will add features to an array */
function add_feature($Conv_Fonts_Flg){
if ($Conv_Fonts_Flg == "YES"){
features[] = $Conv_Fonts_Flg;
}
return features;
}
function add_feature($Ppr_Tray_Lock_Flg){
if ($Ppr_Tray_Lock_Flg == "Y"){
features[] = $Ppr_Tray_Lock_Flg;
}
return features;
}
//This will loop through your recordset to get all of your informaiton and
sort it out.
do{
$Prt_Desc = rs info;
$Conv_Fonts_Flg = rs_Conv_Fonts_Flg
$Ppr_Tray_Lock_Flg = rs_Ppr_Tray_Lock_Flg

Sorry for being so lame!
Julie

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 17, 2006 Aug 17, 2006

Copy link to clipboard

Copied

Not being lame, but I'm not sure I understand exactly what you're looking to
do.

> Let me take two features (Conv_Fonts_Flg and Ppr_Tray_Lock_Flg) and this
> is
> how I would get them to show on the page:

OK, have you tried this? Is it nto working? This is how you want to get
them to work o the page, is this how they're going onto the page and you
need to add more, orr...is this part not working yet?


> <td><?php print_features(rs_Conv_Fonts_Flg, "Security and Convenience
> Font");
> ?></td>
> <td><?php print_features(rs_Ppr_Tray_Lock_Flg, " Paper Tray Lock");
> ?></td>

OK, you're goign to need to check that function if you want it to print
anyting, like this:
<?php echo print_features(rs_Conv_Fonts_Flg, "Security....");?></td>

>
> And then am I putting this in the top of the document:
>

> /*This function will add features to an array */
> function add_feature($Conv_Fonts_Flg){
> if ($Conv_Fonts_Flg == "YES"){
> features[] = $Conv_Fonts_Flg;
> }
> return features;
> }

OK, above, you fed two variables into your function, here you're only taking
one in - so that's a problem. It looks like you submitted two properties,
perhaps the table field name and the 'viewable' name, so we'll build your
array like this:

function add_feature($field, $printerFeature, $featuresArray){
//it would be best to loop through all features in here, but i'm not sure
exactly where we're at on the page anymore? or how you're doing this? should
be a do-while loop dependent on a dw recordset (such as your featuers
listing, if these are all in one record, then we can do that as well.

if($field == 'YES'){
$featuresArray[$field]=$printerFeature;
}
return $featuresArray;
}

function print_features($featuresArray){
foreach($featuresArray as $id=>$value){
echo 'whatever you want to do for that where $id is your key, and $value
is the value of the current key being looped through';
}
}

to reference it, just put

$features[] = add_feature($row_DWRecordset['field'],
$row_DWRecordset['name'], $features);

The, if you want to list all array items:

print_features($features);


does this make sense? let's review this before goign on the other part of
the email. i'm waking up slow today


> function add_feature($Ppr_Tray_Lock_Flg){
> if ($Ppr_Tray_Lock_Flg == "Y"){
> features[] = $Ppr_Tray_Lock_Flg;
> }
> return features;
> }
> //This will loop through your recordset to get all of your informaiton and
> sort it out.
> do{
> $Prt_Desc = rs info;
> $Conv_Fonts_Flg = rs_Conv_Fonts_Flg
> $Ppr_Tray_Lock_Flg = rs_Ppr_Tray_Lock_Flg
>
> Sorry for being so lame!
> Julie
>


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 17, 2006 Aug 17, 2006

Copy link to clipboard

Copied

Julie-

Sorry, told you I wasn't awake. Here is the same post, but made a bit more
legible.

Not being lame, but I'm not sure I understand exactly what you're looking
to do.

>> Let me take two features (Conv_Fonts_Flg and Ppr_Tray_Lock_Flg) and this
>> is
>> how I would get them to show on the page:

>> And then am I putting this in the top of the document:
>> /*This function will add features to an array */
>> function add_feature($Conv_Fonts_Flg){
>> if ($Conv_Fonts_Flg == "YES"){
>> features[] = $Conv_Fonts_Flg;
>> }
>> return features;
>> }
>
OK, above, you fed two variables into your function, here you're only
taking one in - so that's a problem. It looks like you submitted two
properties, perhaps the table field name and the 'viewable' name, so we'll
build your array like this:

//it would be best to loop through all features in here, but i'm not sure
exactly where we're at on the page anymore? let's get ti working for one,
then we'll move to more complicated stuff.

function add_feature($field, $printerFeature, $featuresArray){
if($field == 'YES'){
$featuresArray[$field]=$printerFeature;
}
return $featuresArray;
}

function print_features($featuresArray){
foreach($featuresArray as $id=>$value){
echo 'whatever you want to do for that where $id is your key, and $value
is the value of the current key being looped through';
}
}

to reference it, just put

$features[] = add_feature($row_DWRecordset['field'],
$row_DWRecordset['name'], $features);

The, if you want to list all array items:

print_features($features);


does this make sense? let's review this before goign on the other part of
the email. i'm waking up slow today


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 17, 2006 Aug 17, 2006

Copy link to clipboard

Copied

Excellent! Thanks!!!

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 18, 2006 Aug 18, 2006

Copy link to clipboard

Copied

LATEST
did you test it an is it working?

<tryign to hide my surpise> ;o)


"tccdover" <webforumsuser@macromedia.com> wrote in message
news:ec2s2r$cje$1@forums.macromedia.com...
> Excellent! Thanks!!!


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines