Jump to content


MYSQL querry arangement


4 replies to this topic

#1 Pbkilldezines

    Young Padawan

  • Members
  • Pip
  • 31 posts

Posted 03 December 2004 - 04:02 PM

OK, I have an affiliate script that I am testing. The way it works is the link is dynamicly generated with an ID, img location, and a counter. How ever the way I want it to look makes it so that the whole page has a line like this::

| AFFILIATE BUTTON |
|________________ |
|Clicks Out:: |
|_________________|

| AFFILIATE BUTTON |
|________________ |
|Clicks Out:: |
|_________________|

| AFFILIATE BUTTON |
|________________ |
|Clicks Out:: |
|_________________|

| AFFILIATE BUTTON |
|________________ |
|Clicks Out:: |
|_________________|

| AFFILIATE BUTTON |
|________________ |
|Clicks Out:: |
|_________________|

| AFFILIATE BUTTON |
|________________ |
|Clicks Out:: |
|_________________|




But how I want it is so that its in colunms insted of one straight row so the long line of affiliates is broken up into 2 or more cloumns.

Here is the PHP for my affiliate script:

$table = "aff_affiliates";

$sql= mysql_query("SELECT * , id , hits FROM $table");

while($row = mysql_fetch_assoc($sql))
{
echo "
<a href=\"http://www.pbkill.com/*.php?id=".$row[id]."\" target=\"_blank\"><img src=\"".$row[button]."\" border=\"0\"></a>
<br>
<font color=\"#CCCCCC\">Clicks Out: ".$row[hits]."</font>
<br>
<br>
";
}
}

PLEASE HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

#2 shao

    Original P2L Programmer

  • Members
  • Pip
  • 49 posts
  • Gender:Male
  • Location:Canada

Posted 04 December 2004 - 12:51 AM

Why don't you use the html table format and have your desired number of columns that way. Simply open tr and close tr for say 2 records or more and than loop.

#3 Pbkilldezines

    Young Padawan

  • Members
  • Pip
  • 31 posts

Posted 04 December 2004 - 02:47 PM

Could you elabertate more on this?

#4 Gio

    Jedi In Training

  • Members
  • PipPip
  • 317 posts

Posted 11 December 2004 - 10:54 AM

Check out my tutorial in the php tutorials forum for a brief display of html formatting sql output. Its called affiliation tutorial or something like that B)

#5 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 15 December 2004 - 02:59 PM

$sql= mysql_query("SELECT * FROM aff_affiliates");

while($row=mysql_fetch_assoc($sql))
{
echo "\n<a href=http://www.pbkill.com/*.php?id=$row[id] target=_blank><img src=$row[button] border=0></a>
<br>
<font color=#CCCCCC>Clicks Out: $row[hits]</font>
<p>\n";
}

that would probably work a little better for you... but you lost me on what you wanted to acctually do

do you want something that deals the way the affiliates are stored in the databse
or something with the way they are displayed on your site?

if you wanted something on the way they are displayed, use tables and the switch() function for 2 column display (if you want help with that just ask and i can probably figure something out).

either way, please do elaborate a little bit on what you want





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users