Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7182913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:52:18+00:00 2026-05-28T17:52:18+00:00

I’m trying to create a form that will create a table of pricing for

  • 0

I’m trying to create a form that will create a table of pricing for t-shirts.

There are 10 shirts to choose from and each one is a different price. The S through XL are the same price but the XXL is a different price.

Next there is a selection for the color of the garment which also varys the price and there are 3 options White, Athletic, and Color.

The 3rd selection is the number of colors in the print for the shirt. Which there are 5 options (1-2, 3-4, 5-6, 7-8, 9-10 which affects the price.

Then I also have a few checkboxes which are add-ons that add to the price also.

The final data I want to show is a 2 row table showing in each column the price for 48pc, 72pc, 96pc, 144pc, 288pc. The first row will be the price for S-XL and the 2nd row would be for the XXL price.

I’ve created a super huge file that does the calculations and comes up with a cost but I know there is a easier way and a correct way that what I did. How would you guys do a file like this and can anyone help me out? I’m about to go crazy I been working on it for the past week and half straight.

I didn’t post it because it was to long. I uploaded it to gitHub though heres the link:
https://gist.github.com/1708558GitHub

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:52:19+00:00Added an answer on May 28, 2026 at 5:52 pm

    You are right, there is an easier way – you can write a php script that will generate all this code automatically!

    For example, you create in your MySQL DB a table that will hold the < key,val > of all the shirts:

    < DT0001 , DT0001SHIRTCOLOR >
    < DT000161 , DT000161SHIRTCOLOR >
    …

    and then you read the data from your PHP script and print/echo, for example:

    echo "$(document).ready(function(){ $(\"#garmentselect\").change(function(){ ";
    
    $con = mysql_connect("db-machine","username","password")
                   or die("Unable to connect to SQL server");
    mysql_select_db("schema") or die("Unable to select database");
    $query = "select key,value from my_shirts;";
    $result =  mysql_query($query) or die("No Records Found!");
    while($row = mysql_fetch_array( $result )) {
    
        echo "if ($(this).val() == '".$row[key]."' ) { $('#".$row[val]."').slideDown("fast"); } else { $('#".$row[val].").slideUp("fast");}";
    }
    mysql_close($con);
    echo "});"; // end of $("#garmentselect").change(...";
    //continue ...
    

    You can do this with most of your code and avoid duplication. In general, whenever you copy & paste your code and change only the parameters – you should think about creating a generalized method that will get the parameters as input and will generate the code you wanted to copy (this principle is called “code re-use”).

    Hope I helped.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.