Zen Cart Logo
Forums / General Questions / zencart mysql and php help needed

zencart mysql and php help needed

Locked

Views: 1,538

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
5 Jan 2009, 4:11 PM
#1
kitcorsa avatar

kitcorsa

Totally Zenned

Join Date:
Feb 2007
Posts:
1,724
Plugin Contributions:
0

zencart mysql and php help needed

im making an addon to the site which is an image scrolling slideshow which can be added to any page within zencart.

This mod will take the images and links from the featured items.

Their is no mod like this in the download section or seaching on the net so im going to have to make on my self. Im bound to run into some problems so will be asking for help in here.

so who is good with the mysql working of zencart??

5 Jan 2009, 4:41 PM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: zencart mysql and php help needed

The SQL would be the same as is used for the featured products sidebox, except that you might want to change the number of products extracted.

5 Jan 2009, 4:57 PM
#3
kitcorsa avatar

kitcorsa

Totally Zenned

Join Date:
Feb 2007
Posts:
1,724
Plugin Contributions:
0

Re: zencart mysql and php help needed

cheers for that, now i just need to get it to output in a in a way to for the scolling javascript code to work.

5 Jan 2009, 5:03 PM
#4
kitcorsa avatar

kitcorsa

Totally Zenned

Join Date:
Feb 2007
Posts:
1,724
Plugin Contributions:
0

Re: zencart mysql and php help needed

does the standard code only show one item in the featured item box??

<?php
/**
 * Side Box Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license [URL]http://www.zen-cart.com/license/2_0.txt[/URL] GNU Public License V2.0
 * @version $Id: tpl_featured.php 6128 2007-04-08 04:53:32Z birdbrain $
 */
  $content = "";
  $featured_box_counter = 0;
  while (!$random_featured_product->EOF) {
    $featured_box_counter++;
    $featured_box_price = zen_get_products_display_price($random_featured_product->fields['products_id']);
    $content .= '<div class="sideBoxContent centeredContent">';
    $content .=  '<a href="' . zen_href_link(zen_get_info_page($random_featured_product->fields["products_id"]), 'cPath=' . zen_get_generated_category_path_rev($random_featured_product->fields["master_categories_id"]) . '&products_id=' . $random_featured_product->fields["products_id"]) . '">' . zen_image(DIR_WS_IMAGES . $random_featured_product->fields['products_image'], $random_featured_product->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); 
    $content .= '<br />' . $random_featured_product->fields['products_name'] . '</a>';
    $content .= '<div>' . $featured_box_price . '</div>';
    $content .= '</div>';
    $random_featured_product->MoveNextRandom();
  }
?>

i need to to output more than one item image and these need to be wrapped like so

leftrightslide[0]='<a href="[URL]http://link to product"><img[/URL] src="image.gif" border=0></a>'
leftrightslide[1]='<a href="[URL]http://ling to product"><img[/URL] src="image.gif" border=0></a>'
leftrightslide[2]='<a href="[URL="http://ling%20to%20product%22%3e%3cimg/"]http://ling to product"><img[/URL] src="image.gif" border=0></a>'
5 Jan 2009, 5:05 PM
#5
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: zencart mysql and php help needed

No. There's a while loop in there allowing the code to display as many products as were pulled from the database.

6 Jan 2009, 11:19 AM
#6
kitcorsa avatar

kitcorsa

Totally Zenned

Join Date:
Feb 2007
Posts:
1,724
Plugin Contributions:
0

Re: zencart mysql and php help needed

co i can edit the $content senction in the side box code so i can remove the div etc and add my own tags but how can i make it so if i say get 10 items from the features items how can i out put the code to include the leftrightslide[0]=' then for next image leftrightslide[1]=' the 2 3 4 etc ??

6 Jan 2009, 11:23 AM
#7
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: zencart mysql and php help needed

Move $featured_box_counter++; to the end of the while loop and use $content .= leftrightslide[$featured_box_counter]='

6 Jan 2009, 12:13 PM
#8
kitcorsa avatar

kitcorsa

Totally Zenned

Join Date:
Feb 2007
Posts:
1,724
Plugin Contributions:
0

Re: zencart mysql and php help needed

right i think i the code should be correct but need to ask, can php code be inside javascript??

also tried the script by added the javascript into the tmp_index_default but i just kills the page

6 Jan 2009, 12:19 PM
#9
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: zencart mysql and php help needed

kitcorsa:

right i think i the code should be correct but need to ask, can php code be inside javascript??
Yes. There's an explanation in the javascript readme in the docs folder that comes with each Zen Cart release package.
kitcorsa:

also tried the script by added the javascript into the tmp_index_default but i just kills the pageZen Cart has a proper javascript loading mechanism. You hack the code directly into pages at your own risk.

6 Jan 2009, 12:24 PM
#10
kitcorsa avatar

kitcorsa

Totally Zenned

Join Date:
Feb 2007
Posts:
1,724
Plugin Contributions:
0

Re: zencart mysql and php help needed

i removed the php from the javascript and the loaded but no images as their is nothing to output.

6 Jan 2009, 12:27 PM
#11
kitcorsa avatar

kitcorsa

Totally Zenned

Join Date:
Feb 2007
Posts:
1,724
Plugin Contributions:
0

Re: zencart mysql and php help needed

yep defo the php killing it, dropping the php into the tmp_index_default file kills it

6 Jan 2009, 12:44 PM
#12
kitcorsa avatar

kitcorsa

Totally Zenned

Join Date:
Feb 2007
Posts:
1,724
Plugin Contributions:
0

Re: zencart mysql and php help needed

dropping the php into the tmp_index_defalut file also kills it so i think the php has an error somewhere.

i read the readme file about on Js and tried as instructed and the the site never loaded all, and couldn't figger out how i would display the JS output were i wanted it on the page.

6 Jan 2009, 12:46 PM
#13
kitcorsa avatar

kitcorsa

Totally Zenned

Join Date:
Feb 2007
Posts:
1,724
Plugin Contributions:
0

Re: zencart mysql and php help needed

here is where i got to with the php.

<?php
  $content = "";
  $featured_box_counter = 1;
  while (!$random_featured_product->EOF);
  $featured_box_counter++; {
    $content .= 'leftrightslide[$featured_box_counter]=';
    $content .= '<a href="' . zen_href_link(zen_get_info_page($random_featured_product->fields["products_id"]), 'cPath=' . zen_get_generated_category_path_rev($random_featured_product->fields["master_categories_id"]) . '&products_id=' . $random_featured_product->fields["products_id"]) . '">' . zen_image(DIR_WS_IMAGES . $random_featured_product->fields['products_image'], $random_featured_product->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); 
    $content .= '</a>'';
    $random_featured_product->MoveNextRandom();
  }
?>