Pulling In One Item Of Four Categories
Ive got an offers table which contains name, category_id
I want to display all offers, however the first page will only display four offers (one of each category). My query is as follows so how do I do this part? Code:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Reading Categories
I have a text file called cat.dat which contains the username and the categories they have selected. Another file users.dat is for username and password. Now, my authentication part is working fine, but I can't read the cat.dat file to get their selected items.
Multiple Categories
I am looking for a tutorial, or some help with a slight problem that I am having. What I need to do is create a bit of code that will allow me to select multiple categories for a product. I all ready have it so I can pick form a list of categories and unlimited sub categories. Now I need it so I can select mutable categories from a list, and the product gets displayed on them all. I am using MySQL and PHP for this.
Multiple Categories
i am creating a directory of local business and need a bit of help on something. I want to have it where a client can belong to more than 1 category or sub-category. The categories for example are Restaurants, Entertainment, etc. Then under Restaurants you have something like Greek, Italian, etc as the sub-categories. So I have 3 tables. The categories table with the cat title and id number. (there are only 7 categories) The sub categories table with the sub cat title, id number and the number of the category it belongs to. Then I have the client table that contains the client info such as business name, address, etc. In there I have a field for the category and sub category where I fill in the correct number. So if it is a restaurant (cat 1) and an Italian restaurant (sub cat 7) I fill in the correct fields with those numbers. Now with some clients I want to have them say under Restaurants and sub cat Italian and Caterers. When I try putting in 4,45 in the subcategories field of the client table it erases the ,45. So what can I do to fix this? (so that a client can belong to more than one sub-category.
Paginating Categories
i have small problem here, when aa user browses a specific category i wanted to paginate THAT category, as a test i set the display per page to 5 so if i have 15 items in the database the links are correct they show: Code:
Outputting Data In Categories
I'm trying to organize some data into categories. Lets say for example we have this: while ($row = mysql_fetch_assoc($result)) { $data1 = $row["field1"]; $data2 = $row["field2"]; $data3 = $row["field3"]; $data4 = $row["category"]; echo $data4?><br><?php; echo $data1,$data2,$data3?><br><?php; } Which would have a sample output like this: Category1 Field1Field2Field3 Category1 Field1Field2Field3 Category2 Field1Field2Field3 Category2 Field1Field2Field3 How would I get it to print the category name once, then everything belonging to that category, then move to the next category, etc. So it'd look like this: Category1 Field1Field2Field3 Field1Field2Field3 Category2 Field1Field2Field3 Field1Field2Field3 That's the simplest way I can think of putting it. :) Seems to me like it'd be an easy answer, but I've tried a couple of different approaches and can't seem to get it to work.
Categories In Html Form...
Is there any easy way to select a coulmn (categories) from a mySql Database and put it into a dropdown box in a html form to be used to add to the table, this way they wouldn't have to type in the category and just select it from a dropdown box. I need to do this in a way that it won't select every category as there could be 3 rows with dogs as the category, I only want dogs to show up once.
1 Menu/12 Categories/1 PHP Page
I'm trying to replicate this type of php coding here. <snipped url> Basically, it's a simple menu on the left side that retrieves the info of a table (cat) and 12 different fields (ex: Area Guides, Business, etc...) containing web site addresses. My question to you is, how can we use the same php page (res.php in this case) to retrieve the content of 12 different fields? You see, I would have created 12 different php pages while this guy managed to use only one page to do it! Could you please tell me how he did it and maybe paste me some php code to do something similar?
10 Results Per Page But From Different Categories
I have a script that shows a list from a different category depending on what is in the URL. I've got it to limit the results to the 1st ten results and keep the chosen category in the link(?category=differentcategory) but when next page is clicked it repeats the same ten results. Code:
XML With N Numbers Of Nested Categories
I have a XML which can have n number of nested categories and subcategories. The problem is node names are all same for each level. Now can any please tell how can I display names with relation between each? Code:
Automaticaly Displaying Links In Several Categories
I've put together two functions that pull a list of categories from a db which are hyperlinked to all of the links that correspond to that particular category. And two almost identical functions that display the links. What I would like to do is to have the category names echoed out with all of it's respective links automatically under it as opposed to clicking the category to see them. PHP Code:
List All Sub/Sub-Sub Etc.. Categories (Category Tree)
I'm trying to list category tree, but I'm having problems listing sub-sub.. categories. This is my Category field: +-------+----------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+----------+------+-----+---------+----------------+ | ID | int(11) | NO | PRI | NULL | auto_increment | | NAME | longtext | YES | | NULL | | | P_ID | int(11) | YES | | NULL | | +-------+----------+------+-----+---------+----------------+ This is my code So far: Code:
How Do I Create Categories For A Blog Post?
I created a very simple shoutbox. User posts their name and a message and clicks post. It posts to the database and when the page reloads, the "shout" is displayed. I would like to add categories to this little shoutbox application I created. The user should be able to check off boxes to apply different categories to a post. For example a shout could be in the categories, php,mysql,html and css. Logistically how do I do this using MySQL and PHP? ... Obviously this is just a project for learning and has no real application.
Creating Hierarchy Of Links To Parent Categories?..
Hi I've attempted to create a set of links to my pages which displays all higher level (parent) categories. Something like this: Top > Category1 > Category2 > Category3 > Category4 With Category4 being the title of the current category being displayed. Only the higher level categories should be links, ie Category4 in the example should be just text and not hyperlinked. My attempt so far is the code below. It sort of works, but only displays the current category (as text) and it's parent (as a link). As you descend ito the catalog, the higher levels are not visible.
Displaying A List Of Categories From A Database In A Select Box
Could someone please tell me why this outputs nothing <select name=categories> <? $cat_array = get_categories(); foreach($cat_array as $this_cat) { echo "<option value=""; echo $this_cat["category_id"]; echo """; echo ">"; echo $this_cat["category_name"]; echo " "; } ?> </select> ========================================================== function get_categories() { //get the list of categories from the database $conn = mysql_pconnect("localhost", "user", "pwd"); $query = "select * from categories"; $result = mysql_query($query); if(!$result) return false; $num_cats = mysql_num_rows($result); if($num_cats == 0) return false; $result = db_result_to_array($result); return $result; } //A function that returns a query to the database as an array function db_result_to_array($result) { $res_array = array(); for($count=0; $row=@mysql_fetch_array($result); $count++) $res_array[$count] = $row; return $res_array; }
I Have Sub-categories But Want To Display Full Category Path
Let's say I have a simple web application running with just two MySQL tables. The tables structure is as follows: Table: category category_id (PK) category_name parent_category (FK) //references category_id in this table Table: link link_id (PK) link_name link_description category_id (FK) //references category_id in category table Here is the data in the category table 1, England, 0 2, West Yorkshire, 1 3, Batley, 2 4, Leeds, 2 5, Bradford, 2 As you can see Batley, Leeds and Bradford are sub-categories of West Yorkshire which itself is a sub-category of England. What I want to display when I am browsing through sub-categories of links is not only the name of that sub-category but it's category's parents, grand parents and so on like the below example. UK >West Yorkshire >Batley I see this on a lot of directory sites but none of my PHP books cover how this is done. Must be quite simple so can someone please point me in the right direction. Hope I've explained it well enough, haven't a clue what this process is called.
Blog Software With Many Registered Users Categories
I have a blog made with b2evo, but I'd want to migrate to another software. I need this feature: different user levels, and each level see only the posts intended for them. I'd want to be able to do posts for everyone, posts for customers, posts for friends and posts for close friends. The user levels deployed in b2evo and Wordpress seem only to limit editing and blogging, but not readability of the posts (actually, in b2evo you may limit the visibility of a post to the registered users, but all of them, not a category). The only tool I know who could enable me to do that is typo3, but frankly, installing typo3 for a blog seem a bit of a overkill to me... Do you know any blog software who enable the owner to have different levels of visibility for each post?
Iterator First Item?
Let's say I have the code: foreach($data as $row) { do something with each $row } Is there a way to do something specific to the first item iterated? Pseudocode: foreach($data as $row) { if first time through iteration do something with $row else do something which each remaining $row } Is this possible? I think I could use a regular 'for' loop, using the length of the $data array as a guide, and then an 'if..else' structure to see if it is the first time through the 'for' loop, but I was looking for a more elegant solution.
Trying To Split The Item...
I'm trying to make a search thru my mySQL database, so it any keywords are found then I'm adding the details to the next item in an array that I create. I've tested the array and it is storing the information into the array properly because it echoes out all of the information correctly. My problem is that, at the beginning of each item in the array I have information that tells me what part of the database it was pulled from and the id number and also how many times the a keyword was found in that specific database entry. So you have something like this.. Code:
Get Last Item In URL String
I realize how elementary this is, I apologize. Maybe that's why I can't find the right answer. I've tried everything from EXPLODEing the string to SUBSTR_REPLACE. Can anyone tell me how to just get the last item in a URL string? Like turn this: /mydirectory/myimg.jpg into this: myimg.jpg
Deleting An Array Item
I have a standard array: $foo = array( 0 => 'abc' 1 => 'def' 2 => 'ghi'); and I have a variable, $bar, which equals 'def' ... and I want to check my array to see if the value of $bar exists in the array, and if it does, delete it from the array. if (in_array($bar, $foo)) { // what goes here??? } I've done this before, but for the life of me, I'm drawing a blank now. Help a bruthah out?
Random Item Of An Array
What is the best way of picking out a random item of an array, regarding speed and CPU-usage ? I need a super fast way of picking out an ID from my MySQL db.
Search Item In Database
I made a function that does a case insensitive search. This works fine. But i'd like to improve that script so that it also returns items from the database that are partly similar to the search string. this is the script atm:
Delete Item From Database
I still can't figure out how to delete an item from my shoppingcart. I have tried different ways to do this, but its impossible. -a button or link that deletes a item from my database -the php script that deletes it here is a suggestion: $slett = "DELETE ID, VARE, MODELL, STR, ANTALL, PRIS, TOTALPRIS FROM USER_TRACK WHERE USER_ID = "$user_id""; But how can i assign this to a button?
Updating Item Numbers (or IDs)
After a while of deleting records in a MySQL db, there gets to be the gaps in the id numbering system. i.e. 1, 2, 3, 6, 7, 12, and so on. Is there a way to renumber the id system in a table for 1, 2, 3, 4, 5, 6, etc without manually going in and changing those numbers?
Returning Autogenerated ID On New Item
Lets say you have a form that when saved to the mysql database creates a unique incremental id. The form is just the first part of a series of things the user can do, so once the ID is created, the page would need to know immediately what this ID is. Is there a way to grab this ID instantly once it is created? Obviously if this were a sign-up for and a new user name and password are involved, you can have the user login after the initial set up and this select statement would bring back the ID. But the situation I have doesn't work like that. The way I have been dealing with this is simply to have a select statement after the initial insert that requests the record based on a couple of other fields that are likely unique. But this seems like a rather kludgy way of doing it. Is there some other solution.
What Does `Catalog`.item Like '%A-%' Mean? -MySQL?
I am looking at an old query and I cannot remember or figure out what this part of the query means: `Catalog`.item like '%A-%' It is the like '%A-%' I cannot figure out. Then entire query is:[color=blue] > SELECT * > FROM `Catalog` > WHERE `Catalog`.img_status = Ƈ' AND `Catalog`.item_type ='R' AND > `Catalog`.item like '%A-%' > ORDER BY `Catalog`.item_type[/color] And will not work without the Like part
Finding # Of Item From Query
I have a query that goes "SELECT item_name FROM products WHERE products.drink = 'juice'" . If I get back 12 results from this query I can make a list using a simple loop, that is fine . If I click on one of these list items I want to go to a detail page, again I can do this no probs. How do I carry over to the detail page the number that the item appeared in the original list, for example if a result was "orange" and it was the 5th one in the list, how do I carry over the number 5 to the detail page?
Pulling Images
I'm having trouble getting to resize. The script works, but I get an error that says it's unable to open files for reading. Do I need to change modes or something. When I put the image files in the root directory they work fine, but when I put them in my image folder and then write the script to find them there it can't. Any ideas?
Pulling From A Db At Random??
I am trying to pull articles from my db at random on my site. Like for instance for a certain month I will have 20 articles in the db, and would like to pull 3 randm links to the articles at random, so everytime a user loads my hoome page different content will be provided, so it seems fresh. Any thoughts?
Pulling Info
Here is what I I am trying to do. select * from table where fname='fname' order by 'time_sent' desc <-- This works what I am trying to do is: select * from table where fname='fname' and opened='y' and opened='n' and opened='r' order by 'time_sent' desc <-- This doesn't work :( the entries in opened are y, n, r, a I only want it to pull y,n,r and list them where fname='$fname' only I tried googling for a solution with very little luck. Anybody have any ideas how I can accomplish this?
Pulling Certain Data From Db
What i am trying to do is on the view song page on my web site it will display song information. Well on the right of the info i am giong to have more songs by this artist and list about 5 or 6 songs. i have tried many different ways and i cant get it to work. so here is the code i am using $otherProds = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_inventory WHERE ".$glob['dbprefix']."CubeCart_inventory.customer_id=productId AND deleted = 0 ORDER BY popularity DESC"); heres an image explaining what i need to do. but cannot
Pulling First Word
i want to be able to just pull the first part of the person's email address from mydatadase to appear on the page how would i got about doin this?
MySQL... Not Pulling?
I have a few different queries that pull from a very large database in mySQL. It was working fine for the longest time then one day it stopped working. It only pulls like 1 query per request and will not randomize anything. I have tried having it just list the database in PHP but that only pulls out a few things also. I have tried putting backup copies of the database up, that doesn't work either. Has anyone had this problem? I'm sorry its not very detailed, very hard to explain. Code:
Pulling From Three Tables
To display a list of challenges I need to access the data in: ladder_challenges -- challenge_id -- ladder_id -- datetime -- clan_id_a (user's clan) -- clan_id_b (opponent clan) clans -- clan_id (linked to clan_id_b) -- name ladder_config -- ladder_id (linked to challenges ladder_id) -- name The WHERE would be: clan_id_a = $myclanid Basically, I need to produce a HTML table with the following headers: Challenge Info (w link contains challenge_id) || Ladder Name (w link contains ladder_id) Date & Time || Clan Name (w contains link clan id). If you guys can come up with the SQL query I can come up with the table. I've only ever done a join using two tables, not three so I'm not sure where to start.
Populating Form Item From SQL Enum Set Rev#2
$sql = "SHOW COLUMNS FROM table LIKE 'subject' "; $qry = mysql_query($sql) or die("Query not valid: " . mysql_error()); $res = mysql_fetch_object($qry); // This returns a row with a field 'Type' containing 'enum(...)' $res->Type = str_replace('enum('', '', $res->Type); $res->Type = str_replace('')', '', $res->Type); //now the string is something like this: one','two','three $temp = explode('','',$res->Type); //temp is an array with as much elements as the enum while ($temp) print array_pop($temp); This way is much more easier using the elements since they are elements of an array. Cleaver isn't it?
Shopping Cart Item Array
Trying to build a small simple shopping cart and I am having difficulty getting the solution. The cart is displaying each product, but it is overwriting the values. So if I have added 10 products, it shows ten items, but each item has the values of the last product I added. I think that this may be due to me trying to use a key to store both an array and string at once, but Iam not sure. I have looked at other examples but due to different methods, syntax is throwing me off. Code:
Remove A Single Item From An Array
I have gathered an array of ID's. I need to go throught the array and find a specific ID and remove it from the array. Because we want to keep that ID. Any suggestion of how to do that.
How To Replace An Item In The Url Search String
Using PHP 4, what is the most elegant way to replace a parameter value in a url query string? I want to replace the "Order" parameter, but it could occur anywhere in the query string. myfile.php?Param1=Hi+there&Order=ColumnA&Param3=Bye+Bye myfile.php?Order=ColumnA myfile.php?Param1=Anotehr+example&Order=ColumnA after applying this function, I'd like the result of the above examples to be myfile.php?Param1=Hi+there&Order=ColumnB&Param3=Bye+Bye myfile.php?Order=ColumnB myfile.php?Param1=Anotehr+example&Order=ColumnB
Add Item To Shopping Cart Problem
i have a cart link in all of my listed products on the site. when i press this link i will generate a url like this http://www.mysite.com/index.htm?loc...art&productid=3 after i press this link the site cart.php will be included and add the wanted product to the cart, and show the cart. my problem now is after the cart is showed with the new product in it, when i press the F5 key in the browser to refresh the site, the same product will added to the cart once more, because the previous generated url is unchanged in the browser. have anyone a idea how to fix this problem?
How To Apply Css To A Table That Is The Only Item In A Php File Please
How to apply css to a table that is the only item in a php file please In the page that has just the one table that is to be included in the other 2 pages, there's some heavy css going on, plus the text in the table gets changed quite a lot on a daily basis. Usually, in my program, I can highlught the text that needs a different css applied to it and click on the css style that applies to it, but because the page only has the one table and nothing else, there's no mention of the link to the styles page?
Language Depending Item Url's
I'm using a little newsflash item on my webpage, which is some text in an iframe. I have one newsflash item in English and one in another language, newsflash-english.html and newsflash-other.html How can I serve newsflash-english.html to english surfers and newsflash-other.html to not english users ? depending on the browser language ?
Redirecting To The ID Of Newest Item Created
I have a form that a user submits which creates a product. I want the user to be redirected to product.php?product_i=(the new product id) The problem i'm having is that i dont know the ID of the new product created because the table is set to auto increment. How would i go about finding out the new ID and redirecting to that new product after it has just been created?
|