Jump to content

wemustdesign

Members
  • Posts

    106
  • Joined

  • Last visited

    Never

Everything posted by wemustdesign

  1. No this does not work. I thik I can see where the problem is. When I output the array it outputs like below with the querystring matching the array key (Array key [0])Cocktail remove=0 (Array key [1])Cocktail1 remove=1 (Array key [2])Cocktail2 remove=2 If I delete Cocktail1 from the favorites it then outputs like this: (Array key [0])Cocktail remove=0 (Array key [2])Cocktail2 remove=1 This is because the querystring is generated by $i. I need the querystring to output the same value as the arraykey if you know what I men
  2. I have looked on the Internet but cannot find an array example that suits my needs. The array that I am outputting in a 'add to favorites' similar to a shopping cart. I am currently outputting the array using the code below. This output ok but doesn't work when removing the items from the favorites via a query string. What I need is something that will output the array and the array key within a query string like '&remove_from_favotites&id=$ARRAY_KEY" $i=0; while ($i < $favorites_Size){ echo $_SESSION['favoriteArray'][$i]." <a href=$url&function=remove_favorite&cocktail=$favoritesArray[$i]&ai=$i>[x]</a><br />"; $i++; }
  3. Yes this is what I have done. I have a table for cocktails with a new cocktail in every row. A table with the ingredients and measurements. The trouble I am having is linking all of the tables together for a query. I have attached a screenshot of how I have set up the database
  4. I am creating a cocktail database and need help on a query if anyonr can help. The database has seperate tables for measurements and amounts measurements are stored as 2|4|3 which translate to oz|dash|squeeze when the measurements table is queried. The problem I am having is that I am not sure how to do simultaneous queries. I am wanting to add a conversion to show how much the amounts will be in ml. This translation would only apply to oz as a dash and squeeze would stay the same. You can see what I mean viewing the page below. How do I carry out a query to only show the ml conversion for oz and not for a dash etc. http://www.cocktail-recipe-guide.com/index.php?section=view_cocktail&cocktail=Adonis Here is the current queries while ($i2<$ingredients_count){ $query2="SELECT * FROM ingredients WHERE id = '$ingredients_explode[$i2]'"; $result2=mysql_query($query2); $query3="SELECT * FROM measurement WHERE id = '$measurements_explode[$i2]'"; $result3=mysql_query($query3); while($row2 = mysql_fetch_assoc($result2)){ $ingredients_n=$row2[name]; $ingredient_r = str_replace(" ", "_", "$ingredients_n"); while($row3 = mysql_fetch_assoc($result3)){ $measurement_n=$row3[name]; if ($amounts_explode[$i2] >1 && $measurement_n == "Part"){ $measurement_n = "Parts"; } //convert to ml $ml_convert = $amounts_explode[$i2]*$ml; echo" $amounts_explode[$i2] $measurement_n <a href=index.php?section=view_ingredient&ingredient=$ingredient_r>$ingredients_n</a> ($ml_convert ml)<br />"; $i2++; }}}
  5. I am creating a cocktail database, its only for fun and to help me learn php more. I have created a favorites facility where users can 'add cocktail to favorites'. Too see the prolem I am having go to the cocktail page and add the cocktail to favorites: http://www.cocktail-recipe-guide.com/index.php?section=view_cocktail&cocktail=Adonis As you can see at the top 2 [x] appear, this [x] is to remove the cocktail from the favorites. I cannot figure out why 2 [x] are created when the first cocktail as added to favorites. All cocktails added after this work fine. Here is the code I wrote to create the 'add to favorites': //=============================================================================== // Favorites //=============================================================================== //========================== // Add 2 Favs //========================== switch ($function){ case ("add_2_favorites"): $_SESSION['favoritesSet'] = 1; $favoritesArray = $_SESSION['favoriteArray']; $favorites_Size = sizeof($favoritesArray); if (is_array($_SESSION['favoriteArray'])){ $array_ex = "1"; }else{ $array_ex ="0"; } if ($array_ex == 1){ $in_array = in_array ($cocktail_name, $_SESSION['favoriteArray']); } if ($in_array) { ?> <script language="Javascript"> alert ("Already in favorites") </script> <? }else{ $_SESSION['favoriteArray'][] = $_GET['cocktail']; } break; //========================== // Remove favs //========================== case ("remove_favorite"): $ai = $_GET['ai']; unset ($_SESSION['favoriteArray'][$ai]); break; //========================== // Remove all favs //========================== case ("remove_all_favorites"): session_unset();// need to just remove variable $_SESSION['favoritesSet'] = 0; break; } echo "favoritesSet =".$_SESSION['favoritesSet']."<br>"; if(!$_SESSION['favoritesSet']) { echo "No favorites"; }else{ $function == "add_2_favorites"; if ($function == "add_2_favorites"){ $favorites_List = "$cocktail_name"; }else{ $favorites_List = ""; } $favoritesArray = $_SESSION['favoriteArray']; $favorites_Size = sizeof($favoritesArray); $i=0; while ($i <= $favorites_Size){ echo "$favoritesArray[$i] <a href=".$PHP_SELF."?function=remove_favorite&cocktail=$favoritesArray[$i]&ai=$i>[x]</a><br /> "; $i++; } echo "size of array: $favorites_Size<br />"; echo "<a href=".$PHP_SELF."?function=remove_all_favorites>Remove all favorites</a><br />"; echo "$favoritesArray[0]"; } I would appreciate if anybody had any suggestions of why this is happening. Not too advanced at php so my code may not be the best.
  6. I have created a simple page with 2 columns. In IE it works fine. When content id added to either the right/ left column the #main wrapper expands to the same height. The problem is in Firefox, when content is added the left/ right divs just overlap the #main wrapper which cannot even be seen. You can see what I mean: http://www.the-photography-studio.co.uk/testpage.html The code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>test page</title> <style type="text/css"> <!-- body {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:0.7em; background-image:url(images/00-tile.gif); background-repeat:repeat; margin:0;} #wrapper{width:750px; margin:0; margin:auto; border:2px solid #504f4f;} #main{width:750px; background:#ffffff;} .mainleft{width:475px; border-right-color:#B7CFF9; border-right-style:dashed; border-right-width:1px; background-color:#CCCCCC; float:left} .mainright{width:274px;background-color:#003399; float:right;} } --> </style> </head> <body> <div id="wrapper"> <div id="main"> <div class="mainleft"> This<br /> is<br /> some<br /> sample<br /> text<br /> <br /> <br /> <br /> <br /> <br /> More text <br /> </div><!--maiinleft--> <div class="mainright"> d<br /> l<br /> l<br /> l<br /> </div> </div><!--main--> </div><!--wrapper--> </body> </html>
×
×
  • 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.