Hi everyone,
I have a kind of news bit on my website, the news is kept in the sql database with various rows... headline, story, url etc. I want to show 4 stories from the database randomly. I can do this if i do a simple picture with text next to it and set it to count 4. But what im trying to do is have a main story, with Pic on the left story on the right, then under that the other 3 stories, pic on top with headline under it.
Where ive got to is that everything works except all 4 places are showig the same pic/story and not the 4 different ones that I would like it to.
For an example of what im trying to do see http://www.wanadoo.co.uk/ the section "on wanadoo today"
Any help would be great, and please be gentle with me 🙂
I have included the code below.
Thanks
Lee
<link href="gz_css.css" rel="stylesheet" type="text/css">
<?php
//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("localhost","ldirden","ArOvegIAR"); //(host, username, password)
//specify database ** EDIT REQUIRED HERE **
mysql_select_db("ldirden") or die("Unable to select database"); //select which database we're using
// Build SQL Query
$query = "SELECT * FROM gznews ORDER by rand() LIMIT 0, 4;";
$numresults=mysql_query($query);
$result = mysql_query($query) or die("X Couldn't execute query");
// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
$headline = $row["headline"];
$story = $row["story"];
$url = $row["url"];
$pic = $row["pic"];
}?>
<table width="440" border="0" cellpadding="0" cellspacing="0" bgcolor="ffacdf">
<tr align="left" valign="middle">
<td height="25"><img src="img/space.gif" width="10" height="5"><span class="headlineWhite">On the scene</span></td>
</tr>
<tr align="left" valign="middle">
<td bgcolor="FFFFFF"><img src="img/space.gif" width="5" height="10"></td>
</tr>
<tr align="left" valign="middle">
<td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="left">
<td width="30%" valign="top"><img name="" src="<?php echo"img/$pic" ?>" width="118" height="100" alt=""></td>
<td width="70%" valign="middle"><p><span class="headlineGrey"><?php echo"$headline" ?></span><br>
<span class="hometext"><?php echo"$story" ?></span></p>
<p><a href="<?php echo"$url" ?>" target="_blank"><img src="img/more.gif" width="46" height="9" border="0"></a> </p></td>
</tr>
</table></td>
</tr>
<tr align="left" valign="middle">
<td bgcolor="#FFFFFF"><img src="img/space.gif" width="5" height="14"></td>
</tr>
<tr align="left" valign="middle">
<td valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="139" height="150" align="left" valign="top"><p><img name="" src="<?php echo"img/$pic" ?>" width="100" height="84" alt=""><img src="img/space.gif" width="50" height="5"> <br>
<span class="smallheadlineGrey"><?php echo"$headline" ?></span></p>
<p><a href="<?php echo"$url" ?>" target="_blank"><img src="img/more.gif" width="46" height="9" border="0"></a></p></td>
<td width="11" background="img/verticalline.gif"><img src="img/space.gif" width="11" height="5"></td>
<td width="139" height="150" align="left" valign="top"><p><img name="" src="<?php echo"img/$pic" ?>" width="100" height="84" alt=""><br>
<img src="img/space.gif" width="5" height="5"> <br>
<span class="smallheadlineGrey"><?php echo"$headline" ?></span></p>
<p><a href="<?php echo"$url" ?>" target="_blank"><img src="img/more.gif" width="46" height="9" border="0"></a></p></td>
<td width="11" background="img/verticalline.gif"><img src="img/space.gif" width="11" height="5"></td>
<td width="139" height="150" align="left" valign="top"><p><img name="" src="<?php echo"img/$pic" ?>" width="100" height="84" alt=""><br>
<img src="img/space.gif" width="5" height="5"> <br>
<span class="smallheadlineGrey"><?php echo"$headline" ?></span></p>
<p><a href="<?php echo"$url" ?>" target="_blank"><img src="img/more.gif" width="46" height="9" border="0"></a></p></td>
</tr>
</table></td>
</tr>
</table>