d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Sports Coliseum > Motor Sports & Cars > Thinkin About Buying A New Car
Prev17891011Next
Add Reply New Topic New Poll
Member
Posts: 29,723
Joined: Jun 11 2007
Gold: 279.52
Aug 26 2013 09:39pm
Quote (Sopranos @ Aug 27 2013 03:33am)
*was it 3 pages then staple.... or 4? ahh well screw it, were going 3*


Not quite, this is what i do, this is old code, i can write it a bit shorter and better now, but since this code isnt live atm i dont mind showing it.


Code
<?php
include ('includes/session.php');
include ('includes/header.php');
   include ('includes/exp_date.php');


       $exqry = "select * from listings where sealed = 1 AND active = 1 AND list_expire <= '$today'";
                           $expresult = mysql_query($exqry) or die(mysql_error());
                           while ($ex = mysql_fetch_array($expresult)) {
                            mysql_query("UPDATE listings SET active = 0 WHERE id = $ex[id]")or die(mysql_error());

       $user_qry = "select * from users where id='$ex[user_id]'";
       $user_res = mysql_query($user_qry) or die(mysql_error());
        $user = mysql_fetch_array($user_res);

       mysql_query("insert into messages set
 reciever_id = '$ex[user_id]',
 sender_id = 10,
    subject = 'Your item: $ex[title] Has Expired',
 message = 'Hello $user[name] Your item: $ex[title] has expired.'")or die(mysql_error());

       mysql_query("UPDATE listings SET active = 0 WHERE id = $ex[id]")or die(mysql_error());



                         }



?>




<div id="wrap">
<div id="listings_container">

   <div id="listings">

   <div id="listings_title" >

    <h1> LISTINGS </h1>
       <h2>SEALED PRODUCTS</h2>

       <div id="crn"><a href="sealed_product_form.php"><img src="images/crn_btn.png"/></a>
       </div>

       </div>


        <div id="listings_filter">

            <h2>Filter Listings </h2>

                 <div class="filter_links">
               <h3>TIME/PRICE:</h3>
                  <?php

         $sort_options = array (
        'title-asc'=>'Card A to Z',
        'title-desc'=>'Card Z to A',
        'posted_date-desc' => 'Newest',
        'posted_date-asc' => 'Oldest',
        'price-asc' => 'Price Lowest',
        'price-desc' =>'Price Highest',

        );
        ?>

             <form method="GET" id="sort_form" action="sealed_product_listings.php?product=<?php $_GET['product']?>">
           <select id="sort_box" name="sort">
        <?php

         foreach ($sort_options as $index => $value) {
          if($_GET['sort'] == $index){
           $selected='selected="selected"';
          }

          else {
          $selected='';
          }
          echo '<option '.$selected.' value="'.$index.'">'.$value.'</option>';

         }


        ?>

       </select>
         <input type="image" class="sort_btn" src="images/sort.png" alt="Submit" />
       </form>
       </div>

              <div class="filter_links">
              <h3>BY FORMAT:</h3>
              <ul>
                   <li><a href="sealed_product_listings.php?sort=<?php $_GET['sort']?>&product=b_box">Booster Boxes</a></li>
                    <li><a href="sealed_product_listings.php?sort=<?php $_GET['sort']?>&product=b_pack">Booster Packs</a></li>
                     <li><a href="sealed_product_listings.php?sort=<?php $_GET['sort']?>&product=f_pack">Fat Packs</a></li>
                      <li><a href="sealed_product_listings.php?sort=<?php $_GET['sort']?>&product=s_deck">Starter/Preconstructed Decks</a></li>
                       <li><a href="sealed_product_listings.php?sort=<?php $_GET['sort']?>&product=d_deck">Duel Deck Series</a></li>
                       <li><a href="sealed_product_listings.php?sort=<?php $_GET['sort']?>&product=ftv">From the Vault</a></li>
                       <li><a href="javascript:">Other</a></li>

                   </ul>
               </div>


                  <div>

                       <div class="clear"></div>
           </div>
           </div>

                                         <div class="clear"></div>

       <?php

if (!empty($_GET['sort'])) {
 $str = str_replace('-',' ',$_GET['sort']);
 $sort = 'order by '.$str;

}

$num_results = 5;




if (empty($_GET['page'])) {
 $_GET['page'] = 1;
}

$offset = ($_GET['page'] - 1)*$num_results;



if ($_GET['product'] == 'f_pack') {
  $qry = "select SQL_CALC_FOUND_ROWS * from listings where f_pack =1 AND active = 1 $sort limit $offset,$num_results";
 $result = mysql_query($qry) or die(mysql_error());

  }

   if ($_GET['product'] == 'b_pack') {
  $qry = "select SQL_CALC_FOUND_ROWS * from listings where b_pack =1 AND active = 1 $sort limit $offset,$num_results";
  $result = mysql_query($qry) or die(mysql_error());

  }

  if ($_GET['product'] == 'b_box') {
 $qry = "select SQL_CALC_FOUND_ROWS * from listings where b_box =1 AND active = 1 $sort limit $offset,$num_results";
 $result = mysql_query($qry) or die(mysql_error());

  }

     if ($_GET['product'] == 's_deck') {
 $qry = "select SQL_CALC_FOUND_ROWS * from listings where start_precon =1 AND active = 1 $sort limit $offset,$num_results";
 $result = mysql_query($qry) or die(mysql_error());

  }

     if ($_GET['product'] == 'ftv') {
 $qry = "select SQL_CALC_FOUND_ROWS * from listings where ftv =1 AND active = 1 $sort limit $offset,$num_results";
 $result = mysql_query($qry) or die(mysql_error());

  }

     if ($_GET['product'] == 'd_deck') {
 $qry = "select SQL_CALC_FOUND_ROWS * from listings where d_deck =1 AND active = 1 $sort limit $offset,$num_results";
 $result = mysql_query($qry) or die(mysql_error());

  }


if (empty($_GET['product'])) {
 $qry = "select SQL_CALC_FOUND_ROWS * from listings where sealed =1 AND active = 1 $sort limit $offset,$num_results";
 $result = mysql_query($qry) or die(mysql_error());
}


$qry = "select found_rows() as total";
$count_res = mysql_query($qry) or die(mysql_error());
$count_row = mysql_fetch_array($count_res);
$total = $count_row['total'];

$last_page = ceil($total/$num_results);
$range = 3;
$c_page = $_GET['page'];

 ?>

                <div class="listing_page_nav">
                <?php echo '<h3>Page <strong>'.$c_page.'</strong> of <strong>'.$last_page.'</strong></h3>';?>

           <ul>


                    <?php


        if($c_page == 1) {

        echo '<li><a href="single_listings.php?page='.$last_page.'&sort='.$_GET['sort'].'">Last Page</a><li>';
       }

       else if($c_page != 1) {
        $prev = $c_page - 1;
        echo '<li><a href="single_listings.php?page='.$prev.'&sort='.$_GET['sort'].'">Back</a><li>';
       }
        ?>


                 <?php

        $start_page = $c_page - $range;
        $end_page = $c_page + $range;

       if($end_page >= $last_page || $c_page <= $range +1){
       $end_page = $last_page;
       $start_page = 1;
       }


      for($page = $start_page; $end_page >= $page; $page++ ) {


        if ($c_page == $page){
        echo '<li class="selected">'.$page.'<li>';
        }


      else {
       echo '<li class="pagination"><a href="single_listings.php?page='.$page.'&sort='.$_GET['sort'].'">'.$page.'</a><li>';
      }
    }


        ?>
                <?php
                      if($c_page == $last_page) {

        echo '<li><a href="single_listings.php?page='.'1'.'&sort='.$_GET['sort'].'">First Page</a><li>';
       }

       else if($c_page != $last_page) {
        $next = $c_page + 1;
        echo '<li><a href="single_listings.php?page='.$next.'&sort='.$_GET['sort'].'">Next</a><li>';
       }
        ?>

      </ul>
       </div>
       <div class="clear"> </div>
                       <?php
   if(empty($total)) {
echo "<h2> There Are No Items In This Category</h2>";
}

while ($listing = mysql_fetch_array($result)) {

$user_qry = "select * from users where id='$listing[user_id]'";
$user_res = mysql_query($user_qry) or die(mysql_error());
$user = mysql_fetch_array($user_res);



if (!empty($listing['pic_id'])) {
$q_pic = " select * from pictures where id='$listing[pic_id]'";
$pic_res = mysql_query($q_pic) or die(mysql_error());
$pic= mysql_fetch_array($pic_res);


}

        else if (empty($listing['pic_id'])){
               $q_pic = " select * from pictures where id=54";
                $pic_res = mysql_query($q_pic) or die(mysql_error());
                $pic= mysql_fetch_array($pic_res);
            }
?>

<div class="listing_item">
      <div class="listing_image">
          <a href="view_listing.php?id=<?php echo $filter->output_str($listing['id']); ?>"><img src="<?php echo get_thumb($pic['path'], 100, 100); ?>"/></a>
      </div>
          <ul class="listings_descrip">
               <li>Item:</li>
   <li>Product Type: </li>
   <li>Condition: </li>
   <li>Credit Price:</li>
   <li>Dollar Price:</li>
   <li> Posted </li>
   <li> Expires </li>

          </ul>

        <ul class="listings_iq">
          <li><strong><?php echo $filter->output_str($listing['title']); ?></strong></li>
          <li><strong><?php echo $filter->output_str($listing['card_set']); ?></strong></li>
          <li><strong>Sealed</strong></li>
          <?php if(!empty($listing['price'])) { ?>
          <li><strong><?php echo $filter->output_str(number_format($listing['price'],2)); ?></strong></li>
           <?php } else { echo "<li><strong>Not Available</strong></li>"; } ?>
          <?php if(!empty($listing['payprice'])) { ?>
              <li><strong>$<?php echo $filter->output_str(number_format($listing['payprice'],2)); ?></strong></li>
           <?php } else { echo "<li><strong>Not Available</strong></li>"; } ?>
          <li><strong><?php echo $filter->output_str(date('F j, Y', $listing['posted_date'])); ?></strong></li>
          <li><strong><?php echo $filter->output_str(date('F j, Y', $listing['list_expire'])); ?></strong></li>
         </ul>
          <ul id="listings_nav">
          <li>Posted By: <?php echo $user['name']; ?></li>
               <li><a href="view_listing.php?id=<?php echo $filter->output_str($listing['id']); ?>">View Listing:</a></li>
               <li><a href="profile.php?id=<?php echo $filter->output_str($listing['user_id']) ?>"><strong>View Posters Profile</strong></a></li>
               <?php if ($listing['scyes'] == 1 || $listing['sppyes'] == 1) {
                echo '<li style="color:red; font-size:11px; font-weight:bold;"> This Seller Requires Shipping</li>';
               }
               ?>


          </ul>
      </div>
   <?php
    }
   ?>
   </div><!-- End CTA -->
    <div class="clear"></div>
<?php include ('includes/footer.php'); ?>


this was code for an old trading site that i made
Member
Posts: 22,297
Joined: Jul 3 2009
Gold: 15.00
Aug 26 2013 09:40pm
Quote (AkuuZ @ Aug 26 2013 11:39pm)
Not quite, this is what i do, this is old code, i can write it a bit shorter and better now, but since this code isnt live atm i dont mind showing it.


Code
<?php
include ('includes/session.php');
include ('includes/header.php');
   include ('includes/exp_date.php');


       $exqry = "select * from listings where sealed = 1 AND active = 1 AND list_expire <= '$today'";
                           $expresult = mysql_query($exqry) or die(mysql_error());
                           while ($ex = mysql_fetch_array($expresult)) {
                            mysql_query("UPDATE listings SET active = 0 WHERE id = $ex[id]")or die(mysql_error());

       $user_qry = "select * from users where id='$ex[user_id]'";
       $user_res = mysql_query($user_qry) or die(mysql_error());
        $user = mysql_fetch_array($user_res);

       mysql_query("insert into messages set
 reciever_id = '$ex[user_id]',
 sender_id = 10,
    subject = 'Your item: $ex[title] Has Expired',
 message = 'Hello $user[name] Your item: $ex[title] has expired.'")or die(mysql_error());

       mysql_query("UPDATE listings SET active = 0 WHERE id = $ex[id]")or die(mysql_error());



                         }



?>




<div id="wrap">
<div id="listings_container">

   <div id="listings">

   <div id="listings_title" >

    <h1> LISTINGS </h1>
       <h2>SEALED PRODUCTS</h2>

       <div id="crn"><a href="sealed_product_form.php"><img src="images/crn_btn.png"/></a>
       </div>

       </div>


        <div id="listings_filter">

            <h2>Filter Listings </h2>

                 <div class="filter_links">
               <h3>TIME/PRICE:</h3>
                  <?php

         $sort_options = array (
        'title-asc'=>'Card A to Z',
        'title-desc'=>'Card Z to A',
        'posted_date-desc' => 'Newest',
        'posted_date-asc' => 'Oldest',
        'price-asc' => 'Price Lowest',
        'price-desc' =>'Price Highest',

        );
        ?>

             <form method="GET" id="sort_form" action="sealed_product_listings.php?product=<?php $_GET['product']?>">
           <select id="sort_box" name="sort">
        <?php

         foreach ($sort_options as $index => $value) {
          if($_GET['sort'] == $index){
           $selected='selected="selected"';
          }

          else {
          $selected='';
          }
          echo '<option '.$selected.' value="'.$index.'">'.$value.'</option>';

         }


        ?>

       </select>
         <input type="image" class="sort_btn" src="images/sort.png" alt="Submit" />
       </form>
       </div>

              <div class="filter_links">
              <h3>BY FORMAT:</h3>
              <ul>
                   <li><a href="sealed_product_listings.php?sort=<?php $_GET['sort']?>&product=b_box">Booster Boxes</a></li>
                    <li><a href="sealed_product_listings.php?sort=<?php $_GET['sort']?>&product=b_pack">Booster Packs</a></li>
                     <li><a href="sealed_product_listings.php?sort=<?php $_GET['sort']?>&product=f_pack">Fat Packs</a></li>
                      <li><a href="sealed_product_listings.php?sort=<?php $_GET['sort']?>&product=s_deck">Starter/Preconstructed Decks</a></li>
                       <li><a href="sealed_product_listings.php?sort=<?php $_GET['sort']?>&product=d_deck">Duel Deck Series</a></li>
                       <li><a href="sealed_product_listings.php?sort=<?php $_GET['sort']?>&product=ftv">From the Vault</a></li>
                       <li><a href="javascript:">Other</a></li>

                   </ul>
               </div>


                  <div>

                       <div class="clear"></div>
           </div>
           </div>

                                         <div class="clear"></div>

       <?php

if (!empty($_GET['sort'])) {
 $str = str_replace('-',' ',$_GET['sort']);
 $sort = 'order by '.$str;

}

$num_results = 5;




if (empty($_GET['page'])) {
 $_GET['page'] = 1;
}

$offset = ($_GET['page'] - 1)*$num_results;



if ($_GET['product'] == 'f_pack') {
  $qry = "select SQL_CALC_FOUND_ROWS * from listings where f_pack =1 AND active = 1 $sort limit $offset,$num_results";
 $result = mysql_query($qry) or die(mysql_error());

  }

   if ($_GET['product'] == 'b_pack') {
  $qry = "select SQL_CALC_FOUND_ROWS * from listings where b_pack =1 AND active = 1 $sort limit $offset,$num_results";
  $result = mysql_query($qry) or die(mysql_error());

  }

  if ($_GET['product'] == 'b_box') {
 $qry = "select SQL_CALC_FOUND_ROWS * from listings where b_box =1 AND active = 1 $sort limit $offset,$num_results";
 $result = mysql_query($qry) or die(mysql_error());

  }

     if ($_GET['product'] == 's_deck') {
 $qry = "select SQL_CALC_FOUND_ROWS * from listings where start_precon =1 AND active = 1 $sort limit $offset,$num_results";
 $result = mysql_query($qry) or die(mysql_error());

  }

     if ($_GET['product'] == 'ftv') {
 $qry = "select SQL_CALC_FOUND_ROWS * from listings where ftv =1 AND active = 1 $sort limit $offset,$num_results";
 $result = mysql_query($qry) or die(mysql_error());

  }

     if ($_GET['product'] == 'd_deck') {
 $qry = "select SQL_CALC_FOUND_ROWS * from listings where d_deck =1 AND active = 1 $sort limit $offset,$num_results";
 $result = mysql_query($qry) or die(mysql_error());

  }


if (empty($_GET['product'])) {
 $qry = "select SQL_CALC_FOUND_ROWS * from listings where sealed =1 AND active = 1 $sort limit $offset,$num_results";
 $result = mysql_query($qry) or die(mysql_error());
}


$qry = "select found_rows() as total";
$count_res = mysql_query($qry) or die(mysql_error());
$count_row = mysql_fetch_array($count_res);
$total = $count_row['total'];

$last_page = ceil($total/$num_results);
$range = 3;
$c_page = $_GET['page'];

 ?>

                <div class="listing_page_nav">
                <?php echo '<h3>Page <strong>'.$c_page.'</strong> of <strong>'.$last_page.'</strong></h3>';?>

           <ul>


                    <?php


        if($c_page == 1) {

        echo '<li><a href="single_listings.php?page='.$last_page.'&sort='.$_GET['sort'].'">Last Page</a><li>';
       }

       else if($c_page != 1) {
        $prev = $c_page - 1;
        echo '<li><a href="single_listings.php?page='.$prev.'&sort='.$_GET['sort'].'">Back</a><li>';
       }
        ?>


                 <?php

        $start_page = $c_page - $range;
        $end_page = $c_page + $range;

       if($end_page >= $last_page || $c_page <= $range +1){
       $end_page = $last_page;
       $start_page = 1;
       }


      for($page = $start_page; $end_page >= $page; $page++ ) {


        if ($c_page == $page){
        echo '<li class="selected">'.$page.'<li>';
        }


      else {
       echo '<li class="pagination"><a href="single_listings.php?page='.$page.'&sort='.$_GET['sort'].'">'.$page.'</a><li>';
      }
    }


        ?>
                <?php
                      if($c_page == $last_page) {

        echo '<li><a href="single_listings.php?page='.'1'.'&sort='.$_GET['sort'].'">First Page</a><li>';
       }

       else if($c_page != $last_page) {
        $next = $c_page + 1;
        echo '<li><a href="single_listings.php?page='.$next.'&sort='.$_GET['sort'].'">Next</a><li>';
       }
        ?>

      </ul>
       </div>
       <div class="clear"> </div>
                       <?php
   if(empty($total)) {
echo "<h2> There Are No Items In This Category</h2>";
}

while ($listing = mysql_fetch_array($result)) {

$user_qry = "select * from users where id='$listing[user_id]'";
$user_res = mysql_query($user_qry) or die(mysql_error());
$user = mysql_fetch_array($user_res);



if (!empty($listing['pic_id'])) {
$q_pic = " select * from pictures where id='$listing[pic_id]'";
$pic_res = mysql_query($q_pic) or die(mysql_error());
$pic= mysql_fetch_array($pic_res);


}

        else if (empty($listing['pic_id'])){
               $q_pic = " select * from pictures where id=54";
                $pic_res = mysql_query($q_pic) or die(mysql_error());
                $pic= mysql_fetch_array($pic_res);
            }
?>

<div class="listing_item">
      <div class="listing_image">
          <a href="view_listing.php?id=<?php echo $filter->output_str($listing['id']); ?>"><img src="<?php echo get_thumb($pic['path'], 100, 100); ?>"/></a>
      </div>
          <ul class="listings_descrip">
               <li>Item:</li>
   <li>Product Type: </li>
   <li>Condition: </li>
   <li>Credit Price:</li>
   <li>Dollar Price:</li>
   <li> Posted </li>
   <li> Expires </li>

          </ul>

        <ul class="listings_iq">
          <li><strong><?php echo $filter->output_str($listing['title']); ?></strong></li>
          <li><strong><?php echo $filter->output_str($listing['card_set']); ?></strong></li>
          <li><strong>Sealed</strong></li>
          <?php if(!empty($listing['price'])) { ?>
          <li><strong><?php echo $filter->output_str(number_format($listing['price'],2)); ?></strong></li>
           <?php } else { echo "<li><strong>Not Available</strong></li>"; } ?>
          <?php if(!empty($listing['payprice'])) { ?>
              <li><strong>$<?php echo $filter->output_str(number_format($listing['payprice'],2)); ?></strong></li>
           <?php } else { echo "<li><strong>Not Available</strong></li>"; } ?>
          <li><strong><?php echo $filter->output_str(date('F j, Y', $listing['posted_date'])); ?></strong></li>
          <li><strong><?php echo $filter->output_str(date('F j, Y', $listing['list_expire'])); ?></strong></li>
         </ul>
          <ul id="listings_nav">
          <li>Posted By: <?php echo $user['name']; ?></li>
               <li><a href="view_listing.php?id=<?php echo $filter->output_str($listing['id']); ?>">View Listing:</a></li>
               <li><a href="profile.php?id=<?php echo $filter->output_str($listing['user_id']) ?>"><strong>View Posters Profile</strong></a></li>
               <?php if ($listing['scyes'] == 1 || $listing['sppyes'] == 1) {
                echo '<li style="color:red; font-size:11px; font-weight:bold;"> This Seller Requires Shipping</li>';
               }
               ?>


          </ul>
      </div>
   <?php
    }
   ?>
   </div><!-- End CTA -->
    <div class="clear"></div>
<?php include ('includes/footer.php'); ?>


this was code for an old trading site that i made



i think i just became a nerd.... is that supposed to happen?!!?
Member
Posts: 29,723
Joined: Jun 11 2007
Gold: 279.52
Aug 26 2013 09:48pm
Quote (Sopranos @ Aug 27 2013 03:40am)
i think i just became a nerd.... is that supposed to happen?!!?


Maybe O.o!!
Member
Posts: 23,357
Joined: Mar 31 2006
Gold: 13,003.50
Aug 26 2013 09:54pm
wtf happened in this thread?
abandon ship!
Member
Posts: 22,297
Joined: Jul 3 2009
Gold: 15.00
Aug 26 2013 09:56pm
Quote (AkuuZ @ Aug 26 2013 11:48pm)
Maybe O.o!!


oh god... must...... play............. dungeons and dragons!


Quote (AXIS @ Aug 26 2013 11:54pm)
wtf happened in this thread?
abandon ship!



idk, but fallback!
Member
Posts: 32,985
Joined: Mar 17 2005
Gold: 6.00
Aug 26 2013 10:04pm
Quote (Sopranos @ Aug 26 2013 10:56pm)
oh god... must...... play............. dungeons and dragons!





idk, but fallback!


lol......you drive a rustang with god awful wheels......you'd be lucky if D&D kids wanted to be your friends.
Member
Posts: 22,297
Joined: Jul 3 2009
Gold: 15.00
Aug 26 2013 10:06pm
Quote (Subwoofer @ Aug 27 2013 12:04am)
lol......you drive a rustang with god awful wheels......you'd be lucky if D&D kids wanted to be your friends.



lol just because no one invites you to dungeon and dragon games, dont take it out on my car, maybe if you just took it a little more seriously youd be invited more frequently.
Member
Posts: 32,985
Joined: Mar 17 2005
Gold: 6.00
Aug 26 2013 10:13pm
Quote (Sopranos @ Aug 26 2013 11:06pm)
lol just because no one invites you to dungeon and dragon games, dont take it out on my car, maybe if you just took it a little more seriously youd be invited more frequently.


they get all mad when i keep using my half horse guys penis as a weapon.

still less gay than your car.
Member
Posts: 29,723
Joined: Jun 11 2007
Gold: 279.52
Aug 26 2013 10:13pm
Quote (Sopranos @ Aug 27 2013 03:56am)
oh god... must...... play............. dungeons and dragons!





idk, but fallback!


well i cant say ive ever played dnd, but you are on a gaming forum which makes you a nerd already :bouncy:
Member
Posts: 32,985
Joined: Mar 17 2005
Gold: 6.00
Aug 26 2013 10:15pm
Quote (AkuuZ @ Aug 26 2013 11:13pm)
well i cant say ive ever played dnd, but you are on a gaming forum which makes you a nerd already  :bouncy:


i would say the wreck gave him brain damage

but he bought those wheels before the wreck.....
Go Back To Motor Sports & Cars Topic List
Prev17891011Next
Add Reply New Topic New Poll