Forum Moderators: mack

Message Too Old, No Replies

question about generating webpage content

from a MySQL database

         

Psazf

5:39 pm on Jul 19, 2005 (gmt 0)

10+ Year Member



Hi All, WebmasterWorld

First, sorry if this not the appropriate forum to post my message, but... here it goes:

I have a MySQL database with +/- 2000 records. Each one has fields like: CompanyName, Address, Cyty, Phone, and so on...

Most of them are 'normal' records. They are listed in the webpage for free, they didn't paied anything to be there and appear on my website.

But (1) some of them, had paied a certain amount ($xx), to be more visible. That is, instead of appearing normally in the list as all the others, their information record appears inside a nice framme border with nice colors and with some nice words in the top like "registered company".

But (2) some of them had paied a certain amount ($#*$!), to be more, more visible. That is, instead of appearing normally in the list as all the others, their information record appears at the top of the list (independent of the sorted order) with a nice framme border with nice colors and with some nice words in the top like "gold registered company".

I know that (maybe?) the webpage with the list can be generated/filled with PHP reading the database. But for me this is ease if all records appears the same way.

Is there some way I can make this also with PHP, so that the "registered companies" appears intercalated inside the list with the nice border and that the "gold registered company", appears at the top of the list?

The list is alphabetically sorted.

"registered companies" and "gold registered company", can be a y/n field of the database.

Example:

+++++GOLD R.C.++++++++++++++
+ CB companyname ..........+
+ Address - City - Phone ..+
++++++++++++++++++++++++++++

A companyname
Address - City - Phone

B companyname
Address - City - Phone

----------------------------
¦ CA companyname ..........¦
¦ Address - City - Phone ..¦
----------------------------

CD companyname
Address - City - Phone

----------------------------
¦ CE companyname ..........¦
¦ Address - City - Phone ..¦
----------------------------

D companyname
Address - City - Phone

......
and so on...

In same order of ideias, it's more or less want happens with the results of a G search?!

Thanks in advance by some help, best regards,
PSAZF
(Portugal)

webdude

7:51 pm on Jul 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The easiest way to do this without trying to get into algos and such, would be to create a sort order of sorts :-) If you have three different classes of links and want to display one type over the other, why not create a field in the DB and insert a number. Number one for gold, 2 for paid, 3 for all the rest. When you write query the DB, sort by the sort order. This will put all the golds on top, paid would come next, then the others.

As for how you layout the html to diplay this the way you want, you may have to play with it for a bit.

Hope this helps!

Psazf

10:09 pm on Jul 19, 2005 (gmt 0)

10+ Year Member



hi webdude, thanks your post.

...sort by the sort order...

this is not what I need, because I need that the records "2 for paid" appears sorted with the records "3 for all the rest". Look my example in my 1st post.

Sorry, what you mean with "algos"?

You think it's a big problem layout the html to diplay this the way you want?

Somemore opinions?

Regards,
PSAZF

webdude

11:48 am on Jul 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am confused as to what you are trying to do. Is there an example on-line I could look at? You could sticky me the URL.

Psazf

3:19 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



Hi webdude, sorry maybe I can not make me unserstand very well. It's my poor english (i'm from portugal). I don't have any example on-line yet!

Image that I have the following table sorted by companyname:

CompanyName ... Address ... PaymentType
----------------------------------------
Aaaaaaaaaaa ... xyxyxyx ... none 3
Bbbbbbbbbbb ... nbnbnbn ... none 3
CAaaaaaaaaa ... ghghghg ... paid 2
CBbbbbbbbbb ... tetetet ... Gold 1
CDddddddddd ... ksksksk ... none 3
CEeeeeeeeee ... quququq ... paid 2
Ddddddddddd ... rororor ... none 3
Eeeeeeeeeee ... spspsps ... Gold 1

I need that all company names appears in the webpage, listed/sorted by CompanyName, when PaymentType is 3 and/or 2. But when it's 2, the space where the info for this company appears, must be bordered by some type of frame/graphics (not html frame), to become more eyes catch.

If PaymentType is Gold (1), this/that company(ies) need to be listed on the top (before all the 3 and 2 type) with the space where the info for this company appears, be bordered by some type of frame/graphics, different from the border of 2 and 3 types, to become even more eyes catch, to be the first to be seen.

Example, using data from example table above:

+++++GOLD+++++++++
+ CBbbbbbbbbb..........+
++++++++++++++++++

+++++GOLD+++++++++
+ Eeeeeeeeeee..........+
++++++++++++++++++

Aaaaaaaaaaa

Bbbbbbbbbbb

-----------------------
¦ CAaaaaaaaaa ..........¦
-----------------------

CDddddddddd

-----------------------
¦ CEeeeeeeeee ..........¦
-----------------------

Ddddddddddd

------------------------------------
Now it's more clear? Can you see if php can deal with this?
Best regards and thanks in advance
PSAZF
(Portugal)

PumpkinHead

3:45 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



Select all records where paid = Gold & sort by company name

and for each record found, echo $companyname in gold box and pretty colours

Then...

SQL select all records where paid <> Gold & Sort by company name

And for each record found...

If current payment type = Paid then echo $companyname in nice colours

If current payment type = none then echo $companyname without colours

Hope this helps

Psazf

5:00 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



Hi PumpkinHead, thanks for your answer.

Yes, I had this idea for resolve this kind of problem, but what i didn't am sure, was if PHP mixed with Html and Mysql, can deal with it.

I already made some websites, but all have static pages. I'm learning now the beginnings of php and mysql, for my new website, that must deal with databases data.

Thanks and kind regards
PSAZF

webdude

5:57 pm on Jul 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, I don't program in php, more asp and taf. However, it seems that a simple if and elseif statement would pretty much do what you want it to do, as PumpkinHead brought up.

Your going to have to dive into the programming with php to get it to work.

Psazf

9:49 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



Thanks webdude.

Yes, I already have 3 e-books about PHP+MySQL. I already started to read/learn about it. I didn't installed them already on my XPpro system, because I'm afraid of some problems, I need to make my full backups before.

Kind regards,
PSAZF