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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:17:16+00:00 2026-05-26T06:17:16+00:00

I have the following image list on an html page that I am converting

  • 0

I have the following image list on an html page that I am converting into php to be driven from a mysql database. While I thought it was a simple enough procedure -I am struggling to avoid syntax errors because of the existing use of ‘ in my code.

I need to convert a simple list of images into an array based on what is in the database. The html list is:

<li><a  href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: './imgProd/2.jpg',largeimage: './imgProd/2.jpg'}">
<img src='imgProd/2.jpg' style="width:110px; height:110px;"></a></li>

<li><a  href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: './imgProd/3.jpg',largeimage: './imgProd/3.jpg'}">
<img src='imgProd/3.jpg' style="width:110px; height:110px;"></a></li>

<li><a  href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: './imgProd/4.jpg',largeimage: './imgProd/4.jpg'}">
<img src='imgProd/4.jpg' style="width:110px; height:110px;"></a></li>

I am trying to generate this from php using:

 <?php

$result = mysql_query("SELECT * FROM table WHERE id='$id'");
while($row = mysql_fetch_array($result))
{
    echo '<li>';
    echo '<a href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: './' . $row['photo'] . '',largeimage: './' . $row['photo'] . ''}">';
    echo '<img src=' . $row['photo'] . '' style="width:110px; height:110px;">';
    echo '</a>';
    echo '</li>';
}
?>

but am obviously getting loads of syntax errors as I am attempting to use single quotes within single quotes (I assume!?). Does anyone know how I can incoporate this list into an array??

Thanks very much in advance

JD

  • 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-05-26T06:17:16+00:00Added an answer on May 26, 2026 at 6:17 am

    Escaping the quotes is a bad idea.

    You can either simply close and reopen your <?php ?> tags or use Heredoc syntax.

    Using tags (PHP is a templating language, anything that isn’t between <?php ?> tags will be send to the client exactly as it is):

    <?php    
    $result = mysql_query("SELECT * FROM table WHERE id='$id'");
    while($row = mysql_fetch_array($result))
    {
    ?>
    <li>
    <a href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: './<?php echo $row['photo']; ?>',largeimage: './<?php echo $row['photo']; ?>'}">
    <img src='<?php echo $row['photo']; ?>' style="width:110px; height:110px;">
    </a>
    </li><?php
    }
    ?>
    

    Using Heredoc (the closing HTML; should be on its on line, unindented):

    <?php    
    $result = mysql_query("SELECT * FROM table WHERE id='$id'");
    while($row = mysql_fetch_array($result))
    {    
        echo <<<HTML
        <li>
        <a href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: './{$row['photo']}',largeimage: './{$row['photo']}'}">
        <img src='{$row['photo']}' style="width:110px; height:110px;">
        </a>
        </li>
    HTML;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JavaScript to get a random image from a list of
I have list page to show all images with its name from database in
I have the following CSS .ul{ list-style-image:url(/images/bullet.png) } My bullet.png is 20 x 20px
We suppose that we have the following image (is a single file with 4
I have a header within the following html page and I can't get the
I have the following jquery-code: <script type=text/javascript> $(document).ready(function() { $ ('ul.image-list li:even').addClass ('even'); $
I have the following code to show me a custom list with images and
I have the following jQuery which I want to output a list of images.
The following image have been uploaded to show what I am trying to do
I have the following code: Image tmpimg = null; HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url); HttpWebResponse

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.