Jump to content

How do i get information from fields in different rows


ewaite

Recommended Posts

Hi All,

 

Not really sure what to call what I want to do, If I knew I could search for information.

 

I am building a page with 20 pictures on it with a name below each, I want to pull the Name and image file name from a MySQL database but the names and image file names need to come from 20 different rows. My database key name is Id, so I'm guessing somehow I need to to use something to say:  where Id = "var"  Below is part of the code I have I can get the same image file and name in all 20 places.

 

Any help would be great,

 

 

<?php require_once('../../Connections/Trophies.php'); ?>

<?php

 

mysql_select_db($database_Trophies, $Trophies);

$query_gallery = "SELECT Id, image, name FROM trophies WHERE Id >= 1 ORDER BY Id ASC";

$gallery = mysql_query($query_gallery, $Trophies) or die(mysql_error());

$row_gallery = mysql_fetch_assoc($gallery);

$totalRows_gallery = mysql_num_rows($gallery);

?>

 

 

<td width="20%" height="150" align="center" valign="middle" bgcolor="#000000"><img src="deer-images/<?php echo $row_gallery['image']; ?>" alt="<?php echo $row_gallery['name']; ?>" width="125" height="187"/><br />

                              <font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_gallery['name']; ?></font></td>

                         

 

<td width="20%" align="center" valign="middle" bgcolor="#000000"><img src="deer-images/<?php echo $row_gallery['image']; ?>" alt="<?php echo $row_gallery['name']; ?>" width="125" height="187" /><br />

                              <font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_gallery['name']; ?></font></td>

                         

 

<td width="19%" align="center" valign="middle" bgcolor="#000000"><img src="deer-images/<?php echo $row_gallery['image']; ?>" width="125" height="187" /><br />

                              <font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_gallery['name']; ?></font></td>

 

 

 

Thanks,

ewaite

Not really sure what to call what I want to do, If I knew I could search for information.

 

I am building a page with 20 pictures on it with a name below each, I want to pull the Name and image file name from a MySQL database but the names and image file names need to come from 20 different rows. My database key name is Id, so I'm guessing somehow I need to to use something to say:  where Id = "var"  Below is part of the code I have I can get the same image file and name in all 20 places.

 

Any help would be great,

 

 

<?php require_once('../../Connections/Trophies.php'); ?>
<?php

mysql_select_db($database_Trophies, $Trophies);
$query_gallery = "SELECT Id, image, name FROM trophies WHERE Id >= 1 ORDER BY Id ASC";
$gallery = mysql_query($query_gallery, $Trophies) or die(mysql_error());
$row_gallery = mysql_fetch_assoc($gallery);
$totalRows_gallery = mysql_num_rows($gallery);
?>


<td width="20%" height="150" align="center" valign="middle" bgcolor="#000000"><img src="deer-images/<?php echo $row_gallery['image']; ?>" alt="<?php echo $row_gallery['name']; ?>" width="125" height="187"/><br />
                              <font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_gallery['name']; ?></font></td>
                          

<td width="20%" align="center" valign="middle" bgcolor="#000000"><img src="deer-images/<?php echo $row_gallery['image']; ?>" alt="<?php echo $row_gallery['name']; ?>" width="125" height="187" /><br />
                              <font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_gallery['name']; ?></font></td>
                          

<td width="19%" align="center" valign="middle" bgcolor="#000000"><img src="deer-images/<?php echo $row_gallery['image']; ?>" width="125" height="187" /><br />
                              <font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_gallery['name']; ?></font></td>

 

 

Database Structure:

 

ID = Primary (auto Increment)

name

image = (just a file name)

score-sheet  = (just a file name)

story

score

comp-score

county

state

date

method

catagory

 

Sorry, Hope this is better,

 

 

thanks for any help

ewaite

$query_gallery = "SELECT Id, image, name FROM trophies WHERE Id >= 1 ORDER BY Id ASC LIMIT 0,19";

 

i added the LIMIT 0,19 try it out!  8)

 

and i hope that is what you are looking for

Hi cssfreakie,

 

Thanks for the help, I have Google search foreach loop an looked at examples, but I still don't understand how to get my data from the fields into the loops. 

 

Were does a person go to learn this stuff? It is very hard to learn from books.

 

Thanks,

ewaite

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.