flyboeing Posted March 22, 2011 Share Posted March 22, 2011 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 Quote Link to comment Share on other sites More sharing options...
MrXHellboy Posted March 22, 2011 Share Posted March 22, 2011 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>"; Quote Link to comment Share on other sites More sharing options...
flyboeing Posted March 22, 2011 Author Share Posted March 22, 2011 Then I get: Parse error: syntax error, unexpected T_STRING in -URL-: eval()'d code on line 22 Quote Link to comment Share on other sites More sharing options...
MrXHellboy Posted March 22, 2011 Share Posted March 22, 2011 I Guess you dont have to search for the problem here...... As far as i can see, nothin could throw this kind of error within this code Quote Link to comment Share on other sites More sharing options...
flyboeing Posted March 22, 2011 Author Share Posted March 22, 2011 Hmm okay. Thank you for helping. Then I will search for an other script to show the results horizontal. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.