News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Yet another SSI question...

Started by tecsbrain, July 27, 2008, 10:19:21 PM

Previous topic - Next topic

tecsbrain

I would like to search for the answer to this but I don't know how to phrase it.  I have the following code included in my website:

<?php
$exclude 
= array('1','2','3','4','5','6','7','8','9','10','11','12','13','15','16','17','18');
$topics ssi_recentTopics(10$exclude'array');

   
$array ssi_boardNews(14.05null250'array');

   foreach (
$array as $news)
   {
      echo 
'
         <table border="0" width="100%" align="center" style="font-family:Arial, Verdana, Tahoma, sans-serif; font-size:10pt;">
            <tr>
               <td bgcolor="#DDDDDD"><b>'
$news['subject'], '</b></td>
            </tr>
            <tr>
               <td>'
$news['body'], '<br /></td>
            </tr>
         </table>
         '
;

 
/*     if (!$news['is_last'])
         echo '
         <hr width="100%" />
         ';*/
   
}


///foreach($topics as $topic)
///  echo $topic['subject'], '<br />';
 
?>


..with all the necessary PHP includes and start and end tags, etc.  It works great!

But I'd like to change the title to be a link to the thread as well, instead of just the title in plain text.  I copied the following from line 396 of SSI.php:

<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>

It doesn't return any errors but the only variable that is replaced is $scripturl -- nothing else is included in the URL.  I know I am doing something wrong, but I am at PHP/MySQL Level 1.5 and don't know what to do...any help is appreciated.

lordtron

#1
Alright here you go. This works, I tested it out on my site.

To see it in the works, click here


<?php
// Connects to your Database
$exclude = array('1','2','3','4','5','6','7','8','9','10','11','12','13','15','16','17','18');
$topics ssi_recentTopics(10$exclude'array');


   
$array ssi_boardNews(14.05null250'array');

   foreach (
$array as $news)
   {
      echo 
'
         <table border="0" width="100%" align="center" style="font-family:Arial, Verdana, Tahoma, sans-serif; font-size:10pt;">
            <tr>
               <td bgcolor="#DDDDDD"><b><a href="'
$news['href']. '">'$news['subject'], '</a></b></td>
            </tr>
            <tr>
               <td>'
$news['body'], '<br /></td>
            </tr>
         </table>
         '
;

 
/*     if (!$news['is_last'])
         echo '
         <hr width="100%" />
         ';*/
   
}


///foreach($topics as $topic)
///  echo $topic['subject'], '<br />';
 
?>




VainSoftGames.com - New Design To Gaming

ccbtimewiz

#2
I've cleaned it up a bit, if you wish for it.

<?php
# Connections
$exclude = array('1','2','3','4','5','6','7','8','9','10','11','12','13','15','16','17','18');
$topics ssi_recentTopics(10$exclude'array');
$array ssi_boardNews(14.05null250'array');

   foreach (
$array as $news)
   {
      echo 
'
         <table border="0" width="100%" align="center" style="font-family: Arial, Verdana, Tahoma, sans-serif; font-size: 10pt;">
            <tr>
               <td style="background-color: #dddddd;"><strong><a href="'
$news['href']. '" target="_self">'$news['subject'], '</a></strong</td>
            </tr>
            <tr>
               <td>'
$news['body'], '<br /></td>
            </tr>
         </table>
         '
; }
 
?>


lordtron

Did you ever think that maybe he might have other code in that and he should us only what he wanted us to see. Plus maybe he needed those Commented areas in there for later use.
He never asked for the code to be cleaned or anything, just for us to find out how to get it working.

VainSoftGames.com - New Design To Gaming

ccbtimewiz

The less code, the faster performance. Also, I fixed a couple (x)HTML errors and spaced it a bit better. The way it was coded would have resulted in some (x)HTML problems.

If he wanted to keep the commented code in it, he obviously still has the code he used in the first post. ^^;

lordtron

There where no HTML errors in the code.

And I tested the code in Firefox, Safari, IE, Opera and no problems what so ever in any of them.
And plus if he took out the Comments, my code would be less code, so mine would load faster than yours then.

VainSoftGames.com - New Design To Gaming

ccbtimewiz

#6
The "bgcolor" tag is depricated, and hex should be in lowercase at all times. Bold tags should be replaced with strong tags as well.

Not really big problems, but it's how the W3C teaches it.

Regardless, both code suggestions work fine. It's really up to tecsbrain to modify the code to his liking for his website.  I just offered a cleaner method, hence I said "if you wish it". :)

tecsbrain

Thanks gentlemen for your help.  I copied that code from a tutorial around here or in SMF world that included the deprecated tags, though.  If I could remember where it was........

metallica48423

guys, theres no need to argue over semantics of the whole ordeal.  you both helped out and thats whats important :)
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Advertisement: