Display Issue

Discussion in 'PHP' started by meriad, Jul 20, 2008.

  1. #1
    Hello:

    I have a easy little display issue that I can't seem to get my head around. I am trying to display info from 2 Seperate mysql tables, into a propoerly formated table sorted by date, in some cases there is one entry for a date, and in other cases there are 2 entries for the date. In All Cases if the "Date" is the same. the "city, state" will be the same.

    You can find a display example of the current code in action at:

    http://www.get-music-tickets.com/tickets.php?band=-jonas-brothers

    Here is my current code:

    mysql_query("DROP TABLE tempbandlist");
    mysql_query("CREATE TABLE tempbandlist(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), city VARCHAR(250), state VARCHAR(250), date VARCHAR(250), price VARCHAR(250), link VARCHAR(250), tncity VARCHAR(250), tnstate VARCHAR(250), tndate VARCHAR(250), tnprice VARCHAR(250), tnlink VARCHAR(250), sku VARCHAR(250))");
    $bandlist = mysql_query("SELECT * FROM full_affiliate_feed WHERE GENRE = '$concert2'") or die(mysql_error());
    while($row = mysql_fetch_array($bandlist)){
    $event=$row['DESCRIPTION'];
    if ($event!="mirror"){
    $city=$row['CITY'];
    $state=$row['STATE'];
    $baddates=$row['EVENTDATE'];
    $dateparts=explode("/", $baddates);
    if (strlen($dateparts[0])==1) {
    $datepart1="0".$dateparts[0];}
    else {$datepart1=$dateparts[0];}
    if (strlen($dateparts[1])==1) {
    $datepart2="0".$dateparts[1];}
    else {$datepart2=$dateparts[1];}
    $dates=$datepart1."/".$datepart2."/".$dateparts[2];
    $gameid=$row['ID'];
    $bandlink=$row['ProductURL'];
    $bandlink2="http://www.tkqlhce.com/click-2703350-10281557?url=";
    $fulllink=$bandlink2.$bandlink;
    $gameprice = mysql_query("SELECT * FROM price_feed WHERE EVENT_ID = '$gameid'") or die(mysql_error());
    $pricelist = mysql_fetch_array( $gameprice);
    $lowprice=$pricelist['MINIMUM'];
    $topprice=$pricelist['MAXIMUM'];
    $pricerange="$".$lowprice." - $".$topprice;


    mysql_query("INSERT INTO tempbandlist(city,state,date,price,link)VALUES('$city','$state','$dates','$pri cerange','$fulllink')");
    }
    }
    $concertpt=explode(" ", $concert2);
    $shortconcert=$concertpt[0]." ".$concertpt[1];
    $bandlist2= mysql_query("SELECT * FROM concert_db") or die(mysql_error());
    while($row = mysql_fetch_array($bandlist2))
    {
    $longband=$row['ADVERTISERCATEGORY'];
    $parseband = explode(">", $longband);
    if ($parseband[1]=="CONCERTS ")
    {
    $band=trim($parseband[3]);
    if ($band=="$shortconcert")
    {

    $longdate=$row['NAME'];
    $datePos = strpos($longdate, "-");
    $datestart=$datePos-4;
    $baddate=substr($longdate,$datestart,10);
    $dateparts = explode("-", $baddate);
    $date=$dateparts[1]."/".$dateparts[2]."/".$dateparts[0];
    $city=$row['TITLE'];
    $state=$row['LABEL'];
    $bandlink=$row['BUYURL'];
    $pricerange=$row['THIRDPARTYCATEGORY'];
    $sku=$row['SKU'];
    $findband=mysql_query("SELECT * FROM tempbandlist WHERE sku = '$sku'") or die(mysql_error());
    $found1 = mysql_fetch_array($findband);
    if ($found1['sku'] == '')
    {
    mysql_query("INSERT INTO tempbandlist(city,state,date,price,link,SKU)VALUES('$city','$state','$date','$ pricerange','$bandlink','$sku')");
    }
    }
    }
    }
    $totallist = mysql_query("SELECT * FROM tempbandlist ORDER BY date") or die(mysql_error());
    while($row = mysql_fetch_array($totallist)){
    $city=$row['city'];
    $state=$row['state'];
    $dates=$row['date'];
    $pricerange=$row['price'];
    $fulllink=$row['link'];
    ?>
    <p class="style5">
    <td rowspan="1"><?
    echo "$city,$state</td>";
    ?> <td rowspan="1"><?
    echo "$dates</td> <td>$pricerange</td> <td><a href=$fulllink></p>";
    ?>
    <img src="/images/selecttickets_off.gif" width="101" height="25"></a></td>
    <?
    echo" </td>";
    echo" </tr>";



    My table displays properly if there is only one entry for the date, but if there is 2 entries for the date, I only want the the data and city displayed once, so the table code should look like this:

    <tr>
    <td width="25%" rowspan="2">$city,$state</td>
    <td width="25%" rowspan="2">$dates</td>
    <td width="25%">$Pricerange</td>
    <td width="25%">$fulllink</td>
    </tr>
    <tr>
    <td width="25%">$Pricerange (part 2)</td>
    <td width="25%">$fulllink (part 2)</td>
    </tr>

    You can find a display example of the current code in action at:

    http://www.get-music-tickets.com/tickets.php?band=-jonas-brothers

    I've tried a number of variations trying toget it to display properly, but cant seem to wrap my head around this simple little problem.

    Hope someone can Help

    Thanks

    Richard
    __________________
     
    meriad, Jul 20, 2008 IP