Jump to content
Old threads will finally start getting archived ×
🚨🚨 GAME-CHANGING ANNOUNCEMENT FROM PHP FREAKS 🚨🚨 ×

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.