Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Text displaying as an image and text?

$
0
0

I have been developing some code that will allow my client to chose whether she wants to put an image left, right or centred on her news page. The code is working brilliantly and allows her to do so (thanks to this forum!)

 

However - the news title is displaying twice on the page.

Once as an image and once as text........ I removed 'newsimage' from the sql query however it is still displaying the title as an image even though it is no longer looking for the image? Completely confused as to why it has started doing this.

 

Heres the code:

// Show latest 10 news items
function top10news($s, $t, $u, $w)
{
	session_start();
	$con = mysqli_connect("*****************", "*****************", "*****************", "*****************");

	if (mysqli_connect_errno($con)) {
		echo "<p class='sect'>Could not connect to the database</p>";
	} else {
		$q = "SELECT DISTINCT newsitem.niid,newstitle,newssnippet,sitename,newsimage
        FROM newsitem
        INNER JOIN newsbusiness ON newsitem.niid=newsbusiness.niid
        LEFT JOIN newsimage ON newsitem.niid=newsimage.niid
        WHERE newsitem.niid=newsbusiness.niid AND newsstatus='enabled' ";
		if ($u != "Any") {
			$q = $q . "AND sitename='$u' ";
		}
		if ($s != "Any") {
			$parts = explode('-', $s);
			$y = $parts[0];
			$m = $parts[1];
			$q = $q . "AND YEAR(newsdate) = $y AND MONTH(newsdate) = $m ";
		}
		$q = $q . "ORDER BY newsdate DESC LIMIT 0,10";

		$result = mysqli_query($con, $q);
		while ($tnrow = mysqli_fetch_array($result)) {
			echo "
			<div class='newssummary'>";

			if ("" . $tnrow ['imageposition'] . "" == "None") {
				echo "<p class = 'newsmore' > <a href = 'newsitem.php?i=" . $tnrow['niid'] . "' > Read More</a > </p>";
			}
			else if ($tnrow ['imageposition'] == 'Centre') {
				echo "<p class='newsmore'> <a href='newsitem3.php?i=" . $tnrow['niid'] . "'>Read More</a></p>";
			}
			else if ($tnrow ['imageposition'] == 'Right') {
				echo "<p class='newsmore'> <a href='newsitem2.php?i=" . $tnrow['niid'] . "'>Read More</a></p>";
			}
			else if ($tnrow ['imageposition'] == 'Left') {
				echo "<p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p>";
			}

			echo "<div class='newspic'><img src='http://www.nortech.org.uk/news/" . $tnrow['newsimage'] . "' alt='" . $tnrow['newstitle'] . "' /></div>";
			echo "
			<p><strong>" . $tnrow['newstitle'] . "</strong></p>
			<p class='news'>" . $tnrow['newssnippet'] . "</p>
			</div>
			<div class='padder1'></div>
			<div class='rtgreengp'></div>
			";
		}

		mysqli_close($con);
	}
}

It seems to display correctly if I upload an image along with an article..... so from what I can see if there is no image uploaded, it is just replacing it with the news title? if that makes any sense.......

 

Any advice out there?


Viewing all articles
Browse latest Browse all 13200

Latest Images

Trending Articles



Latest Images