Note that there are some explanatory texts on larger screens.

plurals
  1. POhow do i make a variable from a column of mysql table for every row?
    primarykey
    data
    text
    <p>trying not to make a table with a ton of columns. instead making a few columns and a ton of rows (or records).</p> <p>if i did this with a ton of columns i would know how to do this, but how do you do this with multiple rows/records?</p> <p>i have a table with these fields:</p> <pre><code>id, product_category, product_name, quantity_range, discount_amt </code></pre> <p>there are going to be a lot of records, but i'll just shorten it to a few rows for this question.</p> <p>lets say i had these records:</p> <pre><code>1 Post Card 4x6 5M to 9,999 0.007 2 Post Card 4x6 10M to 14,999 0.01 3 Post Card 4x6 15M to 19,999 0.013 4 Post Card 4x6 20M to 24,999 0.015 5 Post Card 4x6 Over 25M 0.019 </code></pre> <p>now what i want to do is make a group of variables of all the values in just the discount_amt column.</p> <p>so i select everything in table like so:</p> <pre><code>$pricediscountquery = mysql_query("SELECT * FROM pricing_discount") or die(mysql_error()); </code></pre> <p>then loop through result/rows like this:</p> <pre><code>while($pricingdiscountrow = mysql_fetch_array( $pricediscountquery )) { //echo $pricingdiscountrow['product_category']." "; //echo $pricingdiscountrow['product_name']." "; //echo $pricingdiscountrow['quantity_range']." "; echo $pricingdiscountrow['discount_amt']." "; echo "&lt;br /&gt;"; } </code></pre> <p>this displays all the values of the column in a single variable name. i don't want that. i wan't a variable for 0.007, a different variable for 0.01, a different variable for 0.013, a different variable for 0.015, and a different variable for 0.019.</p> <p>how do i do that?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload