Jump to content

Grid Problems


papillonstudios

Recommended Posts

I want to pull the last 8 entries from a database.

 

$result = mysql_query("SELECT * FROM `sites` ORDER BY id DESC LIMIT 8");

 

The problem is when I ORDER BY ASC the elements are displayed fine but in ORDER BY DESC the are messed up. Why? and how do I fix it

 

ORDER BY DESC

Screen_Shot_2012_02_06_at_11_29_23_AM.jpg

 

ORDER BY ASC

Screen_Shot_2012_02_06_at_11_29_41_AM.jpg

 

CSS

 

html {
font-family: segoe ui, arial, helvetica, sans-serif;
height: 100%;	
overflow: hidden;
}

body {
background-image: linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%);
background-image: -o-linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%);
background-image: -moz-linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%);
background-image: -webkit-linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%);
background-image: -ms-linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%);	
background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0.16, #FFFFFF),color-stop(0.79, #E8E8E8));
background-repeat: no-repeat;
}

#sites {
width: 56%;
padding: 10px;
position: relative;
left: 50%;
margin-left: -29%;
top: 150px;
}

.siteWidget {
margin: 5px;
padding: 10px;
width: 200px;
float: left;
text-align: center;
-webkit-transition: all 0.25s ease-in-out;
    -moz-transition: all 0.25s ease-in-out;
}

.siteWidget .img {
height: 150px;
-moz-box-shadow: 2px 2px rgba(0,0,0,0.25);
-webkit-box-shadow: 2px 2px rgba(0,0,0,0.25);
box-shadow: 2px 2px rgba(0,0,0,0.25);
margin-bottom: 10px;
}

.siteWidget .img:hover {
box-shadow: 0 0 10px rgba(0, 0, 0, 1);
    -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 1); 
    -moz-box-shadow: 0 0 10px rgba(0, 0, 0, 1); 
}

a {
text-decoration: none;
colour: black;
}

a:visited {
color: black;
}

a:hover {
color: #e90000;
}

h3 {
margin: 0;
padding: 0;
}

 

html/PHP

<?
ob_start();
include('config.php');
?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Site Selector</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<?php
if (!isset($_POST['submit']))
{
?>
<form action="index.php" method="post">
<table>
	<tr>
		<td>
			<h3>Add New Site: </h3>
		</td>
		<td>
			<input type="text" name="siteName" placeholder="Name" />
		</td>
		<td>
			 <input type="text" name="siteUrl" placeholder="URL" />
		</td>
		<td>
			<input type="submit" name="submit" value="Add Site" />
		</td>
	</tr>
</table>

</form>

<div id="sites">

<?php
//load the pages from the Database
$result = mysql_query("SELECT * FROM `sites` ORDER BY id ASC LIMIT 8");

if (mysql_num_rows($result) == 0)
{
    echo 'No entries';
}
else
{
    while ($row = mysql_fetch_assoc($result))
    {
    ?>
    	<div class="siteWidget">
		<div class="img"><a href="http://<?=$row['url']?>"><img src="http://pagepeeker.com/t/m/<?=$row['url']?>" border="0"></a></div>
    		<a href="http://<?=$row['url']?>" name="<?=$row['name']?>"><?=$row['name']?></a>
    	</div>
    <?	
    }
}
}
else
{
//Get the data
$siteName = secure($_POST['siteName']);
$siteUrl = secure($_POST['siteUrl']);

if (!$siteName || $siteUrl)
{
	header("Location: index.php");
}
else
{
	$query = mysql_query("INSERT INTO `sites` (name, url) VALUE($siteName, $siteUrl)");

	if (mysql_num_rows($query))
	{
		header("Location: index.php");
	}
	else
	{
		echo 'Site not Added!<br />';
		echo '<a href="index.php">Go Back</a>';
	}
}
}
?>
<div style="clear:both;"></div>
</div>
</body>
</html>

 

HTML ONLY


<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Site Selector</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<form action="index.php" method="post">
<table>
	<tr>
		<td>
			<h3>Add New Site: </h3>
		</td>
		<td>
			<input type="text" name="siteName" placeholder="Name" />
		</td>
		<td>
			 <input type="text" name="siteUrl" placeholder="URL" />
		</td>
		<td>
			<input type="submit" name="submit" value="Add Site" />
		</td>
	</tr>
</table>

</form>

<div id="sites">

    	<div class="siteWidget">
		<div class="img"><a href="http://google.ca"><img src="http://pagepeeker.com/t/m/google.ca" border="0"></a></div>
    		<a href="http://google.ca" name="Google">Google</a>
    	</div>
        	<div class="siteWidget">
		<div class="img"><a href="http://facebook.com"><img src="http://pagepeeker.com/t/m/facebook.com" border="0"></a></div>
    		<a href="http://facebook.com" name="Facebook">Facebook</a>
    	</div>
        	<div class="siteWidget">
		<div class="img"><a href="http://coldcallradio.com"><img src="http://pagepeeker.com/t/m/coldcallradio.com" border="0"></a></div>
    		<a href="http://coldcallradio.com" name="Cold Call Radio">Cold Call Radio</a>
    	</div>
        	<div class="siteWidget">
		<div class="img"><a href="http://redbarradio.net"><img src="http://pagepeeker.com/t/m/redbarradio.net" border="0"></a></div>
    		<a href="http://redbarradio.net" name="Red Bar Radio">Red Bar Radio</a>
    	</div>
        	<div class="siteWidget">
		<div class="img"><a href="http://youtube.com"><img src="http://pagepeeker.com/t/m/youtube.com" border="0"></a></div>
    		<a href="http://youtube.com" name="YouTube">YouTube</a>
    	</div>
        	<div class="siteWidget">
		<div class="img"><a href="http://coldcallradio.com/wp-admin"><img src="http://pagepeeker.com/t/m/coldcallradio.com/wp-admin" border="0"></a></div>
    		<a href="http://coldcallradio.com/wp-admin" name="Cold Call Radio Admin Panel">Cold Call Radio Admin Panel</a>
    	</div>
        	<div class="siteWidget">
		<div class="img"><a href="http://apple.ca"><img src="http://pagepeeker.com/t/m/apple.ca" border="0"></a></div>
    		<a href="http://apple.ca" name="Apple Canada">Apple Canada</a>
    	</div>
        	<div class="siteWidget">
		<div class="img"><a href="http://trios.com"><img src="http://pagepeeker.com/t/m/trios.com" border="0"></a></div>
    		<a href="http://trios.com" name="triOs College">triOs College</a>
    	</div>
    <div style="clear:both;"></div>
</div>
</body>
</html>

Link to comment
Share on other sites

Just a stab...

 

1. Do not use short tags ie <?, use full <?PHP

2. try changing this...

    			<div class="siteWidget">
				<div class="img"><a href="http://<?=$row['url']?>"><img src="http://pagepeeker.com/t/m/<?=$row['url']?>" border="0"></a></div>
    				<a href="http://<?=$row['url']?>" name="<?=$row['name']?>"><?=$row['name']?></a>
    			</div>

 

to this...

 

    			<div class="siteWidget">
				<div class="img"><a href="http://<?PHP echo $row['url'];?>"><img src="http://pagepeeker.com/t/m/<?PHP echo $row['url']; ?>" border="0"></a></div>
    				<a href="http://<?PHP echo $row['url']; ?>" name="<?PHP echo $row['name']; ?>"><?PHP echo $row['name']; ?></a>
    			</div>

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.