Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

How can I get these cells listed differently?

I have a list of data being displayed which you can view by going out to http://www.countryshowdown.com/state_winners.php

Instead of there being one column of info, I want two. In other words, right now you see:

California
Illinois
Indiana
Kansas

I want it to be listed like this:

California        Illiniois
Indiana           Kansas

How do I do that?

My current code is below:

<table width=100%>
                                    <?php
                                    $bruce = "select registration.id as registration_id, registration.stage_name, registration.winner_type, registration.radio_name, registration.year, registration.glamour_shot, dbo_radio_stations.station_name, dbo_radio_stations.state_show_id as radio_state from dbo_radio_stations inner join registration on dbo_radio_stations.station_name= registration.radio_name where registration.winner_type='State' and registration.year='$this_year' order by dbo_radio_stations.state";
                                    $bruce_query = mysqli_query($cxn, $bruce);
                                    if(!$bruce_query)
                                    {
                                    $nuts=mysqli_errno($cxn).': '.mysqli_error($cxn);
                                    die($nuts);
                                    }
                                    while($bruce_row=mysqli_fetch_assoc($bruce_query))
                                    {
                                    extract($bruce_row);
                                    ?>
                                    <tr>
                                    <td align="center" valign="center" background="images/spacer.gif" width="70" height="10">
                                    <?php
                                    if($glamour_shot=="" OR $glamour_shot==" " OR empty($glamour_shot)){
                                    $localpicture="Photos/contestants/NoImage.jpg";
                                    }      
                                    else
                                    {
                                    $localpicture="Photos/contestants/crop.php?h=100&w=100&f=$glamour_shot";
                                    }
                                    ?>
                                    <A HREF="<?php echo "$localpicture"; ?>" target="_blank"><IMG SRC="<?php echo "$localpicture"; ?>" border="0" width="67"></a>      
                                    </td>
                                    <td background="images/spacer.gif" width="592"  height="10"valign="center">
                                          <table width=100% border="0">
                                          <tr>
                                          <td background="images/spacer.gif" width="150" height="10">
                                          Name:
                                          </td>
                                          <td background="images/spacer.gif" width="400" height="10">
                                          <A HREF="contestant.php?id=<?php echo $bruce_row['registration_id']; ?>" target="_blank"><?php echo stripslashes($stage_name); ?></a>
                                          </td>
                                          </tr>
                                          <tr>
                                          <td>
                                          State:
                                          </td>
                                          <td>
                                          <b><?php
                                          $vivian= "select State from dbo_states where id='$bruce_row[radio_state]'";
                                          $vivian_query = mysqli_query($cxn, $vivian)
                                          or die("Couldn't execute query.");
                                          $vivian_row=mysqli_fetch_assoc($vivian_query);
                                          extract($vivian_row);
                                          echo $vivian_row['State'];
                                          ?></b>
                                          </td>
                                          </tr>
                                          <tr>
                                          <td>
                                          Radio Station:
                                          </td>
                                          <td>
                                          <?php echo $bruce_row['station_name']; ?>
                                          </td>
                                          </tr>
                                          </table>
                                    </td>
                                    </tr>
                                    <?php
                                    }
                                    ?>
                                    </table>
0
brucegust
Asked:
brucegust
  • 2
1 Solution
 
Ray PaseurCommented:
The general design would be something like this...

<tr><td>
<?php fetch a row and echo the data ?>
</td><td>
<?php fetch a row and echo the data ?>
</td></tr>

You would probably want to test for end-of-file in the results set (fetch function returns FALSE) and if that happened in the second table-data element, your script would insert a blank as a place filler.
0
 
brucegustPHP DeveloperAuthor Commented:
Thanks, Ray!

Your input got me pointed in the right direction.

Here's what I did:

