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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:01:15+00:00 2026-05-18T05:01:15+00:00

Please look at the code below. require_once(initvars.inc.php); require_once(config.inc.php); ?> <?php if($latestads_count) { ?> <div

  • 0

Please look at the code below.

require_once("initvars.inc.php");
require_once("config.inc.php");

?>
<?php
if($latestads_count)
{
?>


<div class="latestposts">

<div class="head"><?php echo $lang['LATEST_ADS']; ?></div>


<table border="0" cellspacing="0" cellpadding="0"  class="postlisting" width="100%">


<?php
$sql = "SELECT a.*, ct.cityname, UNIX_TIMESTAMP(a.createdon) AS timestamp, feat.adid      AS isfeat,
            COUNT(*) AS piccount, p.picfile AS picfile, scat.subcatname, scat.catid, cat.catname
        FROM $t_ads a
            INNER JOIN $t_cities ct ON a.cityid = ct.cityid
            INNER JOIN $t_subcats scat ON a.subcatid = scat.subcatid
            INNER JOIN $t_cats cat ON scat.catid = cat.catid
            LEFT OUTER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'A' AND feat.featuredtill >= NOW()
            LEFT OUTER JOIN $t_adpics p ON a.adid = p.adid AND p.isevent = '0'
        WHERE $visibility_condn
            $loc_condn
        GROUP BY a.adid
        ORDER BY a.createdon DESC
        LIMIT $latestads_count";
$res_latest = mysql_query($sql) or die($sql.mysql_error());

$css_first = "_first";
while($row = mysql_fetch_array($res_latest))
{

    $url = buildURL("showad", array($xcityid, $row['catid'], $row['catname'], 
        $row['subcatid'], $row['subcatname'], $row['adid'], $row['adtitle']));


?>

    <?php 
    if($row['isfeat'])
    {
        //$feat_class = "class=\"featured\"";
        $feat_img = "<img src=\"images/featured.gif\" align=\"absmiddle\">";
    } 
    else 
    { 
        //$feat_class = "";
        $feat_img = "";
    }

    if($row['picfile']) 
    {
        $picfile = $row['picfile'];
        $imgsize = GetThumbnailSize("{$datadir[adpics]}/{$picfile}", $tinythumb_max_width, $tinythumb_max_height);
    }
    else 
    {
        $picfile = "";
    }
    ?>

    <tr>
        <td width="15">
        <img src="images/bullet.gif" align="absmiddle">
        </td>

        <td>
        <b><a href="<?php echo $url; ?>" <?php echo $feat_class; ?>><?php echo $row['adtitle']; ?></a></b> 
        <?php if(0&&$row['picfile']) { ?><img src="images/adwithpic.gif" align="absmiddle"><?php } ?>
        <?php echo $feat_img; ?><br>


        <span class="adcat">



        <?php echo "$row[catname] $path_sep $row[subcatname]"; ?>



        <?php 
        $loc = "";
        if($row['area']) $loc = $row['area'];
        if($xcityid < 0) $loc .= ($loc ? ", " : "") . $row['cityname'];
        if($loc) echo "<br>$loc";
        ?>             

        </span>



        </td>

        <td  align="right" width="<?php echo $tinythumb_max_width; ?>">
        <?php if($picfile) { ?>
        <a href="<?php echo $url; ?>"><img src="<?php echo "{$datadir[adpics]}/{$picfile}"; ?>" border="0" width="<?php echo $imgsize[0]; ?>" height="<?php echo $imgsize[1]; ?>" style="border:1px solid black"></a>
        <?php } ?>
        </td>

    </tr>

This is one of the code files from an existing project. As you can see, it has html, sql, php all intermixed together… and obviously difficult to maintain.

There are around 55 files of similar size and type in this application.

I want to refactor this code,and below are my objectives for doing so:

1)Easy to maintain.

2)Be able to extend easily by adding additional features.

3)Be able to reuse this code for different but somewhat similar applications.

I have a number of question based on the above facts:

1) Do you think we can refactor this code into an mvc application?

2)If we can. how much time should it take to refactor the whole project(55 files) say, for an expert programmer?

3)Should i reuse the above code, or should i start from scratch with a existing mvc framework?

4)How much time do we need to complete the whole project, in case we go for an existing mvc framework say symfony, zend etc.?

5)This site as per my knowledge until now would run Mysql only(as the current db is done in mysql). Should we allow for data abstraction/data acces layers in the model(supposing there is something that performs better than Mysql, I’m not sure about this)

7)Can we easily refactor the code to include sub-layers for model(data abstraction/access), view(further templates, view logic etc.), controller etc. in case we want to do that in future or would we need to start from scratch?

8)Is mvc the way to go , or is there a better pattern/way than it(supposing the site is intended for hundred thousands of users)?

  • 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-18T05:01:16+00:00Added an answer on May 18, 2026 at 5:01 am
    1. Yes.
    2. I would say about an hour per file of that size to make sure everything goes smoothly. So 1-2 weeks of solid work.
    3. If this works well, just re-factor. If you really want something new, grab a framework.
    4. An existing framework will probably take longer to duplicate existing functionality (maybe a month). However, you will have a more stable application in the long run (most likely).
    5. There is nothing wrong with MySQL. Use a data abstraction layer if you feel like you will want to switch in the future for some other reason.
    6. There is no reason why you wouldn’t be able to re-factor. I have done this recently and it is not all that difficult.
    7. MVC is pretty much ideal. That said, there are many different ways to do MVC. Some good, some better, some terrible.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please look through code below: // A.class File file = new File(blah.txt); FileWriter fileWriter
Please look at the code below and help me to figure out what am
Please look at the code below and suggest the best approach. I can't quite
Please take a look at the html listed below and let me know why
I have just started to look at .NET 3.5 so please forgive me if
Please consider this example class: [Serializable] public class SomeClass { private DateTime _SomeDateTime; public
Please explain to me why the very last echo statement is blank? I expect
Have a look at the following code you are not required to read the
Please suggest some good resources to start writing Java Web services.
Please read the whole question. I'm not looking for an approach to managing multi-lingual

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.