Page 1 of 1

A very puzzling challenge - Please Help

Posted: Mon Dec 28, 2009 2:32 am
by ricky-ham
Hi there I am new to this forum just signed up. I have been trying to learn php for a short while no and trying to sort this piece of code out.

I have this code originally;


Code: Select all

<?
include_once('oticos_config.php');
 
function hiVis($name, $start, $items, $cols, $sql, $markup, $blankmarkup='') {
 
$sql .= " LIMIT $start, $items";
$i = $items;
$rowname=$name; 
 
 
$result = mysql_query($sql);
 
$nrows = mysql_num_rows($result);
 
if ($nrows < $items) $items = $nrows; 
 
?>
<table class='<?=$name?>' width='100%'>
<?
 
while ($$rowname=mysql_fetch_assoc($result)) {
 
$m = $$rowname;
 
// This is responsible for getting the tags from the database and getting them ready to be displayed
 
if (isset($m['GameID'])){
    $q1 = "SELECT Name FROM `_tegsLog` LEFT JOIN _tegs USING ( idTeg ) WHERE _tegsLog.GameID = '$m[GameID]' ";
    $res1 = mysql_query( $q1 );     
    
    if( 0 == mysql_num_rows( $res1 ) ) {
        $tegAll = '';               
    }else{
        $tegAll = array();
        while ($tegs = mysql_fetch_assoc($res1)) 
        {
            $tegAll[].= $tegs['Name'];
        }
        $tegAll = implode(', ',$tegAll);
    }
$m['tegs'] = $tegAll;
}
    
// This is responsible for getting the name of the person that uploaded a particular game and getting it ready to be displayed
 
if (isset($m['AccountID'])){
    if ( $m['AccountID'] !=0 ){
        $q2 = "SELECT concat(firstname,' ',lastname) as fullName FROM `_account` WHERE idUser = '$m[AccountID]' ";
        $res2 = mysql_query( $q2 );     
        $from = mysql_fetch_assoc($res2);
    }else{
        $from['fullName'] = '';
    }
$m['from'] = $from['fullName'];
}   
 
$$rowname = $m;
 
//$the_markup = $markup;
eval ("\$the_markup =\"$markup\";");
 
 
    if($i % $cols == 0){ 
?> 
        <tr class='cols<?=$name?>'>     
<?
    }
?>
            <td class='item<?=$name?>'>
                <?=$the_markup?>
            </td>
<? 
    if($i % $cols == $cols-1){ 
?> 
        </tr>       
<?
    }
$i++;
}
 
if($i % $cols !== 0){
?> 
            <td colspan=<?=$cols-($i % $cols)?> class='blank<?=$name?>'>
                <?=$blankmarkup?>
            </td>
        </tr>
 
<?
}
?>
</table>
<? 
} 
?>








Code: Select all

<?
include_once('hiVis.php');
$ratingAnonim = <<<EOT
<div id='rating' style='width: 80px;margin-left: 45px;'>
        <ul class='star-rating'>
            <li class='current-rating' id='current-rating' style='margin: 0px ! important; background: transparent url(images/star/alt_star.gif) repeat scroll left center ! important; width: {\$oticos_rand['Rating']}px; -moz-background-clip: -moz-initial ! important; -moz-background-origin: -moz-initial ! important; -moz-background-inline-policy: -moz-initial ! important; left: 0px ! important;'></li>
        </ul>
    </div>
EOT;
$ratingUse = <<<EOT
<div id='rating_rand{\$oticos_rand['GameID']}' style='width: 80px;margin-left: 45px;'>
        <ul class='star-rating'>
            <li class='current-rating' id='current-rating' style='margin: 0px ! important; background: transparent url(images/star/alt_star.gif) repeat scroll left center ! important; width: {\$oticos_rand['Rating']}px; -moz-background-clip: -moz-initial ! important; -moz-background-origin: -moz-initial ! important; -moz-background-inline-policy: -moz-initial ! important; left: 0px ! important;'></li>
            <span id='ratelinks_rand{\$oticos_rand['GameID']}' class='rate_no{\$oticos_rand['canRate']}'>
            <li><a href='#' onclick='sendRating(1,\"{\$oticos_rand['GameID']}\",$account[idUser],\"rating_rand{\$oticos_rand['GameID']}\");return false;' title='1 star out of 5' class='one-star'>1</a></li>
            <li><a href='#' onclick='sendRating(2,\"{\$oticos_rand['GameID']}\",$account[idUser],\"rating_rand{\$oticos_rand['GameID']}\");return false;' title='2 stars out of 5' class='two-stars'>2</a></li>
            <li><a href='#' onclick='sendRating(3,\"{\$oticos_rand['GameID']}\",$account[idUser],\"rating_rand{\$oticos_rand['GameID']}\");return false;' title='3 stars out of 5' class='three-stars'>3</a></li>
            <li><a href='#' onclick='sendRating(4,\"{\$oticos_rand['GameID']}\",$account[idUser],\"rating_rand{\$oticos_rand['GameID']}\");return false;' title='4 stars out of 5' class='four-stars'>4</a></li>
            <li><a href='#' onclick='sendRating(5,\"{\$oticos_rand['GameID']}\",$account[idUser],\"rating_rand{\$oticos_rand['GameID']}\");return false;' title='5 stars out of 5' class='five-stars'>5</a></li>
            </span>
        </ul>
    </div>
