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 8856079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:16:44+00:00 2026-06-14T14:16:44+00:00

Hey Stack Overflowians, I have a beginners problem for PHP which I’ve not had

  • 0

Hey Stack Overflowians,

I have a beginners problem for PHP which I’ve not had too much luck searching for so I thought I’d ask.

The problem is a slight alteration of my past post which you can find via my profile (since it’s my only one) where I’m trying to print data out of a database in a loop but also trying to wrap HTML around it.

In my example here, I’m trying to print the test line in my database which happens to be a style code of KO278 so that as well as printing the style code, it also prints it inside of an img src so the img of that item is printed as well but I’m not having much luck so far.

I thought perhaps some concatenation might work since I haven’t used it much but my attempt at it didn’t give me much of a result but perhaps my formatting could be off?

Anyway, I’m hoping you could aim me in the right direction.

Thanks!

Also, on a sidenote, I was thinking about if it would be possible for a small image of each colour (jpgs as they are more like patterns) to appear in place of the word of the colour but I don’t see how I could link that up.

Some products have both mixed colours (so different jpgs of them crossing over) or up to 8 colours so I wouldn’t know how to account for that much variability short of having a heap of fields in my database which doesn’t seem very efficient. It’s not that important but it’d be nice if anyone has any suggestions on how I might go about this?

<?php

$sql = "SELECT * FROM mc16koruproducts where collection = 'womens' order by ref";
    $result = pg_exec($sql);
    $nrows = pg_numrows($result);
    #print $nrows;
    $items = pg_fetch_all($result);
    #print_r($items);

    $type = '';

    for ($i=0; $i<$nrows; $i++) {
    if($items[$i]['type']!=$type)
    {
        print "<h2>";
        print $items[$i]['type'];
        print "</h2>";
        $city = $items[$i]['city'];
    }

    print "<div id='info-holder'>";
        print "<div id='img'>";
        print "<img src='products/";
            print $items[$i]['style'];
        print ".jpg />";
    print "</div>";
    print "<div id='style'>";
        print "Style ";
        print $items[$i]['style'];
    print "</div>"; 
    print "<div id='desc'>";
        print $items[$i]['desc'];
    print "</div>";
    print "<div id='size'>";
        print "Sizes: ";
        print $items[$i]['size'];
    print "</div>";
    print "<div id='colour'>";
        print "Colours Available: ";
        print $items[$i]['colour'];
    print "</div>";
    print "<br />";
    print "<br />";
    print "</div>";
?>      
  • 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-14T14:16:45+00:00Added an answer on June 14, 2026 at 2:16 pm

    I think the problem might be that you’re missing a closing single quote after .jpg

    print "<img src='products/";
    print $items[$i]['style'];
    print ".jpg />";
    

    Should be

    print "<img src='products/";
    print $items[$i]['style'];
    print ".jpg' />";
    

    I hope that helps. If not just let me know and I’ll dig deeper.

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

Sidebar

Related Questions

hey guys having this really simple problem but cant seem to figure out have
Hey all... I have a view controller (A) which on some action, alloc init's
Hey there code warriors and stack exchangers. I have been trying in vain to
Hey guys, I have this great scripts someone on stack overflow helped me out
hey , I have a problem with updating a record using a domain service,
Hey php gurus. I'm running into some bizarre class scope problems that clearly have
Hey fine folks of Stack Overflow. I have a bunch of unnested, unordered list
Hey all! Having a little trouble with my stack. Im trying to print each
Hey i have been looking around and i cant find a way to get
*Hey , I have finished developing my app In my iphone apps I have

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.