Categories > TinyButStrong general >

How would I show multiple images from the same user?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Shawn
Date: 2005-04-24
Time: 07:36

How would I show multiple images from the same user?

In my HTML template I have 3 colums.  How would I show multiple images from my database from the same user in this template.

Example of what I am trying to do:
<td> IMAGE 1</td> <td> IMAGE 2 </td> <td> IMAGE 3 </td>

In my database all the images are stored in the same field titled Image.

By: Skrol29
Date: 2005-04-24
Time: 12:57

Re: How would I show multiple images from the same user?

Hello Shawn,

You can use a 'onsection' function to split this field.

function f_onsection($BlockName,&$CurrRec,&$Detail,$RecNum) {
  $CurrRec['images'] = explode(';',$CurrRec['images']);
}

And in you template:
  [blk.images.1]
  [blk.images.2]
  [blk.images.3]
By: Shawn
Date: 2005-04-24
Time: 16:52

Re: How would I show multiple images from the same user?

What's wrong?

HTML CODE

<td><table width="97%" border="0">
              <tr>
                <td>[b2;block=begin]<font size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong>Photo
                  Submitted by [b2.Full Name]</strong></font></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><div align="center">
                    <table width="100%" border="0">
                      <tr>
                        <td>[b2.Image1.1]</td>
                        <td>[b2.Image1.2]</td>
                        <td>[b2.Image1.3]</td>
                      </tr>
                    </table>
                  </div></td>
              </tr>
            </table></td>
        </tr>
        <tr>
          <td><table border="0" align="left" cellpadding="2" cellspacing="0">
              <tr align="center">
                <td><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Next Page:</font></strong> </td>
                <td width="16"><a href="[var..script_name]?username=[b2.Username]&PageNum=[nv.first;endpoint;magnet=a;mtype=m+m]"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">|&lt;</font></a></td>
                <td width="16"><a href="[var..script_name]?username=[b2.Username]&PageNum=[nv.prev;endpoint;magnet=a;mtype=m+m]"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">&lt;</font></a></td>
                <td width="16"><a href="[var..script_name]?username=[b2.Username]&PageNum=[nv.page;block=td;navsize=3;navpos=centred]"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">[nv.page]</font></a></td>
                <td width="16" bgcolor="#fffbec"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">[nv.page;block=td;currpage]</font></strong></td>
                <td width="16"><a href="[var..script_name]?username=[b2.Username]&PageNum=[nv.next;endpoint;magnet=a;mtype=m+m]"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">&gt;</font></a></td>
                <td width="16"><a href="[var..script_name]?username=[b2.Username]&PageNum=[nv.last;endpoint;magnet=a;mtype=m+m]"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">&gt;|</font></a></td>
              </tr>
            </table></td>
        </tr>
        <tr>
          <td>[b2;block=end]</td>


HERE'S MY PHP CODE


<?


//$username = username;
//$password = password;

if(isset($searchstring)) {
  setcookie("username",$email, time() + 604800);
    setcookie("password",$password, time() + 604800);
}
// delete the old one
//setcookie("searchstring",$searchstring);


include_once('tbs_class.php') ;

//Connexion to the database
if (!isset($_SERVER)) $_SERVER=&$HTTP_SERVER_VARS ; //PHP<4.1.0
require($_SERVER['DOCUMENT_ROOT'].'/cnx_mysql.php');


$id = PageNum;



//Default value
if (!isset($_GET)) $_GET=&$HTTP_GET_VARS ;
if (isset($_GET['PageNum'])) {
  $PageNum = $_GET['PageNum'] ;
} else {
    $PageNum = 1 ;
}

//Default value
if (isset($_GET['RecCnt'])) {
  $RecCnt = intval($_GET['RecCnt']) ;
} else {
    $RecCnt = -1 ;
}

$PageSize = 1 ;

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('view_pics2.htm') ;

