Jump to content

Data Customization Help


keyurshah

Recommended Posts

Hi y'all 'freaky' family members, howz y'all?

I need some of your guidance as I have found myself entangled in a problem.

 

Well I have this three tables of make, model and version.

The schema of the tables are as:

MakeTable
  `makeid` int(4) NOT NULL auto_increment,
  `makename` varchar(100) NOT NULL default '',
  PRIMARY KEY  (`makeid`)
ModelTable
  `modelid` int(4) NOT NULL auto_increment,
  `makeid` int(4) NOT NULL default '0',
  `modelname` varchar(100) NOT NULL default '',
  PRIMARY KEY  (`modelid`)
VersionTable
  `versionid` int(4) NOT NULL auto_increment,
  `modelid` int(4) NOT NULL default '0',
  `versionname` varchar(100) NOT NULL default '',
{ Appr 85 Fields Here... }
  PRIMARY KEY  (`versionid`)

What I need to do is to prepare a report of version data.

 

For that I have made this make dropdown wherein all the makes are shown. Then below that there is the model dropdown which is populate by model names according to the make selected. And finally a multiple select version dropdown which is populated by version names according to the model selected. A user can select multiple versions by ctrl+click.

- Going fine till here

 

After posting the form, I implode the versions and make a version search string like this:

$num = count($_POST['versionone']); // number of versions selected
$k = implode(",", $_POST['versionone']); // adding a comma after each versionid
$version_string = "(".$k.")"; // preparing a string like (757,758,759,766,764)

 

Then, the sql:

SELECT 
VersionTable.*, 
ModelTable.modelid, 
ModelTable.modelname, 
MakeTable.makeid, 
MakeTable.makename, 
nwveh_vtype.vtypename, 
nwveh_vtype.vtypeid 
FROM VersionTable 
INNER JOIN ModelTable ON ModelTable.modelid=VersionTable.modelid 
INNER JOIN MakeTable ON MakeTable.makeid=ModelTable.makeid 
WHERE VersionTable.versionid IN (757,758,759,766,764)"

 

The above sql gives the desired results but not a the above table. Need to arrange the queried data according to the table below:

 

 

   

   

1.1 iRDE Era

   

1.1 iRDE Magna

   

1.2 Kappa Magna

   

1.2 Kappa Magna AT

 

 

   

Engine Displacement

   

1234 cc

   

2345 cc

   

3456 cc

   

4567 cc

 

 

   

Engine Type

   

Inline SOHC

   

Inline SOHC

   

Inline SOHC

   

Inline SOHC

 

 

   

Power

   

50Bhp@3200

   

63Bhp@3200

   

63Bhp@3200

   

70Bhp@3200

 

 

   

Torque

   

180Nm@1440-1500

   

180Nm@1440-1500

   

180Nm@1440-1500

   

180Nm@1440-1500

 

 

   

Transmission

   

Manual

   

Manual

   

Automatic

   

Automatic

 

 

   

So on....

   

   

   

   

 

 

Thanks,

Keyur

 

Link to comment
https://forums.phpfreaks.com/topic/136479-data-customization-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.