PDA

View Full Version : A little MySQL coding help please?



Shedevil
January 11th, 2006, 14:19
Hiya,

Currently I'm putting together an affiliates page for my fanfiction archive.
The script I'm using for this is in MySQL.
I've ran into a problem though. The affiliate script is listing the images in rows rather than colums.

E.g. it's doing this with my clickable images:

-
-
-
-
-
-

Rather than doing this:

- - -
- - -

Is there anyway I can make the CLICKABLE images read it correctly in table form? As there are no </br> in the script or <p> or even a table.

This is my complete script (edited for privacy):

connect.php


<? $mysql_host = "localhost";
$mysql_user = "cpaneluser_databaseuser";
$mysql_pass = "databaseuserpass";
$mysql_data = "cpaneluser_database";
$mysql_table = "affiliate";
mysql_connect($mysql_host,$mysql_user,$mysql_pass) or die("Couldnt connect, try again. " . mysql_error());
mysql_select_db($mysql_data) or die("Cannot select database! Please Try again.
" . mysql_error());
?>


My affiliates.php




<? include('connect.php');
$query = "SELECT * FROM affiliate";
$result = mysql_query($query) or die('Error, query failed');
while ($row = mysql_fetch_array($result))
{
echo "<a href='".$row['link']."' target='"._blank."' title='".$row['name']."'><img src='".$row['img']."' border='0'</a>";
}


So umn, help? PLEASE?????? I've been at this for 12 hours and no results...I'm about to glitch out and throw my laptop against the wall!:nervous: Oh yeah and here it is in action: Crystal Rose Affiliates (http://www.crystalrose.be/affiliated.php)

Tree
January 11th, 2006, 14:27
Well, I do notice that there's no ?> at the end of affiliates.php. But that's probably not what's causing it. I don't know why it would do that. But this code looks more organized and will have the same effect (possibly fix your problem) as the above code.


<?
include("connect.php");
$query = "SELECT * FROM affiliate";
$result = mysql_query($query) or die('Error, query failed');
while ($row = mysql_fetch_array($result))
{
?><a href="<?echo $row['link'];?>" target="_blank"
title="<? echo $row['name']; ?>"><img src="<? echo $row['img'];?>" border='0'></a>
<?}?>

Same effect, more organized.

Shedevil
January 12th, 2006, 21:39
Got it working ^_^ it was a simple thing...I had centered my affiliates...stupid thing didn't like the center