Jump to content

lil_bugga

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

About lil_bugga

  • Birthday 08/18/1988

Contact Methods

  • Website URL
    http://www.ben.broxie.co.uk

Profile Information

  • Gender
    Male
  • Location
    Bishop's Stortford, UK

lil_bugga's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm still at a loss, can someone please help me with this?
  2. I've tried to amend the code, but I'm still having issues, as I said I'm still learning what I'm doing so can I have a pointer in the right direction with a little more detail so I can follow and learn. while ($trail = mysqli_fetch_array($get_trail_res)) { $subcat_id = $trail['subcat_id']; $subcat_title = $trail['subcat_title']; if (subcat_id = $_GET["item_id"].")"; { break; } } while ($data = mysqli_fetch_array($get_data_res)) { $item_title = ucwords(stripslashes($data['item_title'])); $item_price = $data['item_price']; $item_image = $data['item_image']; $item_desc = $data['item_desc']; $display_title ="<h3>".$item_title."</h3><br />\n"; $display_price ="<h3>&#163;".$item_price."</h3><br />\n"; $display_image ="<br /><img src=\"".$item_image."\" /><br />\n"; $display_desc ="<br />" .$item_desc. "<br />\n"; } //make breadcrumb trail $display_trail = "<strong><em>You are viewing:</em> <a href=\"/benwoolner/littleshopper/showitems.php?subcat_id=".$subcat_id."\"> ".$subcat_title."</a> > ".$item_title."</strong>
  3. Basically I want to be able to get the subcat_id and subcat_title coloumns from the store_subcategories based on the selection of an item from the store_items table. For example if i was to choose the womans rugby shirt from the store_items table in the post above I want to retrieve Ladies from the store_subcategories table
  4. I'm trying to create a bread crumb trail so that users on my website ,http://ben.broxie.co.uk/benwoolner/littleshopper/ ,can jump back a caterogy. At the moment though every time a user clicks to see an items main details the link back to that category seems to always be sci fi. The table above is store_subcategories, and store_items has 75 indervidual IDs consiting of groups of 5 sharing the same subcat_id like below I've tried to create a join to link the tables and get the results I want but I'm still new to PHP and SQL so I think thats where its gone wrong. Below is my code upto the point of the bread crumb trail. <?php session_start(); //connect to server and select database; you may need it $mysqli = mysqli_connect("localhost", "***", "***", "littleshopper"); // sets up queries $get_data_qry = "SELECT item_title, item_price, item_desc, item_image FROM store_items WHERE id='".$_GET["item_id"]."'"; $get_trail_qry = "SELECT store_subcategories.subcat_id, store_subcategories.subcat_title FROM store_subcategories JOIN store_items ON store_items.subcat_id"; // sets up query calls $get_data_res = mysqli_query($mysqli, $get_data_qry) or die(mysqli_error($mysqli)); $get_trail_res = mysqli_query($mysqli, $get_trail_qry) or die(mysqli_error($mysqli)); //get and show 1st level navigation if (mysqli_num_rows($get_data_res) < 1) { $display_content = "<h3>We're Sorry!</h3><p>We've searched out database and couldn't find anything under that category</p>\n"; } else { while ($trail = mysqli_fetch_array($get_trail_res)) { $subcat_id = $trail['subcat_id']; $subcat_title = $trail['subcat_title']; } while ($data = mysqli_fetch_array($get_data_res)) { $item_title = ucwords(stripslashes($data['item_title'])); $item_price = $data['item_price']; $item_image = $data['item_image']; $item_desc = $data['item_desc']; $display_title ="<h3>".$item_title."</h3><br />\n"; $display_price ="<h3>&#163;".$item_price."</h3><br />\n"; $display_image ="<br /><img src=\"".$item_image."\" /><br />\n"; $display_desc ="<br />" .$item_desc. "<br />\n"; } //make breadcrumb trail $display_trail = "<strong><em>You are viewing:</em> <a href=\"/benwoolner/littleshopper/showitems.php?subcat_id=".$subcat_id."\"> ".$subcat_title."</a> > ".$item_title."</strong> I'd be greatful if someone can help me sort this out and explain to me where I've gone wrong and what changes I need to make and why
  5. Thats worked really nicely, thanks for the help
  6. Hi, I've got my data currently displaying inside tables but currently they line up underneath each other. How can I change this so my items display 4 wide and as many down as is needed. The link shows you what I'm getting so far. http://ben.broxie.co.uk/benwoolner/littleshopper/showitems.php?subcat_id=1 // sets up queries $get_data_qry = "SELECT item_title, item_price, item_image FROM store_items ORDER BY id"; // sets up query calls $get_data_res = mysqli_query($mysqli, $get_data_qry) or die(mysqli_error($mysqli)); //get and show 1st level navigation if (mysqli_num_rows($get_data_res) < 1) { $display_content = "<p><em>Sorry, no categories to browse.</em></p>\n"; } else { while ($data = mysqli_fetch_array($get_data_res)) { $item_title = ucwords(stripslashes($data['item_title'])); $item_price = $data['item_price']; $item_image = $data['item_image']; $display_content .= " <table border=\"1\" width=\"180px\">\n <tr>\n <td><p class=\"centre\"><b>".$item_title."</b></p></td>\n </tr>\n <tr>\n <td><p class=\"centre\"><img src=\"".$item_image."\" height=\"127px\" width=\"157px\"></p></td>\n </tr>\n <tr>\n <td><b>Item Price:</b> &#163;".$item_price."</td>\n </tr>\n </table>\n"; } }
  7. Cheers, i dunno how I missed them, bin trying to get it working a good half hour an its right under my nose , its always the way Thanks again
  8. I'm trying to display the data from inside one of my database tables using the code below, but all I'm getting returned is white space. Any ideas?, I have the connection to the database all set up correctly too // sets up queries $get_data_qry = "SELECT id, subcat_id, item_title, item_price, item_desc, item_image FROM store_items ORDER BY id"; // sets up query calls $get_data_res = mysqli_query($mysqli, $get_data_qry) or die(mysqli_error($mysqli)); //get and show 1st level navigation if (mysqli_num_rows($get_data_res) < 1) { $display_content = "<p><em>Sorry, no categories to browse.</em></p>\n"; } else { while ($data = mysqli_fetch_array($get_data_res)) { $id = $cats['id']; $subcat_id = $cats['subcat_id']; $item_title = ucwords(stripslashes($cats['cat_title'])); $item_price = $cats['item_price']; $item_desc = $cats['item_desc']; $item_image = $cats['item_image']; $display_content .= "blah ".$id."<br />\n ".$subcat_id."<br />\n ".$item_title."<br />\n ".$item_price."<br />\n ".$items_desc."<br />\n ".$item_image; } } Below is the table i'm selecting from, i haven't listed the image coloumn to save time
  9. Please see my new topic, i think that demonstrates and explains what I want a lil more clearly, it just be me getting it wrong as im new to php. http://www.phpfreaks.com/forums/index.php/topic,252495.msg1185812.html#msg1185812
  10. On the image below are the results im trying to achieve both visually and operationally. When books is clicked the navigation panel expands to show 2nd level navigation. When another link is clicked on it will close books and if it has 2nd level navigation will expand. This navigation was achieved using this tutorial http://www.tutorials-db.com/articles/Coding_a_Smooth_CSS_Expanding_Navigation/ The lower of the 2 part image shows my actual results. I've got as far as I can with it so am hoping that someone can help steer me down the right path. I'm new to PHP so I'm happy to have got this far. My thinking for the code below was [*]create $max to store highest id no. from store_cats [*]create $counter = 1 [*]start loop whilst $counter <= $max [*]start building display block[] [*]add in 1st level navigation with the javascrtipt link (as tutorial) [*]add 2nd level navigation inside div (as tutorial) [*]incriment $counter by 1 [*]end loop [*]repeat process until $counter equals $max <?php //connect to server and select database; you may need it $mysqli = mysqli_connect("localhost", "***", "***", "test") or die("There was an error trying to connect to the database"); //show categories first echo "php start<br /><br />"; // sets up queries $max_id_qry = "SELECT MAX(id) as \"max\" FROM store_categories"; $cat_title_qry ="SELECT cat_title FROM store_categories"; // sets up query calls $max_id_res = mysqli_query($mysqli, $max_id_qry) or die("There was an error trying to send a query to the database"); $cat_title_res = mysqli_query($mysqli, $cat_title_qry) or die("There was an error trying to send a query to the database"); // sets up my variables $max = 0; $counter = 1; // retrieve the highest value id listed in store_categories if (mysqli_num_rows($max_id_res) > 0) { $tmp = mysqli_fetch_array($max_id_res); $max = $tmp['max']; // release query to free up memory mysqli_free_result($max_id_res); //display result for testing echo "max id value is ".$max."<br />"; // retrieve nav text if (mysqli_num_rows($cat_title_res) > 0) { $temp = mysqli_fetch_array($cat_title_res); $link_title = $temp['cat_title']; } } // prints counter and link_title echo "<br />".$counter." ".$link_title."<br />"; // sets up while loop used to create display block while ($counter <= $max) { $display_block = "<a href=\"javascript:display('".$cat_title."')\" class=\"Normal\">>>" .$cat_title. "<<</a><br />"; $display_block .= " <div class=\"hide\" id=\"".cat_title."\">"; $display_block .= "test data hard coded for now to provide 2nd level nav"; $display_block .= "</div>"; $counter = $counter + 1; } //close connection to MySQL mysqli_close($mysqli); ?> Whilst I remember these are my two tables If this thread doesn't make sence then please ask for more info
  11. thats not what i was looking to get results wise but thanks anyway. I'm trying a different method now so I'll see how that goes
  12. any one any ideas or am I still loosing you all?
  13. Basically I have two tables for items in a mock shop store_categories id cat_title cat_desc 1 Hats Funky hats in all shapes and sizes! 2 Shirts From t-shirts to sweatshirts to polo shirts and be... 3 Books Paperback, hardback, books for school or play and store_subcategories subcat_id cat_id subcat_title 1 3 Adult Books 2 3 Childrens Books 3 3 Educational Books 4 3 Reference Books 5 2 Mens Tops 6 2 Boys T-ops 7 2 Ladies Tops 8 2 Grils Tops 9 1 Causal Hats 10 1 Party Hats 11 1 Fishing Hats 12 1 Sports Hats I'm attempting to load these so that I can have my navigation update just from the database so I can add and remove lines without all the effort. When I was mocking up my site I was using javascript to manage my navigation and its different levels. This is the javascript navigation I had in place before hand, basically when i clicked the main link the div changes from hidden to visible. <a href="javascript:display('Books')" class="Group">~ Books ~</a> <div class="hide" id="Books"> <a href="#" class="Option">Beginners</a> <a href="#" class="Option">Kids</a> <a href="#" class="Option">Adult</a> </div> I'm trying to get my SQL code to produce this block of code from me substituting the hard coded values like books from the example above with the categories from store categories table. hope this helps make it clearer
  14. Hi guys, I posted a topic a few days ago having problems with my navigation system, I've still had no replies on that to help so I'm trying a new way. I'm thinking of: [*]1st creating $num to store highest id no. from store_category [*]then creating $i = 0 [*]then starting loop whilst $i <= $num, start building display block[] [*]then make a query to get store_category title that is the equivilant of $i [*]then make a query to get any sub links [*]incriment $I =$i +1 [*]end loop each new iteration should now get the main link and any 2nd level links then i should be able to display the blocks The problem i'm having at the moment is retrieving the highest value, this is what I have so far <?php //connect to server and select database; you may need it $mysqli = mysqli_connect("localhost", "xxx", "xxxxx", "test"); //show categories first echo "php start<br /><br />"; $num = "SELECT MAX(id) FROM store_categories"; $res = mysqli_query($mysqli, $num); if (res) { echo $res; } echo "<br /><br />php end"; //close connection to MySQL mysqli_close($mysqli); ?> What i'm trying to achieve overall is a block like this, then where i have the options of beginners, kids and adults I could have many more options all taken from my database Thanks in advanced for any help
×
×
  • 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.