Categories > TinyButStrong general >

Need a little help

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Shawn
Date: 2005-03-22
Time: 23:41

Need a little help

I have a MySQL database with several records, the columns are ID, Name, VALUE. Here's an example of my database:

------------------
    
id - 1
upload - 1
name - First Name
value - Shawn
              
id - 2
upload - 1
name - Last Name
value - Smith

id - 3
upload -1
name - Address
value - 12345 Apple Street

id - 4
upload - 2
name - First Name
value - Jenny

id - 5
upload - 2
name - Last Name
value - Bosley

id -6
upload - 2
name - Address
value - 555 Pine Road

-----------

I'm trying to show the different records on page.

PHP
---

select value from table where name='first name'
select value from table where name='last name'

HTML
-----

[b1;block=begin]
[b1.value]
[b1'block=end]

Problem is that it repeats the first record.  If i use limit 5 it repeats also.

How can I show 5 records without only repeating the first???



By: Skrol29
Date: 2005-03-23
Time: 00:55

Re: Need a little help

Hello Shawn,

I don't understand your PHP: you have twi queries, but only one block in the HTML snippet.
By: Shawn
Date: 2005-03-23
Time: 01:13

Re: Need a little help

Basically in the HTML I want to show

Shawn Smith 12345 Apple Street
Jenny Bosley 555 Pine Road
etc...
etc...
etc...

Looking at the DB, do you follow me?
By: Skrol29
Date: 2005-03-23
Time: 01:23

Re: Need a little help

Why don't you use a query with two simple JOIN clauses ?
LEFT JOIN if some record may be missing.
By: Shawn
Date: 2005-03-23
Time: 01:27

Re: Need a little help

I'll try that and update you.  I keep trying different things, right now this is what my php looks like:

$RecCnt = $TBS->MergeBlock('b1',$cnx_id, "SELECT value FROM uploadinfo WHERE name IN ('Address','City','State','Asking Price')", $PageSize,$PageNum,$RecCnt);

This is what my HTML Looks like:

<td height="15" colspan="5" ><table width="100%" border="0">
        [b1;block=begin]  <tr>
            <td>[b1.value]</td>
          </tr>[b1;block=end]

By: Shawn
Date: 2005-03-23
Time: 06:32

Re: Need a little help

Skrol,

I'm pulling the right data now, howeve it's all one different lines.

Here's what I'm doing, any idea on how it can all show on one line???

PHP
----

$RecCnt = $TBS->MergeBlock('b1',$cnx_id, "SELECT value from ezu_uploadinfos WHERE id=4 || id=5 || id=7", $PageSize,$PageNum,$RecCnt);


HTML
-----

<table width="100%" border="0">
        [b1;block=begin]  <tr>
            <td><span class="sm"><font color="#000066" face="Verdana, Arial, Helvetica, sans-serif"><font color="#000000">[b1.value]</font></font></span></td>
          </tr>[b1;block=end]
        </table>
By: Skrol29
Date: 2005-03-23
Time: 11:32

Re: Need a little help

The following SQL statement gives you all in one:
SELECT fn.upload
  , fn.value AS 'FirstName'
  , ln.value AS 'LastName'
  , ad.value AS 'Address'
FROM t_test_shawn AS fn
LEFT JOIN t_test_shawn AS ln ON (fn.upload=ln.upload) AND (ln.name='Last Name')
LEFT JOIN t_test_shawn AS ad ON (fn.upload=ad.upload) AND (ad.name='Address')
WHERE (fn.name='First Name')
By: Shawn
Date: 2005-03-23
Time: 16:38

Re: Need a little help

Thanks. That pulls the data to one line while doing the SQL statement in PhpMyAdmin.

How would I put this in the HTML, my previous HTML (tbs code) no longer works   ??
By: Shawn
Date: 2005-03-23
Time: 16:40

Re: Need a little help

Nevermind.  Knocks self on Head.  : )

Knocks self on Head again : )