View Full Version : php problem
I use this code all the time, but now its not working.
There are 12 entries in the database, but for some reason its only selecting one.
My code:
<?php
include("includes/config.php");
$sql = mysql_query("SELECT * FROM `objects` WHERE `type` = 'image' ORDER BY `id` DESC");
$fetch = mysql_fetch_array($sql);
$url = $fetch["url"];
$id = $fetch["id"];
echo("<a href=\"?page=view&id=$id\"><img class=\"home\" src=\"images/uploads/$url\" border=\"0\" width=\"170\" height=\"170\"></a>");
?>
Independent
18-06-2008, 04:48 PM
I use this code all the time, but now its not working.
There are 12 entries in the database, but for some reason its only selecting one.
My code:
<?php
include("includes/config.php");
$sql = mysql_query("SELECT * FROM `objects` WHERE `type` = 'image' ORDER BY `id` DESC");
$fetch = mysql_fetch_array($sql);
$url = $fetch["url"];
$id = $fetch["id"];
echo("<a href=\"?page=view&id=$id\"><img class=\"home\" src=\"images/uploads/$url\" border=\"0\" width=\"170\" height=\"170\"></a>");
?>
Try flush the database, then add them again.
Try flush the database, then add them again.
Tried that, I also tried it on a different server.
Jack!
18-06-2008, 05:03 PM
mabey if its suddely stopped working put the code in 12 times ;) lol joke ..try a diffrent code is all i can say
Baving
18-06-2008, 06:37 PM
$sql = mysql_query("SELECT * FROM `objects` WHERE `type` = 'image' ORDER BY `id` DESC");
while($fetch=mysql_fetch_array($sql)){
echo("<a href=\"?page=view&id=$fetch[id]\"><img class=\"home\" src=\"images/uploads/$fetch[url]\" border=\"0\" width=\"170\" height=\"170\"></a>");
}
Maybe what you're looking for if you are wanting to return more than 1 row
CoolHostUK-Dom
18-06-2008, 06:54 PM
mabey if its suddely stopped working put the code in 12 times ;) lol joke ..try a diffrent code is all i can say
maybe if you suddenly replied you could CLICK HERE (http://www.youareanidiot.org) OR HERE (http://www.********.com) OR HERE (http://www.habboxforum.com/login.php?do=logout)
Edited by SyrupyMonkey (Forum Super Moderator): Please do not post rudely/act as a troll, thanks.
Protege
18-06-2008, 07:16 PM
Doms comment made me laugh lul - I think bavings ones near correct enough for you.
I use this code all the time, but now its not working.
There are 12 entries in the database, but for some reason its only selecting one.
My code:
<?php
include("includes/config.php");
$sql = mysql_query("SELECT * FROM `objects` WHERE `type` = 'image' ORDER BY `id` DESC");
$fetch = mysql_fetch_array($sql);
$url = $fetch["url"];
$id = $fetch["id"];
echo("<a href=\"?page=view&id=$id\"><img class=\"home\" src=\"images/uploads/$url\" border=\"0\" width=\"170\" height=\"170\"></a>");
?>
Agnostic Bear
18-06-2008, 08:06 PM
I use this code all the time, but now its not working.
There are 12 entries in the database, but for some reason its only selecting one.
My code:
<?php
include("includes/config.php");
$sql = mysql_query("SELECT * FROM `objects` WHERE `type` = 'image' ORDER BY `id` DESC");
$fetch = mysql_fetch_array($sql);
$url = $fetch["url"];
$id = $fetch["id"];
echo("<a href=\"?page=view&id=$id\"><img class=\"home\" src=\"images/uploads/$url\" border=\"0\" width=\"170\" height=\"170\"></a>");
?>
<?php
include( 'includes/config.php' );
$sql = mysql_query( "SELECT * FROM `objects` WHERE `type` = 'image' ORDER BY `id` DESC" );
while( false !== ( $fetch = mysql_fetch_array( $sql ) ) )
{
echo( '<a href="?page=view&id=' . $id . '"><img class="home" src="images/uploads/' . $url . '" border="0" width="170" height="170"></a>' );
}
?>
that would be the best way to go about it.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.