EOT;
 
 
if( $account['role'] =='anonymous' ){ 
    $zapros = "SELECT * , IFNULL((Rating*15),0) As Rating, 'null' AS canFav  FROM _games ORDER BY RAND()";
    $rating = $ratingAnonim;
}else{
    $zapros = "SELECT *,IFNULL((Rating*15),0) As Rating, (SELECT count(_rating.GameID) as canRate FROM _rating WHERE idUser=$account[idUser] AND GameID=_games.GameID) as canRate, (SELECT count(_favorites.GameID) as canFav FROM _favorites WHERE idUser=$account[idUser] AND GameID=_games.GameID) as canFav FROM _games ORDER BY RAND()";
    $rating = $ratingUse;
}
$display = <<<EOT
<table border='0' cellpadding='0' cellspacing='0' height='78' width='100%'>
      <tbody><tr>
                <td align='center' height='78' valign='top' width='126'>
                        <table>
                             <tbody><tr>
                                <td align='center' background='images/game_im_bg126x76.jpg' height='78' valign='middle' width='126'><a href='game_play.php?game={\$oticos_rand['GameID']}' ><img src='http://games.oticos.com/img.php?f({\$oticos_rand['GameID']}.jpg)+w(120)+h(72)+q(100)' alt='{\$oticos_rand['Name']}' ></a></td>
                              </tr>
                                </tbody>
                        </table>  
                </td>
 
      
        <td valign='top'><table border='0' cellpadding='0' cellspacing='0' width='100%'>
            <tbody><tr>
              <td width='10'>&nbsp;</td>
              <td class='style25' height='20' width='200'><a href='game_play.php?game={\$oticos_rand['GameID']}' >{\$oticos_rand['Name']}</a></td>
            </tr>
            <tr>
              <td height='56' width='10' id='favorites_rand{\$oticos_rand['GameID']}'>
                                <a href='#' class='favorites fav_{\$oticos_rand['canFav']}' onclick='sendFav({\$oticos_rand['canFav']},\"{\$oticos_rand['GameID']}\",$account[idUser],\"favorites_rand{\$oticos_rand['GameID']}\");return false;'></a>
                            </td>
              <td height='56' valign='top' class='style_tegs'>
                                {\$oticos_rand['tegs']}
                                <A href='game.php?game={\$oticos_rand['GameID']}'>Game Discription</A>
                            </td>
            </tr>
        </tbody></table></td>
        <td width='150'><table border='0' cellpadding='0' cellspacing='0' height='75' width='100%'>
            <tbody><tr>
              <td rowspan='4' class='style24' background='images/line_up.jpg' height='75' width='10'>&nbsp;</td>
              <td class='style24'>Added: <span class='style28'>
EOT;
$display .= '" . date(\'m/d/y\', strtotime( $oticos_rand[\'Date\'] )) . "</span>';
$display .= <<<EOT
                        </td>
            </tr>
            <tr>
              <td class='style24'>From: <span class='style32'>{\$oticos_rand['from']}{\$oticos_search['Origin']}</span></td>
            </tr>
            <tr>
              <td class='style24'>Played: <span class='style29'>{\$oticos_rand['Clickthrough']}</span></td>
            </tr>
            <tr>
              <td class='style24'>
                            <span style='float: left;'>Ratings: </span>
EOT;
$display .= $rating;
$display .= <<<EOT
                            </td>
            </tr>
        </tbody></table></td>
      </tr>
    </tbody>
</table>
<div class='dotted' ></div>
EOT;
 
 
hiVis("oticos_rand", 0, $count, 1, $zapros, $display);
?>


AND I want to change it to allow the use of this, which is some css and html code;

Code: Select all

<div class="game_view_layout">
                
                    <div class="game_image_view">
                    
                            <div class="game_image">
                            
                            <img src="images/img67.jpg" alt="" width="120" height="72" />
                            
                            </div>
                    
                    </div>
                
                                <div class="game_text_holder">
                                
                                      <div class="game_name">
                                      
                                        <p> Emo Cupid </p>
                                        
                                      </div>
                                  
                                  <div class="game_description">
                                  
                                    <p>Cupid  Has Gone Emo. Dress Up The Emo Version Of Cupid Choosing From Many Different  Types Of Clothes And Accessories. Remember To Give Cupid Her Bow...</p>
                                    
                                  </div>
                                  
                                  <div class="game_details">
                                  
                                    <p> Ratings   12/23/09   1,000 views <span>Admin</span></p>
                                    
                                  </div>
                                  
                               </div>
                  
                </div>



