Jump to content

Problem connecting image slider w/ news


CrashOkami

Recommended Posts

Hello everyone,

 

I'm building a gaming news, reviews etc website for my last project at the university. Although, I'm a bit bummed right now, I'm stuck and can't figure out how to handle this.

 

I've got a neat image slider on my index page, with 6 options, and I want it to display the following items from my MySQL's "news" table: Title (headline), Small_desc (small description), and the Image (the header image, which I configured the slider to auto-size).

 

My slider's raw, working (although static) code is as follows:

 

<ul id="slideshow">
	<li>
		<h3>Headline 1</h3>
		<span>photos/assassins01.jpg</span>
		<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ut urna. Mauris nulla. Donec nec mauris. Proin nulla dolor, bibendum et, dapibus in, euismod ut, felis.</p>
		<a href="#"><img src="photos/assassins01.jpg" alt="Thumbnail_1" width="125" height="75"/></a></li>

</ul>
<div id="wrapper">
	<div id="fullsize">
		<div id="imgprev" class="imgnav" title="Previous Image"></div>
		<div id="imglink"></div>
		<div id="imgnext" class="imgnav" title="Next Image"></div>
		<div id="image"></div>
		<div id="information">
			<h3></h3>
			<p></p>
		</div>
	</div>

	<div id="thumbnails">
		<div id="slideleft" title="Slide Left"></div>
		<div id="slidearea">
			<div id="slider"></div>
		</div>
		<div id="slideright" title="Slide Right"></div>
	</div>
</div>

 

What I want to work on is the 6 versions of the first part. I will need to replace static items with variables from my database's table's items, and display them, meaning I will have to make it look like this:

 

	<li>
		<h3>$Title</h3>
		<span>$Image</span>
		$Small_desc
		<a href="my article"><$Image alt="$Title" width="125" height="75"/></a></li>

 

Problem is, I'm getting lots of errors when I try to configure it myself. I've already connected to my database, and made the code ask for the last 6 items, sorted by Date. Code is as follows:

 

<?php
mysql_connect("localhost", "root") or die("Failed to connect.");
mysql_select_db("starblind_database") or die("Failed to find database.");
$query = "SELECT * FROM news ORDER BY Date LIMIT 6";   
$result = mysql_query($query) or die("Failed to execute query.");

while($row = mysql_fetch_array($result))
{
[b]...[/b]
        }
?>

 

In the bold part, my slider's code should be present. At this point, I've started working on my other pages and abandoned index, but I'm finishing the others, and want to finish the index one, as my project is due for this Tuesday. I'm kindly asking you all, can you please help me? Or at least point me in the right direction, where I can pick up from and continue? It would be very, very appreciated.

 

Thank you,

Christos

[/code]

Link to comment
Share on other sites

I just noticed I'm missing the $_GET code, meant to get my items from the database and display them. I've filled them in, and now the database code looks like this:

 

<?php
mysql_connect("localhost", "root") or die("Failed to connect.");
mysql_select_db("starblind_database") or die("Failed to find database.");
$query = "SELECT * FROM news ORDER BY Date LIMIT 6";   
$result = mysql_query($query) or die("Failed to execute query.");

$Title = $_GET["Title"];
$Small_desc = $_GET["Small_desc"];
$Image = $_GET["Image"];

while($row = mysql_fetch_array($result))
...
...

 

Although they get counted as undefined variables. What seems to be the biggest problem is that I can't find a way to enclose my slider's UL, LI etc in my php, and the code shows up broken.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.