Jump to content

dmarchman

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dmarchman's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You can use distinct within a join but requires a group by the distinct value to work select distinct * from prod as p, gal as g where p.id_prod = g.idprod_gal group by idprod_gal order by p.update_prod That worked! Sweet beans! Thanks so much! I'm kicking myself for how simple that is.
  2. That produces the same thing I'm getting with my original query. It duplicates the products for every image in the gal table assigned to it. Thanks for the suggestion, though.
  3. I have 2 tables, one stores products and the other stores multiple images for each product here is my SQL to write both: CREATE TABLE `prod` ( `id_prod` int(11) NOT NULL auto_increment, `cat_prod` int(11) NOT NULL default '0', `title_prod` text, `desc_prod` longtext, `reason_prod` text, `qty_prod` int(11) default NULL, `price_prod` decimal(6,2) NOT NULL default '0.00', `location_prod` varchar(255) default NULL, `manu_prod` text, `typesale_prod` text, `update_prod` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id_prod`) ); CREATE TABLE `gal` ( `id_gal` int(11) NOT NULL auto_increment, `idprod_gal` int(11) NOT NULL default '0', `img_gal` varchar(255) NOT NULL default '', PRIMARY KEY (`id_gal`) ); The tables are linked with id_prod & idprod_gal. The gal table can store the names of multiple images for each product. I want to query the prod table to give me a list of all the products in it, but join the gal table to pull out one image to display. My current attempts of writing this see the images as the unique items and therefore display a product several times, once for each instance of an image. This is the query that does this: SELECT * FROM prod INNER JOIN prodcats ON cat_prod = id_prodcats INNER JOIN gal ON id_prod = idprod_gal ORDER BY update_prod DESC Is there something simple I am missing here. I appreciate any help I can get.
  4. figured this out with the help of this excellent website here's the tables in the db: (art is the name of the table that holds my articles) CREATE TABLE `art` ( `id_art` int(11) NOT NULL auto_increment, `idtop_art` int(11) NOT NULL default '0', `title_art` varchar(100) NOT NULL default '', `desc_art` varchar(255) NOT NULL default '', `text_art` longtext NOT NULL, `date_art` datetime default NULL, PRIMARY KEY (`id_art`) ) (top is the name of the table that holds the names of the topics of the articles) CREATE TABLE `top` ( `id_top` int(11) NOT NULL auto_increment, `topic_top` varchar(100) NOT NULL default '', PRIMARY KEY (`id_top`) ) heres the SQL(switch to advanced mode in the recordset dialog) SELECT *, count(*) FROM art INNER JOIN top ON idtop_art = id_top GROUP BY topic_top ORDER BY topic_top ASC from the bindings panel in dreamweaver i only need to drag out the name of the topic and the count dynamic text blocks to make it work. i could simplify the SQL by only selecting the fields i need to like this: SELECT id_top, topic_top, count(*) FROM art INNER JOIN top ON idtop_art = id_top GROUP BY topic_top ORDER BY topic_top ASC this would make the search a bit faster, and i could pass the primary key to a sort page to only display articles of a given topic. not too bad for someone at the end of his rope a couple of days ago..
  5. i used my brain and figured it out myself. this is the easy way and requires a little more management than an db solution, but it works. first i made some links on a page with the month and year and then pointed them to another page and passed a parameter for example: june 2005 links to datesortbymonth.php?date_blogent=2005-06 then on the datesortbymonth.php page i made a recordset with the following query: SELECT * FROM blogent WHERE date_blogent LIKE '%colname%' ORDER BY date_blogent DESC and the following Variable: colname 1 $_GET['date_blogent'] basically in simple mode of the DW recordset dialog you set the filter keyword to "contains" as in date_blogent contains URL Parameter date_blogent. worked all good and purty.
  6. I have on my index page the newest entry from my database, and at the bottom the user can click to go to a page that displays the entry as well as comments for that entry. The blog entry and the comments are being pulled from separate tables. Now I need to tweak the View/Post Comments Link on my index page to display the number of comments for that entry. I have messed around with the SQL and have made it display the total number of comments for ALL of the entries combined, but I need to sort it somehow by the id of the entry. Any help on this would be appreciated.
  7. did you try disabling Preview using temporary file in the DW preferences under the Preview in Browser category and try to preview the page itself. sometimes dreamweaver does some stupid things with those temp files, like saving them to your site folder.
  8. i am working on a blog i made in dreamweaver and need some help 'cause i'm a MySQL n00b. I have a table in my db to store my blog entries (i named the table blogent) and when i enter a new blog a DATE field in that table named date_blogent that automatically stores the date i entered the blog in (with the date being stored as YYYY-MM-DD of course). I want to create links on a page that allow me to sort my blog entries by the month they were entered for example, i click on a link that says "July 2005" and the page filters through just the entries for that month. its probably something too simple and stupid for my feeble mind to comphrehend but any help would be appreciated.
  9. i found this: Clicky clicky i used the version that stores my username and password in the login page since i'm the only one who accesses my admin area.
  10. why not just install apache and php and make your local system a test server. i setup my laptop this way and it works great. i used the book "PHP Dreamweaver MX 2004" by Apress which shows you step by step how to install and configure Apache, PHP and MySQL. you can even set Apache to listen on another port so you can develop with PHP or ASP/IIS on the same machine. the self-installing PHP/MySQL apps are conveinent, but lack the ability to go in and fine tune them to your needs. manually installing Apache, PHP and MySQL makes life a lot easier, and it's not too difficult to do.
  11. It's a known-by-macromedia bug that the restrict assess to page server behavior doesn't work right because it doesn't use globals to store the session. There are a few fixes out there, but for some reason macromedia hasn't addressed this theirselves. I found one workaround in the book: PHP Dreamweaver MX 2004 (Apress ISBN 1-59059-350-2), but while the fix worked fine on my test server, it didn't work on my webhost. I eventually turned to another script after searching for one that explained itself simply. I still don't understand why macromedia won't fix this. Hell, they updated to 7.01 to fix numerous bugs and even added back in the godawful timeline panel that NOBODY uses.
  12. What I'm trying to do is create an entry page for my blog that will display my blog entries. To give you an example of what is going to be displayed, here is the layout: Recent blog header Most recent title date posted tagline blog entry body copy Previous blog entries header Blog title Blog title Blog title I basically want the most recent entry in my blog database to display in its entirety, then below that show the next 3 recent entries in the database as a title only. This is the query I use to display the most recent entry: And with the help of a friend (who knows nothing about PHP but knows ColdFusion so I took the code he gave me and did my best to translate it) I wrote this query to try to display the other entries: the $query_rsBlog is the variable name the query is being stored in. it's a recordset built w/ Dreamweaver since I'm not comfortable with hand writing my SQL. Here is the full code for the recordsets that Dreamweaver writes if it helps.. [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]mysql_select_db($database_heading1, $heading1); $query_rsBlog = \"SELECT * FROM blogent INNER JOIN topics ON idtop_blogent = id_top ORDER BY id_blogent DESC LIMIT 1\"; $rsBlog = mysql_query($query_rsBlog, $heading1) or die(mysql_error()); $row_rsBlog = mysql_fetch_assoc($rsBlog); $totalRows_rsBlog = mysql_num_rows($rsBlog); mysql_select_db($database_heading1, $heading1); $query_rsOtherBlogs = \"SELECT * FROM blogent INNER JOIN topics ON idtop_blogent = id_top WHERE id_blogent <> \'$query_rsBlog\' ORDER BY id_blogent DESC\"; $rsOtherBlogs = mysql_query($query_rsOtherBlogs, $heading1) or die(mysql_error()); $row_rsOtherBlogs = mysql_fetch_assoc($rsOtherBlogs); $totalRows_rsOtherBlogs = mysql_num_rows($rsOtherBlogs);[/span][!--PHP-Foot--][/div][!--PHP-EFoot--] If anyone could educate me on this I would appreciate it.
×
×
  • 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.