Jump to content

Phaelon

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by Phaelon

  1. Wow! Yeah how did that happen!! OK I tried it, it works. You are truly awesome! Thank you.
  2. Thanks, but it didn't work. SELECT * FROM products DESC;
  3. Hi all, I have a MySQL table with the field 'number'. When I SELECT * from that field, I get a return for the rows of 'number' in the order 1, 2, 3, 4, etc... SELECT * FROM products; Is there a way where I can get a return in the reverse order, so highest to lowest (4, 3, 2, 1, etc...)?
  4. Sure they don't. The code you suggested isn't compatible with what I needed to do. I already told you this. You need to stop assuming you know other people are trying to do.. and if speeds anything to go by, I'd still be stuck if it wasn't for the other help site. You need to stop over analysing in life. I use to have this problem. Cheers.
  5. What ever man... For anyone that wants to know the answer, here it is: while ($row = mysql_fetch_assoc($result)) { ${option'.$row['number']} = 1; }
  6. No, I want to do it my way because there is a bigger picture to what I am doing which I haven't explained as it is irrelevant and I want to keep my thread simple. ... So do you know if what I want to do can be done, or are you just lecture me on what you thinks best without providing any assistance what so ever?
  7. Does anyone know how I can make a variable name with partial use of another variable? while ($row = mysql_fetch_assoc($result)) { $option'.$row['number'].' = 1; } So, I would get: $option1 = 1 $option2 = 1 $option3 = 1 I tried '$option'.$row['number'].'' = 1;, but it didn't work.
  8. Oh, its ok.. I came up with a way: while ($row = mysql_fetch_row($result)) { if (empty($option'.$row['type'].')) { echo '<OPTION>'.$row['type'].'</OPTION>'; $option'.$row['type'].' = 1; } }
  9. Thanks. Can you please explain to me why my way failed, so I don't have to ask again?
  10. Hey all, I want to select a row by its highest value for a specific field (a field called 'price'). I tried it with the following command, but it failed: SELECT * FROM products WHERE MAX(price) AND gender = 'Mens' AND type = 'T-Shirt'; This is my table: +-----------------+--------------+------+-----+-------------------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+--------------+------+-----+-------------------+-------+ | number | int(10) | YES | | NULL | | | gender | varchar(6) | YES | | NULL | | | type | varchar(25) | YES | | NULL | | | name | varchar(50) | YES | | NULL | | | brand | varchar(50) | YES | | NULL | | | colour | varchar(50) | YES | | NULL | | | material | varchar(50) | YES | | NULL | | | countryoforigin | varchar(50) | YES | | NULL | | | price | decimal(6,2) | YES | | NULL | | | cost | decimal(6,2) | YES | | NULL | | | adddate | timestamp | NO | | CURRENT_TIMESTAMP | | | weight | int(5) | YES | | NULL | | | sizetype | varchar(25) | YES | | NULL | | | sizexs | varchar(2) | YES | | NULL | | | sizes | varchar(2) | YES | | NULL | | | sizem | varchar(2) | YES | | NULL | | | sizel | varchar(2) | YES | | NULL | | | sizexl | varchar(2) | YES | | NULL | | +-----------------+--------------+------+-----+-------------------+-------+ Does anyone know why it failed?
  11. Actually, I would like to get this feature working after all. If anyone could help it would be greatly appreciated.
  12. Does anyone know how I can escape a decimal in a URL variable? I.E: example.com/?value=100.00 echo $_GET['value']; returns '', when I am wanting it to return '100.00'. I tried using quotes around 100.00 in the URL, but it didn't work.
  13. Hey guys, I have a simple problem and hope someone can tell me why my script isn't working. Firefox says "ReferenceError: search is not defined". To me it looks defined, but I am not confident in JavaScript and will say I have messed up. <SCRIPT type="text/javascript"> function search() { $search = "/products/mens/t-shirts/"; if (document.getElementById("colour").value != "(Any)") { $search .= "?colour=".document.getElementById("colour").value.""; } if (document.getElementById("material").value != "(Any)") { $search .= "?material=".document.getElementById("material").value.""; } if (document.getElementById("countryoforigin").value != "(Any)") { $search .= "?countryoforigin=".document.getElementById("countryoforigin").value.""; } if (document.getElementById("budget").value != "(None)") { $search .= "?budget=".document.getElementById("budget").value.""; } alert("".$search.""); window.location = $search; } </SCRIPT> <DIV class="centre"> Colour: <SELECT id="colour"><OPTION>(Any)</OPTION></SELECT> <BR> Material: <SELECT id="material"><OPTION>(Any)</OPTION></SELECT> <BR> Country of origin: <SELECT id="countryoforigin"><OPTION>(Any)</OPTION><OPTION>Afghanistan</OPTION><OPTION>Albania</OPTION><OPTION>Algeria</OPTION><OPTION>American Samoa</OPTION><OPTION>Angola</OPTION><OPTION>Anguilla</OPTION><OPTION>Antigua and Barbuda</OPTION><OPTION>Argentina</OPTION><OPTION>Armenia</OPTION><OPTION>Aruba</OPTION><OPTION>Ascension Island</OPTION><OPTION>Australia</OPTION><OPTION>Austria</OPTION><OPTION>Azerbaijan</OPTION><OPTION>Bahamas</OPTION><OPTION>Bahrain</OPTION><OPTION>Bangladesh</OPTION><OPTION>Barbados</OPTION><OPTION>Belarus</OPTION><OPTION>Belgium</OPTION><OPTION>Belize</OPTION><OPTION>Benin</OPTION><OPTION>Bermuda</OPTION><OPTION>Bhutan</OPTION><OPTION>Bolivia</OPTION><OPTION>Bosnia and Herzegovina</OPTION><OPTION>Botswana</OPTION><OPTION>Brazil</OPTION><OPTION>British Indian Ocean Territory</OPTION><OPTION>Brunei Darussalam</OPTION><OPTION>Bulgaria</OPTION><OPTION>Burkina Faso</OPTION><OPTION>Burundi</OPTION><OPTION>Cambodia</OPTION><OPTION>Cameron</OPTION><OPTION>Canada</OPTION><OPTION>Cape Verde</OPTION><OPTION>Cayman Islands</OPTION><OPTION>Central African Republic</OPTION><OPTION>Chad</OPTION><OPTION>Chile</OPTION><OPTION>China</OPTION><OPTION>Colombia</OPTION><OPTION>Comoros</OPTION><OPTION>Congo</OPTION><OPTION>Congo, The Democratic Replublic of The</OPTION><OPTION>Cook Islands</OPTION><OPTION>Costa Rica</OPTION><OPTION>Cote D'Ivoire</OPTION><OPTION>Croatia</OPTION><OPTION>Cuba</OPTION><OPTION>Cyprus</OPTION><OPTION>Czech Republic</OPTION><OPTION>Denmark</OPTION><OPTION>Djibouti</OPTION><OPTION>Dominica</OPTION><OPTION>Dominican Republic</OPTION><OPTION>Ecuador</OPTION><OPTION>Egypt</OPTION><OPTION>El Salvador</OPTION><OPTION>Equatorial Guinea</OPTION><OPTION>Eritrea</OPTION><OPTION>Estonia</OPTION><OPTION>Ethiopia</OPTION><OPTION>Falkland Islands (Malvinas)</OPTION><OPTION>Faroe Islands</OPTION><OPTION>Fiji</OPTION><OPTION>Finland</OPTION><OPTION>France</OPTION><OPTION>French Guiana</OPTION><OPTION>French Polynesia</OPTION><OPTION>Gabon</OPTION><OPTION>Gambia</OPTION><OPTION>Georgia</OPTION><OPTION>Germany</OPTION><OPTION>Ghana</OPTION><OPTION>Gibraltar</OPTION><OPTION>Greece</OPTION><OPTION>Greenland</OPTION><OPTION>Grenada</OPTION><OPTION>Guadeloupe</OPTION><OPTION>Guam</OPTION><OPTION>Guatemala</OPTION><OPTION>Guinea</OPTION><OPTION>Guinea-Bissau</OPTION><OPTION>Guyana</OPTION><OPTION>Haiti</OPTION><OPTION>Holy See (Vatican City State)</OPTION><OPTION>Honduras</OPTION><OPTION>Hong Kong</OPTION><OPTION>Hungary</OPTION><OPTION>Iceland</OPTION><OPTION>India</OPTION><OPTION>Indonesia</OPTION><OPTION>Iran, Islamic Republic of</OPTION><OPTION>Iraq</OPTION><OPTION>Ireland</OPTION><OPTION>Israel</OPTION><OPTION>Italy</OPTION><OPTION>Jamaica</OPTION><OPTION>Japan</OPTION><OPTION>Jordan</OPTION><OPTION>Kazakhstan</OPTION><OPTION>Kenya</OPTION><OPTION>Kiribati</OPTION><OPTION>Korea, Democratic People's Republic of</OPTION><OPTION>Korea, Republic of</OPTION><OPTION>Kosovo, Republic of</OPTION><OPTION>Kuwait</OPTION><OPTION>Kyrgyzstan</OPTION><OPTION>Lao, People's Democratic Republic</OPTION><OPTION>Latvia</OPTION><OPTION>Lebanon</OPTION><OPTION>Lesotho</OPTION><OPTION>Liberia</OPTION><OPTION>Libyan Arab Jamahiriya</OPTION><OPTION>Liechtenstein</OPTION><OPTION>Lithuania</OPTION><OPTION>Luxembourg</OPTION><OPTION>Macao</OPTION><OPTION>Macedonia, The Former Yugoslav Republic of</OPTION><OPTION>Madagascar</OPTION><OPTION>Malawi</OPTION><OPTION>Malaysia</OPTION><OPTION>Maldives</OPTION><OPTION>Mali</OPTION><OPTION>Malta</OPTION><OPTION>Marshall Islands</OPTION><OPTION>Martinique</OPTION><OPTION>Mauritania</OPTION><OPTION>Mauritius</OPTION><OPTION>Mexico</OPTION><OPTION>Micronesia, Federated States of</OPTION><OPTION>Moldova, Republic of</OPTION><OPTION>Mongolia</OPTION><OPTION>Montenegro</OPTION><OPTION>Montserrat</OPTION><OPTION>Morocco</OPTION><OPTION>Mozambique</OPTION><OPTION>Myanmar</OPTION><OPTION>Namibia</OPTION><OPTION>Nauru</OPTION><OPTION>Nepal</OPTION><OPTION>Netherlands Antilles</OPTION><OPTION>New Caledonia</OPTION><OPTION>New Zealand</OPTION><OPTION>Nicaragua</OPTION><OPTION>Niger</OPTION><OPTION>Nigeria</OPTION><OPTION>Niue</OPTION><OPTION>Northern Mariana Islands</OPTION><OPTION>Norway</OPTION><OPTION>Oman</OPTION><OPTION>Pakistan</OPTION><OPTION>Palau</OPTION><OPTION>Panama</OPTION><OPTION>Papua New Guinea</OPTION><OPTION>Paraguay</OPTION><OPTION>Peru</OPTION><OPTION>Philippines</OPTION><OPTION>Pitcairn</OPTION><OPTION>Poland</OPTION><OPTION>Portugal</OPTION><OPTION>Puerto Rico</OPTION><OPTION>Qatar</OPTION><OPTION>Reunion</OPTION><OPTION>Romania</OPTION><OPTION>Russian Federation</OPTION><OPTION>Rwanda</OPTION><OPTION>Saint Kitts and Nevis</OPTION><OPTION>Saint Lucia</OPTION><OPTION>Saint Pierre and Miquelon</OPTION><OPTION>Saint Vincent and the Grenadines</OPTION><OPTION>Samoa</OPTION><OPTION>Sao Tome and Principe</OPTION><OPTION>Saudi Arabia</OPTION><OPTION>Senegal</OPTION><OPTION>Serbia</OPTION><OPTION>Seychelles</OPTION><OPTION>Sierra Leone</OPTION><OPTION>Singapore</OPTION><OPTION>Slovakia</OPTION><OPTION>Slovenia</OPTION><OPTION>Solomon Islands</OPTION><OPTION>Somalia</OPTION><OPTION>South Africa</OPTION><OPTION>Spain</OPTION><OPTION>Sri Lanka</OPTION><OPTION>Sudan</OPTION><OPTION>Suriname</OPTION><OPTION>Swaziland</OPTION><OPTION>Sweden</OPTION><OPTION>Switzerland</OPTION><OPTION>Syrian Arab Republic</OPTION><OPTION>Taiwan</OPTION><OPTION>Tajikistan</OPTION><OPTION>Tanzania, United Republic of</OPTION><OPTION>Thailand</OPTION><OPTION>Timor Leste</OPTION><OPTION>Togo</OPTION><OPTION>Tokelau</OPTION><OPTION>Tonga</OPTION><OPTION>Trinidad and Tobago</OPTION><OPTION>Tristan Da Cunha</OPTION><OPTION>Tunisia</OPTION><OPTION>Turkey</OPTION><OPTION>Turkmenistan</OPTION><OPTION>Turks and Caicos Islands</OPTION><OPTION>Tuvalu</OPTION><OPTION>Uganda</OPTION><OPTION>Ukraine</OPTION><OPTION>United Arab Emirates</OPTION><OPTION>United Kingdom</OPTION><OPTION>United States</OPTION><OPTION>United States Minor Outlying Islands</OPTION><OPTION>Uruguay</OPTION><OPTION>Uzbekistan</OPTION><OPTION>Vanuatu</OPTION><OPTION>Venezuela</OPTION><OPTION>Vietnam</OPTION><OPTION>Virgin Islands, British</OPTION><OPTION>Virgin Islands, U.S.</OPTION><OPTION>Wallis and Futuna</OPTION><OPTION>Yemen</OPTION><OPTION>Zambia</OPTION><OPTION>Zimbabwe</OPTION></SELECT> <BR> Budget: <SELECT id="budget"><OPTION>(None)</OPTION></SELECT> <BR> <BR> <INPUT onclick="return search();" type="button" value="SEARCH"> </DIV>
  14. Never mind, I am going to drop this feature. Thanks anyway.
  15. Hey all, I'm creating a search page and on it people can search by brand. They can do this by toggling a SELECT OPTION <SELECT> <OPTION>BRAND A</OPTION> <OPTION>BRAND B</OPTION> <OPTION>BRAND C</OPTION> </SELECT> What I am wanting to do is make these OPTIONS dynamic and only include brands that I will actually be carrying. Is there a way to do a lookup on a MySQL table of products and for each different type of data, to generate a <OPTION></OPTION> option for it? Like.. a foreach different type of data. The thing I am having a problem with is that there are several different types of products of the same category, such as 'product 1' and 'product 4' both being T-Shirt's, I don't want to have two options as <OPTION>T-Shirt</OPTION><OPTION>T-Shirt</OPTION>. Can what I want to do even be done??
  16. I just put in echo mysql_fetch_assoc($result); before the while and it only returned a single array. That sounds wrong, right?
  17. Yeah that can be done, because $row gets redefined when the while loop reloops, but its not relooping.
  18. I have a table with 2 rows in it, yet PHP is only acting on 1. Does anyone know why? Basically, it should be generating two items on a cart list page (the DIV's), but only the first is present. <?php $query = "SELECT * FROM cart WHERE cartholder = 1"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $sizexs = $row['sizexs']; $sizes = $row['sizes']; $sizem = $row['sizem']; $sizel = $row['sizel']; $sizexl = $row['sizexl']; $query = "SELECT * FROM products WHERE number = ".$row['number'].""; $result = mysql_query($query); $row = mysql_fetch_assoc($result); if ($row['gender'] == 'Mens') {$gender = 'mens';} else {$gender = 'womens';} if ($row['type'] == 'T-Shirt') {$type = 't-shirts';} $number = $row['number']; $brand = $row['brand']; $name = $row['name']; $price = $row['price']; echo ' <DIV class="content"> <A href="/products/'.$gender.'/'.$type.'/product/?productnumber='.$number.'"><IMG alt="" src="/products/'.$gender.'/'.$type.'/'.$number.'/thumb.png"></A> <BR> '.$brand.' <BR> '.$name.' <BR> <BR> $'.$price.' </DIV> '; } ?>
  19. Thanks davidannis, I tried your suggestion, but it didn't work. $_SESSION['cart']['content'] = array( array(number => 1, sizes => 1) , array(number => 2, sizes => 1) ); foreach ($_SESSION['cart']['content'] as $content) { echo 'PRODUCT NUMBER: '.$content['number'].'<BR>'; if (isset($content['sizes'])) {echo 'SIZE S: '.$content['sizes'].'<BR>';} if (isset($content['sizem'])) {echo 'SIZE M: '.$content['sizem'].'<BR>';} echo '<BR>'; } foreach ($_SESSION['cart']['content'] as $key=>$value){ if ($value==2){ $_SESSION['cart']['content'][$key]=2; } } foreach ($_SESSION['cart']['content'] as $content) { echo 'PRODUCT NUMBER: '.$content['number'].'<BR>'; if (isset($content['sizes'])) {echo 'SIZE S: '.$content['sizes'].'<BR>';} if (isset($content['sizem'])) {echo 'SIZE M: '.$content['sizem'].'<BR>';} echo '<BR>'; } Thank you for the information mac_gyver. I just tried to do that, but it didn't work: $_SESSION['cart']['content'] = array( array(number => 1, sizes => 1) , array(number => 2, sizes => 1) ); foreach ($_SESSION['cart']['content'] as $content) { echo 'PRODUCT NUMBER: '.$content['number'].'<BR>'; if (isset($content['sizes'])) {echo 'SIZE S: '.$content['sizes'].'<BR>';} if (isset($content['sizem'])) {echo 'SIZE M: '.$content['sizem'].'<BR>';} echo '<BR>'; } $_SESSION['cart']['content'][2]['sizes'] = 2; foreach ($_SESSION['cart']['content'] as $content) { echo 'PRODUCT NUMBER: '.$content['number'].'<BR>'; if (isset($content['sizes'])) {echo 'SIZE S: '.$content['sizes'].'<BR>';} if (isset($content['sizem'])) {echo 'SIZE M: '.$content['sizem'].'<BR>';} echo '<BR>'; }
  20. To further explain on what I am trying to do, in MySQL I would do the equivilent of something along the lines of: UPDATE content SET sizes = 2 WHERE number = 2; I'm basically wanting to do the same, but for an array in a PHP session. Perhaps I have engineered my session and array wrong for a cart system?
  21. Hi all, I have made the following variable with arrays: $_SESSION['cart']['content'] = array( array(number => 1, sizes => 1) , array(number => 2, sizes => 1) ); Can someone please tell me how I can update the key 'sizes' where 'number = 2' without it touching anything else?
  22. my shopping cart is a total POS and I need to start from scratch and sleep. Thanks anyway.
  23. Is it possible to find out the name of a child variable? I have: $_SESSION['cart']['content']['foo'] $_SESSION['cart']['content']['bar'] I want to basically do: foreach ($_SESSION['cart']['content'][*] as $content) { echo $content['productname']; } Notice the star I am using above to express what I am trying to mean. Ultimately PHP would echo: $_SESSION['cart']['content']['foo']['productname'] $_SESSION['cart']['content']['bar']['productname']
×
×
  • 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.