If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > reading a database and sorting.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-13-10, 19:14
skysober skysober is offline
Registered User
 
Join Date: May 2010
Posts: 2
reading a database and sorting.

Yes, I am totally a noob in sql. I am trying to write a small program that will take the photo attachments in a forum and make them look like an album.

I can read the database tables, and even get it to list everyone and all the photos. That is the problem. I want it to say read member #2 only and show only that members photos.

When I say if ($member > "0") it will list all the members number just fine. (i.e. member #2 shows above his photo. Member #245 shows above his photo.)

But if I say if ($member = "2") to try and get it to list ONLY member #2, it shows everyones photo but the member #2 shows above photos not even his.



Quote:
<?
$username="DBUSERNAME";
$password="DBPASS";
$database="DBNAME";
$x=date("j");

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM ibf_attachments";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo "<b><center>Database Output</center></b><br><br>";

$i=0;
while ($i < $num) {
$member=mysql_result($result,$i,"attach_member_id" );

if ($member > "0")

{
$isimage=mysql_result($result,$i,"attach_is_image" );
$imagedate=mysql_result($result,$i,"attach_date");
$imagesize=mysql_result($result,$i,"attach_filesiz e");
$imagewidth=mysql_result($result,$i,"attach_img_wi dth");
$imageheight=mysql_result($result,$i,"attach_img_h eight");
$imagelocation=mysql_result($result,$i,"attach_loc ation");
$imagethumblocation=mysql_result($result,$i,"attac h_thumb_location");


$attachfile=mysql_result($result,$i,"attach_file") ;



$str_2 = "http://www.WEBSITE.com/forum/uploads/$imagelocation";
$str_3 = "http://www.WEBSITE.com/forum/uploads/$imagethumblocation";

if ($isimage ="1")
{
echo "<b>$member $isimage</b><br>Image Size: $imagesize<br> Image Width: $imagewidth<br> Image Height: $imageheight<br>$attachfile<br><a href=$str_2 target='blank'><img src='$str_3' alt='the image' /></a> <br>";
}
}
?>
<?PHP
$i++;
}
?>
Reply With Quote
  #2 (permalink)  
Old 05-14-10, 12:50
skysober skysober is offline
Registered User
 
Join Date: May 2010
Posts: 2
over 25 views and not one clue or hint.

Thanks tho! I'll try somewhere else then that might deal more specific with SQL and PHP.



[This thread can be closed]
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On