Jump to content

Tranceflux

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by Tranceflux

  1. Hi The Little Guy, Thanks for your reply! I believe it opened up a dead end for me. I understood most of your awesome solution but I have some point of doubts: 1) $str $query = ltrim($str, '?'); In this code, where do you get the $str from? 2) The link echo '<a href="/search.php?newVal=myval&'.$query.'">Link</a>'; In this code, how does the link detects that its option has been selected and will change to "deselect" mode? (eg. Current url on browser is http://lookbook.nu/search?gender=girls&pattern=argyle Hovering on 'Agryle' gives you <a href="/search.php?gender=girls">Agryle</a> instead of <a href=?/search.php?gender=girls&pattern=agryle) PS: Will credit you on my website!
  2. Hi Jrobles, You might wanna consider the script that I use for my website to generate a dynamic table. As for pagination, I'm afraid you would have to seek help in other tutorials because I haven't included that in my website yet. <?php //Setting up connection and selecting database// include "connection.php"; //Defining array holders// $item_id = array(); $item_image = array(); $item_name = array(); $item_colour = array(); $item_price = array(); $item_account = array(); $item_category = array(); $item_likes = array(); //Defining how many cells to show ($length; you can set it or let it figure out how many to show, see below) and how many per row ($itemperrow) if(!isset($itemperrow)) $itemperrow = 5; if(isset($length)) $length = $length + 1; //Get information needed from database// $sql = "SELECT * FROM item ORDER BY item_likes DESC"; $results = mysql_query($sql,$con); $length = mysql_affected_rows() + 1; //Loop cell generation, I don't start with $i=0 because there will be a problem when you want to end the row, see all the way below echo('<table><tr>'); for($i=1;$i<$length;$i++) { $row = mysql_fetch_array($results); $item_id[$i] = $row['item_id']; $item_name[$i] = $row['item_name']; $item_colour[$i] = $row['item_colour']; $item_price[$i] = $row['item_price']; $item_account[$i] = $row['item_account']; $item_category[$i] = $row['item_category']; $item_likes[$i] = $row['item_likes']; $imageid = $row['item_img']; //Selecting the corresponding image from image table (I store my images of product in another table, which is why I need the code below, feel free to alter the code to suit how you store your images $sql = "SELECT * FROM image WHERE image_id = '$imageid'"; $result = mysql_query($sql,$con); $row = mysql_fetch_array($result); $grabpath = $row['image_path']; $item_image[$i] = $grabpath; //Selecting the account id from account table, as I want to display who uploaded it $sql = "SELECT * FROM account WHERE account_name = '$item_account[$i]'"; $result = mysql_query($sql,$con); $row = mysql_fetch_array($result); $account_id = $row['account_id']; //This is the important cell generation part, tweak the HTML according to what you want echo('<td><a href="item.php?id=' . $item_id[$i] . '"><img src="' . $item_image[$i] . '" id="image" onload="resize(\'image\')" /></a></td>'); //Detects if a new row needs to be created, using the modulus function to find if there is any remainder. Eg. 3 divide by 3 (the function has generated the 3rd cell, the itemperrow is 3, so the next cell should be on a new row. Remainder gives 0, thus echo out a new row if($i%$itemperrow==0) {echo('</tr><tr>');} } //End of the demonic table echo('</tr></table>'); ?> I hope this helps. As for the width etc etc, I would suggest that you use a CSS spreadsheet to define all these as it will make the whole code easier to work with. Cheers!
  3. The included script provides pagination as well. Another tutorial that might interest you: http://www.phpfreaks.com/tutorial/basic-pagination
  4. Hi Tesign, Do you mind elaborating what you want to achieve/ have in mind?
  5. Hi everyone , consider the case below: http://lookbook.nu/search I want to build a search function like that for my ecommerce website but I've been getting lots of Search Engine tutorials on the web instead (eg. using a query string) while I had in mind displaying results based on categories. http://lookbook.nu/search?gender=girls&material=cotton&colors[]=000000 I know lookbook uses $_GET to query their database, but how do they put the different options into 1 query string? (eg. how does the script recognize it should be mysql_query("SELECT * FROM clothes WHERE gender = girls && material = cotton && colors = 000000 SORT BY date DESC")? And another thing that puzzles me as well: Once you have selected on an option (eg. Gender: Girl), the link knows that it is selected and clicking it again will deselect it (eg. http://lookbook.nu/search?gender=girls&material=cotton&colors[]=000000 becomes http://lookbook.nu/search?material=cotton&colors[]=000000) Any advise? Thanks
×
×
  • 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.