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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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.