Jump to content

Help; mysql_result / arrays


xyn

Recommended Posts

Hey,
I've got a small problem, which i'm confused myself over...
and i wanted to count the amount of IMAGES have
been stoed for someones bio...

basically I have the structure, but the way i have done it is
when they upload an image they can upload a max of 3 images
premium gets 5... but i make this limit using mysql_num_rows
checking if they have 3 rows etc..

So i have 3 images in my table and now it's time to display each
image in my table (i've got this sorted) but my problem is with
whether i should use, AN ARRAY or MYSQL_RESULT();

IF i use an array. how would I extract my images?
OR if i use mysql_result($result, $row, 'field');
how could i get this to work correctly?

My sql table is set-out as;
- id                  <Uploaded ID
- user                <User uploaded this img
- image_name    < Image Name
- time                < Time uploaded...
Link to comment
https://forums.phpfreaks.com/topic/27370-help-mysql_result-arrays/
Share on other sites

Where are the images stored??
The images are in teh tables as the exact name of the file??

here is something quick
[code]<?php
$user = $_POST['username'];  //Or however you are getting the username or userid
$sql = "SELECT * FROM tablename WHERE user = '$user'";
  $res = mysql_query($res) or die (mysql_error());
    while($r = mysql_fetch_assoc($res)){
      echo "<img src=\"/path/to/pictures/".$r['image_name']." width=xxx height=xxx\"><br>\n";
}
?>[/code]

Ray
yeh but tha's the problem... If i use that method the images will be confused ie:
id        image_name            user            date
0            img1.gif                abc                00/00/00
1            img2.gif                abc                00/00/00
2            img3.gif                abc                00/00/00

which means using your method which is what i needed an
ARRAY or Mysql_result for to organise these images. because
i will get them by id

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.