Hi I am trying to get it so the page displays the date, title and news for the last 3 records in the database I have setup, also make the date and title a link to the actual news article page. This is what I have tried but its no good anybody tell me where I have gone wrong with this please, the coding in this file gets pulled into the page using an include. <div id="panel-right" class="box panel"> <div class="in"> <h3>Driving Insructor<br /> Latest News</h3> <?php $result = mysql_query(SELECT * FROM news ORDER BY id DESC LIMIT 0,3); while($r=mysql_fetch_array($result)) { $date=$r['date']; $title=$r['title']; $news=$r['news']; $id=$r['id']; $address = "$title/$id"; $url = str_replace(' ','-',$address); //make the title a link echo "<li>"; echo "<a href='news_article/$url')'>$date : $title</a>"; echo "<p>" . substr($list['news'], 0, 400) . "</p>"; echo "</li>"; } ?> <p><a href="dual_control_car_hire/latest_news.php">All News</a></p> </div> </div> PHP:
http://www.lease-hire.co.uk/dual-control-car-hire-test This column (right), content column and the footer both have gone since adding the PHP code to display the dynamic news bit, I have used an include to pull in the left column, right column and footer see. Below is the code for the main file which pulls in the others, of course I have changed the database name, username, password. <?php mysql_connect('localhost', 'username', 'password'); mysql_select_db('database''); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-language" content="cs" /> <meta name="description" content="Total Fleet Services are also now able to offer great rates for dual control car hire and driving instructor car leasing." /> <meta name="keywords" content="car,leasing,driving,instructor,dual,control,cars,hire,contract,total,fleet,services" /> <link href="dual_control_car_hire/css/test_screen.css" type="text/css" rel="stylesheet" media="screen,projection" /> <!--[if lte IE 6]> <link href="dual_control_car_hire/css/msie.css" type="text/css" rel="stylesheet" media="screen,projection" /> <![endif]--> <link rel="stylesheet" media="print" type="text/css" href="/dual_control_car_hire/css/print.css" /> <title>Total Fleet Services Ltd - Dual Control Car Hire, Driving Instructor Cars</title> </head> <body> <div id="layout"> <?php include 'dual_control_car_hire/header.php'; ?> <div id="container" class="box"> <?php include 'dual_control_car_hire/left_column.php'; ?> <?php include 'dual_control_car_hire/right_column.php'; ?> <div id="obsah" class="content box"> <div class="in"> <h2>Dual Control Car Leasing</h2> <p>Total Fleet have been in the contract hire and leasing business since 1994 and with this wealth of experience are also now able to offer great rates for dual control car hire. Leasing a dual control car with Total Fleet Services offers many benefits to driving instructors who are looking to get a new vehicle.</p> <h3>Here are some of the benefits of leasing your dual control driving instructor car:</h3> <ul> <li>A brand new car every 12 or 18 months on fixed term rentals</li> <li>All mechanical repairs and services are included in the monthly rental</li> <li>All vehicle excise duty is included</li> <li>All vehicles are fitted with He-man dual controls</li> <li>Breakdown, home start and recovery is included </li> <li>Fixed costs to allow accurate budgeting</li> <li>We hold large stocks of manual and automatic dual controlled cars that are under 12 months old that can be delivered to you within a few days While you wait for your new vehicle to arrive. </li> </ul> <p>Free nationwide delivery with all dual control vehicles.</p> <p><a href="dual_control_car_hire/special-contract-hire-rates.php" class="bigredtext">Special Offers From £56.67</a></p> <p>If you not looking for dual control contract hire cars and are looking for other car and van leasing deals, checkout out other site at <a href="http://www.lease-hire.co.uk">www.lease-hire.co.uk</a></p> </div> </div> </div> <?php include 'dual_control_car_hire/footer.php'; ?> </body> </html> PHP:
what is that variable $list['news'] i think its not initialized any where. can we get what is the error displaying here?
Sorry yeah should be $r['news'] Its because I copied that section from another file I have made for another part of this new section. I have tried changing that to the $r['news'] but it still does not work, I am not getting any eroor just the page does not diplay properly, the content column, right column (This file in question) and the footer have gone since I added the PHP section in this file.
Change $result = mysql_query(SELECT * FROM news ORDER BY id DESC LIMIT 0,3); PHP: to $result = mysql_query(SELECT * FROM news ORDER BY id DESC LIMIT 0,3) or die(mysql_error()); PHP: And try again, maybe there is an error in the query.
Done still no error though. :/ EDIT Dont worry fixed it made a real silly error never put the quotes needed doing the query. oops