$RecCnt = $TBS->MergeBlock('b2',$cnx_id, "SELECT DISTINCT usn.upload
, em.value AS 'Username'
, nm.name AS 'Image1'
, fn.value AS 'Full Name'
FROM ezu_uploadinfos AS usn
LEFT JOIN ezu_uploadinfos AS em ON (usn.upload=em.upload) AND (em.name='Username')
LEFT JOIN ezu_uploadinfos AS fn ON (em.upload=fn.upload) AND (fn.name='Full Name')
LEFT JOIN ezu_files AS nm ON (usn.upload=nm.upload) AND (usn.upload=usn.upload)
WHERE (usn.value='$username') GROUP BY Image1 ORDER BY upload DESC", $PageSize,$PageNum,$RecCnt);

function f_onsection($BlockName,&$CurrRec,&$Detail,$RecNum) {
  $CurrRec['Image1'] = explode(';',$CurrRec['Image1']);
}



//
//if (!$RecCnt) {
//header("Location: http://www.homesonthegulf.com/ooops.php");
// exit();
//}
/////


$TBS->MergeNavigationBar('nv','',$PageNum,$RecCnt,$PageSize) ;
$tpl->Render = TBS_OUTPUT ;
$TBS->Show() ;

?>



Shawn
By: Skrol29
Date: 2005-04-24
Time: 18:09

Re: How would I show multiple images from the same user?

You have to explain what result you have regarding to what you'd like to have. Your problem (that we don't know) has probably to do with how your image names are stored.
We can help, but not doing all for you.
By: Shawn
Date: 2005-04-24
Time: 18:35

Re: How would I show multiple images from the same user?

Here's the page that where I'm testing it:

http://www.zdot.com/view_pics2.php?username=sb@cableone.net

This is how I have the page now, but would like to show several images  (20) on one page instead of having to hit the next page.

http://www.zdot.com/view_pics.php?username=sb@cableone.net
By: Skrol29
Date: 2005-04-24
Time: 18:47

Re: How would I show multiple images from the same user?

Function f_onsection() is not executed because the tag [b2;block=begin] misses parameter onsection=f_onsection.
By: Shawn
Date: 2005-04-24
Time: 22:40

Re: How would I show multiple images from the same user?

I guess I'm retarded because here's what I get now.

TinyButStrong Error (Array value): Can't merge [b2.Image1.3] because there is no key named '3'. This message can be cancelled using parameter 'noerr'.

TinyButStrong Error (Array value): Can't merge [b2.Image1.2] because there is no key named '2'. This message can be cancelled using parameter 'noerr'.

TinyButStrong Error (Array value): Can't merge [b2.Image1.1] because there is no key named '1'. This message can be cancelled using parameter 'noerr'.

By: Skrol29
Date: 2005-04-25
Time: 00:28

Re: How would I show multiple images from the same user?

> I guess I'm retarded because here's what I get now.

I'm sure your not :)
Try with [b2.Image1.0]. At least this one should be merged.
You said the image names are stored in the same field. But what is the separator? Do you have an example?
By: Shawn
Date: 2005-04-25
Time: 01:15

Re: How would I show multiple images from the same user?

It worked for one image when changed to [b2.Image1.0] but not for the others [b2.Image1.1] [b2.Image1.2] and so on.

I have the images stored in the database as Image1 separated by username you can go to http://www.zdot.com/view_pics2.php?username=sb@cableone.net to see where I'm working.

http://www.zdot.com/view_pics.php?username=sb@cableone.net is the page that will be replaced once it's worked out. 

By: Shawn
Date: 2005-04-25
Time: 02:13

Re: How would I show multiple images from the same user?

Each image has it's own ID.
By: Skrol29
Date: 2005-04-25
Time: 02:29

Re: How would I show multiple images from the same user?

Hi,

The solution I sent is for 3 images stored in a field like this: "image_a.gif;image_b.gif;image_c.gif".

We cannot do all for you. You have to do your part of founding the problem. Copy/past my answer won't help you if you don't understand what it is supposed to solve.

We miss the organisation of your data to found a solution. You should describe it and/or give examples.
By: Shawn
Date: 2005-04-25
Time: 02:42

Re: How would I show multiple images from the same user?

Of course I know you can't solve my problems.  I'm not asking for that at all. I appreciate the help you do provide.  I'll mess around with this all night until I figure it out.

Just like everything else I learn, I'll keep at it, until I solve the problem.  I appreciate the help you provided thus far. 

I won't post on this topic again.  Thanks.