$column=0;
                                    $bruce = "select registration.id as registration_id, registration.stage_name, registration.winner_type, registration.radio_name, registration.year, registration.glamour_shot, dbo_radio_stations.station_name, dbo_radio_stations.state_show_id as radio_state from dbo_radio_stations inner join registration on dbo_radio_stations.station_name= registration.radio_name where registration.winner_type='State' and registration.year='$this_year' order by dbo_radio_stations.state";
                                    $bruce_query = mysqli_query($cxn, $bruce);
                                          if(!$bruce_query)
                                          {
                                          $nuts=mysqli_errno($cxn).': '.mysqli_error($cxn);
                                          die($nuts);
                                          }
                                    while($bruce_row=mysqli_fetch_assoc($bruce_query))
                                    {
                                    extract($bruce_row);
                                    //get the name of the state represented by the dbo_radio_stations state_show_id
                                    $vivian= "select State from dbo_states where id='$bruce_row[radio_state]'";
                                    $vivian_query = mysqli_query($cxn, $vivian)
                                    or die("Couldn't execute query.");
                                    $vivian_row=mysqli_fetch_assoc($vivian_query);
                                    extract($vivian_row);
                                    //insert data into temporary table
                                    $mike = "insert into jorja (registration_id, stage_name, glamour_shot, radio_name, show_state) values('$registration_id', '$stage_name', '$glamour_shot',
                                    '$radio_name', '$vivian_row[State]')";
                                    $mike_query = mysqli_query($cxn, $mike);
                                          if(!$mike_query)
                                          {
                                          $crap = mysqli_errno($cxn).' :'.mysqli_error($cxn);
                                          die($crap);
                                          }
                                     }
                                    ?>
                                    <?php
                                    $taylor="select * from jorja order by show_state";
                                    $taylor_query=mysqli_query($cxn, $taylor)
                                    or die("Couldn't execute query.");
                                    while($taylor_row=mysqli_fetch_assoc($taylor_query))
                                    {
                                    extract($taylor_row);
                                    if($column==0)
                                    {
                                    echo "<tr>";
                                    }
                                    ?>
                                    <td align="center" valign="center" background="images/spacer.gif" width="70" height="10">
                                    <?php
                                    if($taylor_row['glamour_shot']=="" OR $taylor_row['glamour_shot']==" " OR empty($taylor_row['glamour_shot'])){
                                    $localpicture="Photos/contestants/NoImage.jpg";
                                    }      
                                    else
                                    {
                                    $localpicture="Photos/contestants/crop.php?h=100&w=100&f=$glamour_shot";
                                    }
                                    ?>
                                    <A HREF="<?php echo "$localpicture"; ?>" target="_blank"><IMG SRC="<?php echo "$localpicture"; ?>" border="0" width="67"></a>      
                                    </td>
                                    <td background="images/spacer.gif" width="592"  height="10"valign="center">
                                          <table width=100% border="0">
                                          <tr>
                                          <td background="images/spacer.gif" width="150" height="10">
                                          Name:
                                          </td>
                                          <td background="images/spacer.gif" width="400" height="10">
                                          <A HREF="contestant.php?id=<?php echo $taylor_row['registration_id']; ?>" target="_blank"><?php echo stripslashes($taylor_row['stage_name']); ?></a>
                                          </td>
                                          </tr>
                                          <tr>
                                          <td>
                                          State:
                                          </td>
                                          <td>
                                          <b><?php
                                          echo $taylor_row['show_state'];
                                          ?></b>
                                          </td>
                                          </tr>
                                          <tr>
                                          <td>
                                          Station:
                                          </td>
                                          <td>
                                          <?php echo $taylor_row['radio_name']; ?>
                                          </td>
                                          </tr>
                                          </table>
                                    </td>
                                    <?php
                                    if($column==1)
                                    {
                                    echo "</tr>";
                                    $column=0;
                                    }
                                    else
                                    {
                                    $column = $column+1;
                                    }
                                    ?>
                                    <?php
                                    }
                                    ?>
                                    </table>
0
 
Ray PaseurCommented:
Thanks for the points!  Best, ~Ray
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now