Please Help If you could thanks :D I just looked over it and it looks very long lol but each one is a different file and they link together. I am sooooooo confused. One more not the 2 chunchs of code above actually works but its not very good

Re: A very puzzling challenge - Please Help

Posted: Mon Dec 28, 2009 2:40 am
by kalidG
your code contain some error
kindly wrap your code tag in "[ code ] " so we can see the code clearly and help to give you the specific place for the error
thank you,

khaled

Re: A very puzzling challenge - Please Help

Posted: Mon Dec 28, 2009 2:52 am
by ricky-ham
I cant believe how fast you commented thanks : )

Re: A very puzzling challenge - Please Help

Posted: Mon Dec 28, 2009 7:25 am
by kalidG
this code for what?

Re: A very puzzling challenge - Please Help

Posted: Mon Dec 28, 2009 7:52 am
by omniuni
OK, the third file doesn't have any PHP in it, it's just HTML. That means there can't be a parsing error, per se. If you want to use that code in the place of some of the output in one of the files with PHP, then simply copy and paste, and then escape the appropriate characters. As long as you're using a text editor with syntax highlighting, it should let you know which characters to escape.

Besides that, I'll reiterate the last question asked; what's the code for? If you can give us a bit more information, it will help us troubleshoot the problem.

Re: A very puzzling challenge - Please Help

Posted: Mon Dec 28, 2009 12:14 pm
by ricky-ham
Thanks guys for you reply. This code is used on my site to display a list of game details such as date, image, rating.

There is some more code but this is the main 2 that produce the outcome wished. I also know that the last block of code is html. I tried to put it in variable and then print it to the screen.

Using;

<<<EOT



EOT;

But that did not work.

Re: A very puzzling challenge - Please Help

Posted: Mon Dec 28, 2009 2:30 pm
by omniuni
Hm, this should work:

Code: Select all

$myHTML = <<<ENDHTML
<span>My HTML Code Here</span>
ENDHTML;
 
echo $myHTML;
 

Re: A very puzzling challenge - Please Help

Posted: Mon Dec 28, 2009 3:16 pm
by ricky-ham
Ok thanks thats great it works to print the html to the screen but it does not incorporate the php elements. I have more code that may help but i dont want to over whelm anyone with some random set of codes lol. I will re edit the code and put it up. :D

Re: A very puzzling challenge - Please Help

Posted: Mon Dec 28, 2009 8:29 pm
by bjazmoore
It is hard to get a grasp as to how you desire all this to fit together. Do I understand that you have various "chucks" of code, but are not sure how to intergrate them? How about the include files. Can you post these also. It would be nice if you had it all in one file the way you think it actually goes together.

Bjaz

Re: A very puzzling challenge - Please Help

Posted: Mon Dec 28, 2009 9:00 pm
by ricky-ham
That is the 2 main chunks of code. What I can do is to better explain what i am trying to do. I have added to images of before and after results.

Well I have a site that I am currently updating and I want to change the layout of the way it list some of the items.
The 1st and 2nd block of code is really it. The include file(oticos_config.php) is only used to conntect to the mysql database. The second code is linked to the 1st.

I have tried sooo many different ways over many days and still no result i get error messages once uploaded. So i am trying to change the display.

Again thanks to every one who has commented so far. U lot are really cool :D

Re: A very puzzling challenge - Please Help

Posted: Tue Dec 29, 2009 1:48 am
by omniuni
OK, so, I thought that include sounded a bit odd. I'd never heard of a CMS by that name, so I Googled it.

My guess would be that you're trying to update http://www.oticos.com/?

Now, the website appears to be working, so can you link us to an exact page that you want to modify, and explain how?

Are you actually trying to change the information that is displayed, or simply HOW it is being displayed?

Re: A very puzzling challenge - Please Help

Posted: Tue Dec 29, 2009 2:26 am
by ricky-ham
Just how it is displayed. I have theses two links for you. This is how it should look lol http://www.oticos.com/oticosnewlayout_BACKUP.php and this is how it is now http://www.oticos.com/ Just the list on the left.

I cant really link to the php pages that does it because it wont display anything to the screen as they have not been set to echo out anything.

Re: A very puzzling challenge - Please Help

Posted: Fri Jan 01, 2010 2:38 am
by ricky-ham
I REALLY want to thank every one that has replied and I have finally figured out the problem. You would not believe it. Basically on the css code the double speech marks messed with the php elements. So to fix it all I had to do was replace them with a single one.

Example: <div class="test"> would need to be changed to <div class='test'>

I really cant believe it took many weeks to solve.

Re: A very puzzling challenge - Please Help

Posted: Fri Jan 01, 2010 3:20 am
by omniuni
That's not particularly nice HTML. Did you try simply escaping the double-quotes? (\")

Re: A very puzzling challenge - Please Help

Posted: Mon Jan 11, 2010 9:20 am
by ricky-ham
sorry for the late reply i don't get to do much coding now adays. Thanks for your response I will be trying that out. : )