/    Sign up×
Community /Pin to ProfileBookmark

Show part of last 3 records

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.

[code=php]
<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($r[‘news’], 0, 400) . “</p>”;
echo “</li>”;
}

?>
<p><a href=”dual_control_car_hire/latest_news.php”>All News</a></p>

</div>
</div>
[/code]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@tirnaAug 24.2010 — When you say it is "no good", what is it doing that it shouldn't?

Maybe if you post the actual generated html things will become clearer.
Copy linkTweet thisAlerts:
@johnevaauthorAug 24.2010 — Content column, right/news column and footer disapper.

http://www.lease-hire.co.uk/dual-control-car-hire-test

Below is the main pages file which pulls in the different include files. The code in the first post I made is right_column.php

[code=html]<?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 &pound;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>
[/code]
Copy linkTweet thisAlerts:
@tirnaAug 24.2010 — I don't normally click posted links for obvious security reasons, so I can't help you.

Hopefully someone else will come along to help you fix your code.
Copy linkTweet thisAlerts:
@johnevaauthorAug 24.2010 — Ahright would you like me to post the html output then?

As you can see from below it just stops running anything to do with the right coloumn include, I obviously have something wrong but just carnt see whats wrong with it as I am very new at playing with PHP not sure whats wrong at all. :/

[code=html]
<!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">

<div id="header">

<p class="head"><a href="http://www.lease-hire.co.uk/dual-control-car-hire"><img src="http://www.lease-hire.co.uk/dual_control_car_hire/img/header.jpg" alt="Total Fleet Services Dual Control Cars and Driving Instructor Cars Logo Image" /></a></p>
<hr class="noscreen" />

<p class="noscreen noprint">
<em>Skip to <a href="#obsah">content</a>, <a href="#nav">navigation</a>.</em>
</p>

<hr class="noscreen" />

<div id="nav" class="box">
<ul>
<li><a href="http://www.lease-hire.co.uk/dual-control-car-hire">Home<br /><span>Main page</span></a></li>
<li><a href="http://www.lease-hire.co.uk/dual_control_car_hire/about-us.php">About<br /><span>Our team</span></a></li>
<li><a href="http://www.lease-hire.co.uk/dual_control_car_hire/contract-hire-rates.php">Contract Hire<br /><span>How much it costs</span></a></li>
<li><a href="http://www.lease-hire.co.uk/dual_control_car_hire/special-contract-hire-rates.php">Special Offers<br /><span>New and used cars</span></a></li>
<li><a href="http://www.lease-hire.co.uk/dual_control_car_hire/pdi-rates.php">PDI<br /><span>Rates</span></a></li>
<li><a href="http://www.lease-hire.co.uk/dual_control_car_hire/daily-hire-rates.php">Daily Hire<br /><span>How much it costs</span></a></li>
<li><a href="http://www.lease-hire.co.uk/dual_control_car_hire/faqs.php">FAQ's<br /><span>Questions answered</span></a></li>
<li><a href="http://www.lease-hire.co.uk/dual_control_car_hire/apply-now.php">Apply<br /><span>Now</span></a></li>
<li><a href="http://www.lease-hire.co.uk/dual_control_car_hire/maintenance.php">Maintenance<br /><span>Terms</span></a></li>
</ul>
<hr class="noscreen" />
</div>




<div id="container" class="box">

<div id="panel-left" class="box panel">
<div class="in">

<h3><a href="http://www.SwiftPage3.com/survey/TFSDualControlSubscribe" class="no_under">Special Offer Newsletter<br /> <img src="http://www.lease-hire.co.uk/dual_control_car_hire/img/subscribe_now.gif" alt="Subcribe Now" /></a></h3>
<p><a href="http://www.lease-hire.co.uk/dual_control_car_hire/referal.php"><img src="http://www.lease-hire.co.uk/dual_control_car_hire/img/referal.jpg" alt="referal link"/></a></p>
<h3>Contact Details</h3>
<p>Total Fleet Services Ltd <br />
Security House<br />
Littleton Drive<br />
Huntington<br />
Cannock<br />
Staffs<br />
WS12 4TS</p>
<p>Call Us On:<br />0845 070 1787</p>
<p>Fax:<br />0845 070 1788</p>
<p>Email:<br /><a href="mailto:[email protected]">[email protected]</a></p>

</div>
</div>


[/code]
Copy linkTweet thisAlerts:
@johnevaauthorAug 24.2010 — Dont worry fixed it made a real silly error never put the quotes needed doing the query. oops
×

Success!

Help @johneva spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...