Jump to content

show records horizontal: syntax error, unexpected T_STRING


flyboeing

Recommended Posts

Hello all,

 

I am a little confused about the following thing. For my website I am making a php/mysql script that shows information from the DB. Normaly it is shown vertical, but I want it horizontal, just 4 at one row, than the next row. I found a piece of code and try to work with that:

 

<?php
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
if ($option=="com_content" && $view=="article") {
    $ids = explode(':',JRequest::getString('id'));
    $article_id = $ids[0];
    $article =& JTable::getInstance("content");
    $article->load($article_id);

}

mysql_connect("localhost", "....", "...."); 
mysql_select_db("...."); 

// fetch data. I am only going to display 8 products.
    $res = mysql_query("SELECT file_14 FROM fotodatabase WHERE select_5 LIKE '%{$article->get("alias")}%' LIMIT 8");
    $num = mysql_num_rows($res) ;
    // calculate table dimensions. This will display 4 products in a line and then another 4 on the next line.
//If you wanted to display more products change the Limit 8 to Limit 12.
     $per_row = 4;
    $rows = (int) (($num + $per_row – 1) / $per_row);
    $count = 0;

    //Create Html table
    echo "<table>";
    for ($i = 0; $i < $rows; $i++)
    {
        echo "\t<tr>";
        for ($j = 0; $j < $per_row; $j++)
        {
            if ($count < $num)
            {
                $it = mysql_fetch_array($res);
                $Photo= $it["file_14"];
//I have a bike details page that i’m going to link to. I am also diplaying the bike image. The images are held in folder called ProductImages.
                  $item1 = "<td width='160'><a href='UsedBikeDetails.php?BikeID=$BikeID'><img border='0' src='ProductImages/$Photo' width='150' height='200'></a></td>";  
                     }
            else

                $item1 = "";
            echo "\t\t<td>$item1</td>";
            $count++;
            
        }
        echo "\t</tr>";
    }
    echo “</table>";

?>

 

The first part of the code (from the top till the MySql connect) is the code to get the page Alias from Joomla. That part is working fine.

Then you get the connect statement (also working), but after that I get a little confused. I changed all the parameters to my values but when I go to my URL I get:

 

Parse error: syntax error, unexpected T_STRING in [i](URL)[/i] : eval()'d code on line 23

 

Can someone take a look at this code?

 

Kind regards,

Ruud

Please remove this once, i wanna know what happens then.....

 

$item1 = "<td width='160'><a href='UsedBikeDetails.php?BikeID=$BikeID'><img border='0' src='ProductImages/$Photo' width='150' height='200'></a></td>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.