Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7842411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:18:56+00:00 2026-06-02T16:18:56+00:00

i have a PHP/mySQL question related to virtuemart ecommerce – I’ve asked on the

  • 0

i have a PHP/mySQL question related to virtuemart ecommerce – I’ve asked on the VM forum but the response is very slow.

I’m using this code to load products from the same category in a product page, its works well but;

<?php   // find all the other products in this category
$q = "SELECT p.product_id, p.product_name, c.category_name, c.category_flypage
   FROM #__{vm}_product p,#__{vm}_product_category_xref pc, #__{vm}_category c
   WHERE p.product_publish='Y' AND pc.product_id = p.product_id AND pc.category_id = c.category_id AND c.category_id = '$category_id' AND p.product_id != '$product_id'
   ORDER BY p.product_name ";
$db = new ps_DB;
$db->query( $q );
if( $db->next_record() )  {
   echo 'Other products in the category "'.$db->f('category_name').'"<br />';
   $flypage = $db->f('category_flypage');
   $db->reset();
   while( $db->next_record() ) {
      ?><a href="<?php  $sess->purl(URL . "index.php?page=shop.product_details&flypage=$flypage&product_id=" . $db->f("product_id") . "&category_id=$category_id" ) ?>"><?php $db->p("product_name"); ?></a><br />
      <?php
   }
}
?>

But, I cant substr the output of the product name, if I put <?php substr($db->p("product_name"), 0 12) ?> the substr is completely ignored and the whole name is still output – any one know why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:18:58+00:00Added an answer on June 2, 2026 at 4:18 pm

    I suspect that $db->p prints the name directly, instead of returning it. You’re also missing an echo before substr... The code should probably look like this:

    <?php echo substr($db->f('product_name'), 0, 12) ?>
    

    Here I assumed that $db->f returns the value of the field, given how it’s used in the rest of the code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The only similar question I have found is: Insert php boolean into mysql bit
Further to my previous question about salted passwords in PHP/MySQL , I have another
I have asked this question earlier today but I didn't provide enough information and
I have a question regarding the proper workflow of git in a PHP/MySQL workflow.
I have a PHP/mySQL search script that for some reason, after the latest update
We have a PHP/MYSQL application that collects user input, including special characters like ø,ü,ñ,
I have a php/mysql poll that I'm trying to modify. It sets a unique
I have a PHP/MySQL query that returns to an HTML table, and I'm stuck
I have a legacy PHP/MySQL app that calls mysql_connect(). Tons of existing downstream code
I have this piece of php - mysql code: When a user tagged in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.