Page 1 of 1

How to clear a page, or refresh a page content.

Posted: Thu Mar 06, 2008 4:17 am
by jpmad4it2
Mod | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Hi there

This is a bit of a strange issue, well it is to me being a newbie lol.

I'll start with my code:

Code: Select all

<?
      $num=3;
      $width=100/$num;
      $cnt=0;
      
      $items="<table border='0' cellpadding='0' cellspacing='0' align='center'><tr>";
      $taa=0;
      
      if(mysql_num_rows($online_sql) > 0) {
          while ($online = mysql_fetch_array($online_sql)) {
            $taa++;
            if ($cnt==$num){
                $items.="</tr><tr>";
                $cnt=0;
            }
 
            $items.="<td style='padding-bottom:20px; padding-right:20px;'>
                        <table class='border' bgcolor='#000000'>
                            <tbody>
                                <tr>
                                    <td style='height:190px;'><a href='".processLink($online["product_id"], $online["name"])."'><img alt='".$online["name"]."' border=0 src='makethumb.php?pic=product_images/".$online["filename"]."&w=122&sq=N' /></a><br /><div align='center'><a href='".processLink($online["product_id"], $online["name"])."'>".$online["name"]."</a>
                                    </td>
                                </tr>
                        </tbody>
                  </table>
                  </td>";
             $cnt++;
 
             $items.="</tr></tbody></table>";
             print $items;
    }
    } else {
        print "<center>We're sorry, but no one is online </center>";
}
?>
      <?  
        if (!isset($_GET["id"])) $_GET["id"]='';
        if ($_GET["id"]!=''){
        require "profiles.php";
            } else {
            $engine->load(); 
        }
    ?>
This code is contained in my index.php file. What it does is grab the data from the database to display pictures of people who are online. It also creates a link over the image, which once clicked loads up that persons profile.

I think that the profile is loaded by this code: $engine->load(); which is shown in the above code. I think it calls a module and essentially includes a PHP file (which holds the profile for the person). The link to the profile is in this format: http://www.mysite.com/JONATHAN,217. I guess that its getting the user name and ID?

The problem is that the profile is being loaded directly into the index.php file underneath all the images. What I need to do is try to clear the images first, and then load the profile, all within the index.php page, or on a separate page. It just looks a mess when the profile is loaded underneath the images.

I tried to add some kind of page counter, but realised that wouldn't work. Could I not add the above code to the link that is processed using 'onclick' and call a separate file called user_profile.php? My problem is getting the data into a link format using PHP. Or maybe use the $engine->load(); within the link?

Or does anyone have any better ideas? I'm sure there must be something else I can do, for example, is there no function to load a php file in the else statement, or redirect to another file?

Any help would be great.

kind regards
Jonathan


Mod | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: How to clear a page, or refresh a page content.

Posted: Thu Mar 06, 2008 9:09 am
by Sekka
At line 8, place the following code

Code: Select all

if (!isset ($_GET["id"]) || (isset ($_GET["id"]) && $_GET["id"] == '')){
After line 34, insert another close curly brackets,

Code: Select all

}
This ensures that the online people generation is only run when no profile ID is supplied.

Hope this helps!

Re: How to clear a page, or refresh a page content.

Posted: Thu Mar 06, 2008 9:21 am
by jpmad4it2
Hey thanks!

That didn't work though, I'm getting this error:

Parse error: syntax error, unexpected T_ELSE in /homepages/33/d235031006/htdocs/index.php on line 32

I moved the closing parenthesis above the } else { statment and the page loaded fine, yet upon clicking the images the profile is still loaded directly beneath all the images :(

Any ideas?

EDIT: its going to be best if I can load the module (which is just a php file) in a separate page I think, so then I can edit that page as I wish. The problem is loading the file into the index page. Is there a way I can say

$engine->load(); INTO this.php page?

Do you need to see the load() function?