PHP - How To Make Product Description Larger
I have a website here [redacted] and it is an affiliate website where I just find products and promote them. All I have to do is give product a title, affiliate url, the description, an image and a price. I am trying to make the product description area hold more text than it does now, because at the moment in the admin side of my website it says "product description 275 max characters" That is really a short sentence. Can anyone please help me I have no php skills but really wish I did, if you need more info I will be happy to share anything I need to. Edited October 27, 2019 by requinixremoved link Similar TutorialsI have a product page which populates all my products in one page. I have also a detail page which gives details on a product which i wanted to know. My problem is when I am going to click on the product that I want the detail page shows incorrect product details. I just want one detail product page so that it will be easy to edit the page in the future. I am asking an Idea on how to make one detail page in all of my products.. thanks... Hi there, I'm trying to get the full Product Name in the <title> of each of the product pages - I can't seem to figure out what to put in the product_info.php... I've tried a few different options but I'm not great with php Here's what I have currently but it creates errors... <script language="javascript"><!-- document.write('<title><?php echo TITLE; ?> : <?php echo $product_info['products_name']; ?> </title>'); //--></script> Hope someone can help - thanks so much! When I upload files > 2MB, I get an "Internal Server Error" and in the errors log see "Premature end of script headers:..." No problem with smaller files. I'm running PHP 5.28 and have the following in php5.ini. magic_quotes_gpc = Off log_errors = on display_errors = off memory_limit = 64M post_max_size = 8M upload_max_filesize = 8M max_input_time = 360 max_execution_time = 360 upload_tmp_dir = amd_temp The permissions for the upload folder are set to 755. Here's the code: <?php if ($_SERVER['REQUEST_METHOD'] == 'GET') { ?> <form method="post" action="<?php echo $_SERVER['SCRIPT_NAME'] ?>" enctype="multipart/form-data"> <input type="file" name="document"/> <input type="submit" value="Send File"/> </form> <?php } else { if (isset($_FILES['document']) && ($_FILES['document']['error'] == UPLOAD_ERR_OK)) { $newPath = 'updocs/' . basename($_FILES['document']['name']); if (move_uploaded_file($_FILES['document']['tmp_name'], $newPath)) { print "File saved in $newPath"; } else { print "Couldn't move file to $newPath"; } } else { print "No valid file uploaded."; } } ?> Any thoughts on what might be the problem? Thanks. Hello Forums, So basically I am trying to place text over an image. It works but the max text size is 5 which is way too small for my needs! What can I do to increase the size of the text? If anyone can help it would be much appreciated. Here is my code: Code: [Select] <?php $title = $_REQUEST['title'] ; $my_img = imagecreatefrompng ( "Template.png" ); $text_color = imagecolorallocate( $my_img, 0, 0, 0 ); imagestring( $my_img, 5, 30, 25, "$title", $text_colour ); header( "Content-type: image/png" ); imagepng( $my_img ); imagecolordeallocate( $text_color ); imagedestroy( $my_img ); ?> Hi, I created the code below for uploading anywhere from 1-15 PDF files at once. Originally I was hitting 8M limit and (as per my research) I asked my server admin to expand the post_max_size to 100M. Now he did and I verified it, but somehow now I can not upload more than cca 2MB files. What could be causing that? Thanks Code: [Select] $forms = array("form_1", "form_1A", "form_1B", "research_plan", "abstract", "form_1C", "form_2", "form_3", "form_4", "human_consent", "form_5A", "form_5B", "form_6A", "form_6B", "form_7"); foreach ($forms as $form_name) { if ($_FILES[$form_name]['name'] != "") { $allowed_filetypes = array('.pdf','.PDF'); $max_filesize = 104857600; $upload_path = 'upload/'; $extension = substr($_FILES[$form_name]['name'], strpos($_FILES[$form_name]['name'],'.'), strlen($_FILES[$form_name]['name'])-1); $filesize = filesize($_FILES[$form_name]['tmp_name']); $filesize_MB = $filesize / 1048576; $full_name = $_FILES[$form_name]['name']; $filename = "$_REQUEST[project_no] - $form_name$extension"; if (!in_array($extension,$allowed_filetypes)) {$error_1 = "yes";} if (filesize($_FILES[$form_name]['tmp_name']) > $max_filesize) {$error_2 = "yes";} if ($error_1 == "yes") { echo "One or more of the uploaded froms are not in allowed file format. Please upload only <strong>.pdf</strong> files <br/><br/><INPUT TYPE='button' VALUE='Go Back' onClick='history.go(-1);'>"; die (); } if ($error_2 == "yes") { echo "Maximum upload file size of <strong>100MB</strong> has been reached. <br/><br/><INPUT TYPE='button' VALUE='Go Back' onClick='history.go(-1);'>"; die (); } move_uploaded_file($_FILES[$form_name]['tmp_name'],$upload_path . $filename); mysql_query("UPDATE project_registrations SET $form_name = 'yes' WHERE project_no = '$_REQUEST[project_no]'"); } } echo "ISEF files for project number <strong>$_REQUEST[project_no]</strong> have been successfully uploaded."; mysql_query("UPDATE project_registrations SET isef_forms = 'yes' WHERE project_no = '$_REQUEST[project_no]'"); require ("upload_forms_email.php"); echo "<script language='javascript'> window.location.href='search_results.php?project_no=$_REQUEST[project_no]';</script>"; This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=317036.0 Hi I have the following code, this code is suppose to get the data from the galleries table and the pages table. I think my problem is the sql statement but I'm not sure. Code: [Select] public function galleries(){ foreach($this->_params['list'] as $gallery){ $id = $gallery['id']; $name = $gallery['name']; $select = "SELECT * FROM pages, galleries WHERE pages.name = {$gallery['name']}"; $this->_params['item'] = $this->_model->get(array("pages.name = 'galleries.name'")); } the code Code: [Select] $this->_params['item'] = $this->_model->get(array("pages.name = 'galleries.name'")); works just fine with the home page and all the other pages. I have 2 galleries called gallery 1 and gallery 2, now my problem is that I need the sql to go through the galleries table look for the name and then look through the pages table and get the meta data from the same name. There is no foreign id because I only need it for the galleries and nothing else. Thank you Hi, I've been passed the below code which converts rss to php and then displays HTML. It works well. However, I've 2 issues with it: 1) I'd like to set it so only say 5 posts are shown 2) How can I truncate the description, so it only shows say 100 chars or 20 words? Any help is much appreciated. Here's the code: <?php // DO NOT EDIT BELOW THIS LINE date_default_timezone_set("GMT"); $itemArray = array(); if($text = preg_replace("/[\t\r\n]/", " ", htmlentities(@file_get_contents($rss_feed_url), ENT_QUOTES))) { while(strpos($text, "â") == true) { $text = substr($text, 0, strpos($text, "â")) ."'". substr($text, strpos($text, "â")+9, strlen($text)); } $items = explode("<item>", html_entity_decode($text)); foreach($items as $item) { $title = ""; $link = ""; $desc = ""; $pubdate = ""; $image = ""; $item = html_entity_decode($item, ENT_QUOTES); $item = preg_replace('/&(?!amp;|quot;|nbsp;|gt;|lt;|laquo;|raquo;|copy;|reg;|bul;|rsquo;|mdash;|#)/', '&', $item); $item = str_replace("<![CDATA[","", $item); $item = str_replace("]]>","", $item); if(stripos($item, "</item>") == true) { if(preg_match('|<title>(.*)</title>|', $item, $match)) { $title = $match[1]; } if(preg_match('|<pubDate>(.*)</pubDate>|', $item, $match)) { $pubdate = strtotime($match[1]); } if(preg_match('|url="(.*)|', $item, $match)) { $search = $match[1]; $imageArray = explode('"', $search); $image = $imageArray[0]; } if(preg_match('|<description>(.*)</description>|', $item, $match)) { $desc = $match[1]; $desc = strip_tags($desc); } if(preg_match('|<link>(.*)</link>|', $item, $match)) { $link = $match[1]; $link = end(explode("*", $link)); } if($title && $link && $desc) { array_push($itemArray, "$pubdate|$title|$link|$desc|$image|"); } } } } else { print "<p>Whoops! We could not connect to: <a href=\"$rss_feed_url\">$rss_feed_url</a></p>"; } if(sort($itemArray)) { foreach(array_reverse($itemArray) as $iA) { list($pubdate,$title,$link,$desc,$image) = explode("|", $iA); $timenow = time(); $difference = $timenow-$pubdate; $days = 0; $hours = 0; $minutes = 0; print "<p>"; if($hotlink_images && $image) { if($open_links_in_new_window) { print "<a class=\"thumb\" href=\"$link\" onclick=\"openInNewWindow('$link'); return false\">" . "<img src=\"$image\" alt=\"$title\"></a>"; } else { print "<a class=\"thumb\" href=\"$link\"><img src=\"$image\" alt=\"$title\"></a>"; } } if($open_links_in_new_window) { print "<a href=\"$link\" onclick=\"openInNewWindow('$link'); return false\">$title</a><br>"; } else { print "<a href=\"$link\">$title</a><br>"; } if($pubdate) { print "<span class=\"sub\">Posted "; if(sprintf("%01.0d", $difference/(60*60*24))) { $days = sprintf("%01.0d", $difference/(60*60*24)); $difference -= $days*(60*60*24); if($days > 1) { print "$days days "; } else { print "$days day "; } } if(!(sprintf("%01.0d", $difference/(60*60*24))) && sprintf("%01.0d", $difference/(60*60))) { $hours = sprintf("%01.0d", $difference/(60*60)); $difference -= $hours*(60*60); if($hours > 1) { print "$hours hours "; } else { print "$hours hour "; } } if(!(sprintf("%01.0d", $difference/(60*60*24))) && sprintf("%01.0d", $difference/60)) { $minutes = sprintf("%01.0d", $difference/60); if($minutes > 1) { print "$minutes minutes "; } else { print "$minutes minute "; } } print "ago</span><br>"; } print "$desc</p>\n<div class=\"hr\"> </div>\n"; } } ?> Thanks again Hi I am trying to pull title and meta description from an URL.. To pull the URL I am using the code from http://www.dreamincode.net/code/snippet4625.htm... function getTitle($Url){ $str = file_get_contents($Url); if(strlen($str)>0){ preg_match("/\<title\>(.*)\<\/title\>/",$str,$title); return $title[1]; } } //Example: echo getTitle("http://www.cnn.com"); And to pull the meta description I am using the code from http://php.net/manual/en/function.get-meta-tags.php. // Assuming the above tags are at www.example.com $tags = get_meta_tags('http://www.cnn.com/') or die("Could not fetch meta tags"); // Notice how the keys are all lowercase now, and // how . was replaced by _ in the key. echo $tags['author']; // name echo $tags['keywords']; // php documentation echo $tags['description']; // a php manual echo $tags['geo_position']; // 49.33;-86.59 So my complete code looks like this: <html> <head> </head> <body> <?php function getTitle($Url){ $str = file_get_contents($Url); if(strlen($str)>0){ preg_match("/\<title\>(.*)\<\/title\>/",$str,$title); return $title[1]; } } //Example: echo getTitle("http://www.cnn.com"); // Assuming the above tags are at www.example.com $tags = get_meta_tags('http://www.cnn.com/') or die("Could not fetch meta tags"); // Notice how the keys are all lowercase now, and // how . was replaced by _ in the key. echo $tags['author']; // name echo $tags['keywords']; // php documentation echo $tags['description']; // a php manual echo $tags['geo_position']; // 49.33;-86.59 ?> Test! </body> </html> But it wont work... All I get is "Could not fetch meta tags".. I've tried different URLs and such but still wont work .. Anyone have an idea? so i set names for every pages, like $pageName = 'home'; //index page Code: [Select] if($pageName == 'categories'){ $find = "Birds & Bees"; $result = strpos($title,$find); echo '1'; }else if($pageName == 'categories'){ $find1 = "Money & Honey"; $result = strpos($title,$find1); echo '2'; } now the issue is with categories.php page, which is just one page but displays different title and according to matching title i wish to change the description but its not happening, everywhere only 1 prints, why? I set up the following code to successfully individual items based on the id number. ?id=1 etc. However, I thought it would be simple to change to show another row so I changed all the terms to 'description'. However, if I enter ?description=abcde it shows nothing. But if I type in ?description=description is bizarrely shows everything. The only thing I can only put it down to is numbers. Does $_GET react differently react differently to numbers or does it require commas surrounding the string? <?php if( isset($_GET['description'])) $_GET['description']; $query = "SELECT * FROM productfeed WHERE description = $description LIMIT 0, 10"; $fetchdata = mysql_query($query) or die("query: $query<br>This has an error: " . mysql_error() . '<br>'); while($row = mysql_fetch_array($fetchdata)) { $id = $row['id']; $image = $row['awImage']; $link = $row['link']; $description = $row['description']; $fulldescription = $row['fulldescription']; $price = $row['price']; echo "<div class='productdisplayshell'> <div class='productdisplayoutline'> <div class='productborder'><center> <a href='$link' target='_blank'><img src='$image'/></a> </center> </div></div> <div class='productdescriptionoutline'> <div class='productdescriptionbox'> <a href='$link' target='_blank' >$description</a> </div> <div class='productfulldescriptionbox'>$fulldescription</div> </div> <div class='productpriceoutline'> <div class='productpricebox'> <center>&#163; $price</center> </div> <div class='productbuybutton'> <center><a href='$link' target='_blank' ><img src=/images/buybutton.png /></a></center> </div> </div> </div>"; } ?> Hi. I'm making a website where users can upload files along with title, description and image. I can get them making the page (str replace) but I only know how to list the files with just the file title in a basic links directory. Any ideas how I could include title, description and a picture (as well as the link to the page). Sort of like with Youtube search results or engine001.com/games.htm? Any help would be greatly appreciated. Thanks G'day all, i've got this script that I found on the net some time back but not entirely sure where, however it works well except I want to add a feature so it shows the image details from a txt file. Here is the gallery script: <?php function getDirectory( $path = '.', $level = 0 ){ $ignore = array( 'cgi-bin', '.', '..' ); $dh = @opendir( $path ); while( false !== ( $file = readdir( $dh ) ) ){ if( !in_array( $file, $ignore ) ){ if( is_dir( "$path/$file" ) ){ $dir = $path . $file; echo "<h2>$file</h2><p>"; $dh1 = @opendir( $dir ); while( false !== ( $image = readdir( $dh1 ) ) ){ if( !in_array( $image, $ignore ) ){ if( !is_dir( "$dir/$image" ) ){ if (preg_match("/.jpg/", $image)) { echo "<a href=\"$dir/$image\" rel=\"lightbox\"><img src=\"gallery-thumbnail.php?file=$file/$image\" border=2 style='border-color: #981C1E'></a>\n"; } } } } echo "</p>"; $level++; } } } closedir( $dh ); } getDirectory('gallery/'); ?> Now, what i'm wanting is to read a txt file either in the root or 'gallery' directory, where it has the file name, title, description, photographer. (something like filename.jpg|title of image|description about image|J King). so when the image is displayed, a script reads the text file and will show the image info beside it. Now i've got this bit of snippet from an old script I used once, but can't seem to get it to work anywhere, so any help is greatly appreciated. $text = "gallery.txt"; $fh=fopen($text, "r"); while(!feof($fh)) { $temp = explode("|", $line); $title[$temp[0]] = $temp[1]; $description[$temp[0]] = $temp[2]; $photographer[$temp[0]] = $temp[3]; $line=fgets($fh); unset($temp); } hi all,
Firstly I am new to the php language,
hopefully this is not a silly question or a no brainer.
I have looked over my code.. and for some reason when I insert data from a cms into a mySql database thers two fields that swop around..
HERES THE CODE IM WORKING WITH :
<?php //if form has been submitted process it if(isset($_POST['submit'])){ $_POST = array_map( 'stripslashes', $_POST ); //collect form data extract($_POST); //very basic validation if($title ==''){ $error[] = 'Please enter the title.'; } if(!isset($error)){ try { //insert into database $stmt = $handler->prepare('INSERT INTO event_calendar (title,event_date,description) VALUES (:title, :description, :event_date)') ; $stmt->execute(array( ':title' => $title, ':description' => $description, ':event_date' => date('Y-m-d') )); //redirect to index page header('Location: index.php?action=added'); exit; } catch(PDOException $e) { echo $e->getMessage(); } } } //check for any errors if(isset($error)){ foreach($error as $error){ echo '<p class="error">'.$error.'</p>'; } } ?> <form action='' method='post'> <p><label>Title</label> <input type='text' name='title' value='<?php if(isset($error)){ echo $_POST['title'];}?>'></p> <p><label>Description</label><br /> <textarea name='description' cols='50' rows='5'><?php if(isset($error)){ echo $_POST['description'];}?></textarea></p> <p><label>Date of Event : (y-m-d) :</label><input name="event_date" type="date" value='<?php if(isset($error)){ echo $_POST['event_date'];}?>'></p> <p><input type='submit' name='submit' value='Submit'></p> </form>Could anyone please just look through it.. My database structure is simple.. id, title, description, event_date Thanks in advance Hi, I have a little problem that I can't seem to solve myself. My coding skills are very limited, just wanted to mention that . I have a list of rows, bascially banners that members submit. They have to be manually approved by me before they are put on air. So to quicken up this process I made this little code in my admin panel. $bq = mysql_query("SELECT id, usrid, bname, burl, btarget FROM ban_rotator WHERE status = 'Waiting'"); $pb = mysql_num_rows($bq); if ($_GET['ap']) { $bid = $_GET['ap']; mysql_query("UPDATE ban_rotator SET status = 'Active' WHERE id = '$bid'"); It works perfectly except for one thing. It will always show the banner I just approved in addition to the remaining ones that are waiting. Any tips would be appreciated. I have to add that this code is a part of a fairly large admin panel php file. Just realized i need a bit more explanation. If I hit refresh in the browser the one I just approved will be gone. As I would like it to be after hitting Approve on the banner in question. If I just approve the second banner (after approving the first), the first will be gone from the list of waiting and the second will still show until I either hit approve on the third or hit refresh in the brower. Alka On the index page of http://www.sportskevesti.co i have the meta tags of Title, Description, Keyword.... and other element, but it is necessary to show them in name of the other pages, socer, basketbal, handbal, tennis...., and there fore news spetial. in this moment, i have this meta tag double. for example: www.sportskevesti.co/index.php Quote <meta name="title" content="Sportske Vesti"> <meta name="description" content="Najnovije sportske vesti iz Srbije i ostatka sveta. Sve na jednom mestu."> <meta name="keywords" content="sport, vesti, fudbal, tenis, kosarka, odbojka, rukomet, auto, moto, trke"> http://sportskevesti.co/index.php?opcija=vest&vest_id=60067 Quote <meta name="title" content="Sportske Vesti"> <meta name="description" content="Najnovije sportske vesti iz Srbije i ostatka sveta. Sve na jednom mestu."> <meta name="keywords" content="sport, vesti, fudbal, tenis, kosarka, odbojka, rukomet, auto, moto, trke"> <meta name="title" content="Danas je derbi!" /> <meta name="description" content="Na stadionu Crvene zvezde danas se igra ..." /> <meta name="keywords" content="danas, derbi, "/> Since I assume that this is not good for SEO optimization, how to avoid this and show only one meta per page ? I cant get my head around this. I m trying to add product attributes into this script. I have products tables and product_extras product.id and product_extras.id are same. How can I add this to cart. Is there any easy way to do this. Any help would be much appreciated! Quote cart.php Code: [Select] <?php // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions require_once('inc/functions.inc.php'); // Start the session session_start(); // Process actions $cart = $_SESSION['cart']; $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; case 'delete': if ($cart) { $items = explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($_GET['id'] != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } $cart = $newcart; } break; case 'update': if ($cart) { $newcart = ''; foreach ($_POST as $key=>$value) { if (stristr($key,'qty')) { $id = str_replace('qty','',$key); $items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($id != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } for ($i=1;$i<=$value;$i++) { if ($newcart != '') { $newcart .= ','.$id; } else { $newcart = $id; } } } } } $cart = $newcart; break; } $_SESSION['cart'] = $cart; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>products</title> <link rel="stylesheet" href="css/styles.css" /> </head> <body> <div id="shoppingcart"> <h1>Your Shopping Cart</h1> <?php echo writeShoppingCart(); ?> </div> <div id="contents"> <h1>Please check quantities...</h1> <?php echo showCart(); ?> <p><a href="index.php">Back to products...</a></p> </div> </body> </html> Quote functions.php Code: [Select] <?php function writeShoppingCart() { $cart = $_SESSION['cart']; if (!$cart) { return '<p>You have no items in your shopping cart</p>'; } else { // Parse the cart session variable $items = explode(',',$cart); $s = (count($items) > 1) ? 's':''; return '<p>You have <a href="cart.php">'.count($items).' item'.$s.' in your shopping cart</a></p>'; } } function showCart() { global $db; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<form action="cart.php?action=update" method="post" id="cart">'; $output[] = '<table>'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM products WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = '<tr>'; $output[] = '<td><a href="cart.php?action=delete&id='.$id.'" class="r">Remove</a></td>'; $output[] = '<td>'.$title.'</td>'; $output[] = '<td>£'.$price.'</td>'; $output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>'; $output[] = '<td>£'.($price * $qty).'</td>'; $total += $price * $qty; $output[] = '</tr>'; } $output[] = '</table>'; $output[] = '<p>Grand total: <strong>£'.$total.'</strong></p>'; $output[] = '<div><button type="submit">Update cart</button></div>'; $output[] = '</form>'; } else { $output[] = '<p>You shopping cart is empty.</p>'; } return join('',$output); } ?> Hello all! I am new to the forums and this is my first post. I've tried to search for an answer but have come up empty handed so I thought I'd just ask outright. I am building a website for a local car dealership and they want to have a "Vehicles" page where it shows a list of all the vehicles in inventory and the consumer can sort the inventory by Make, Model, Year, Color, and/or Price. I'm working with php and MySQL and I am a newbie coder trying to learn on my own. I know how to sort querys but I am completely lost when it comes to sorting with dynamic/multiple variable chosen by the user. Please help. I know my code sucks but any advise will be SUPER helpful. Code: [Select] <?php include "storescripts/connect_to_mysql.php"; if(isset($_POST['Year'])){ $where = "WHERE"; if(isset($_POST['Color'])) { $and = "AND"; } else { $and = ""; } if(isset($_POST['Model'])) { $and = "AND"; } else { $and = ""; } $yearArr = "'" . implode("','", $_POST['Year']) . "'"; $yearSort = "Year IN($yearArr) $and"; if(isset($_POST['Color'])){ $colorArr = "'" . implode("','", $_POST['Color']) . "'"; $colorSort = "Color IN($colorArr)"; } else { $colorArr = ""; $colorSort = ""; } if(isset($_POST['Model'])){ $modelArr = "'" . implode("','", $_POST['Model']) . "'"; $modelSort = "Model IN($modelArr)"; } else { $modelArr = ""; $modelSort = ""; } } else { $yearArr = ""; $yearSort = ""; $where = ""; } if(isset($_POST['Color'])){ $where = "WHERE"; if(isset($_POST['Year'])) { $and = "AND"; } else { $and = ""; } if(isset($_POST['Model'])) { $and = "AND"; } else { $and = ""; } $colorArr = "'" . implode("','", $_POST['Color']) . "'"; $colorSort = "Color IN($colorArr) $and"; if(isset($_POST['Year'])){ $yearArr = "'" . implode("','", $_POST['Year']) . "'"; $yearSort = "Year IN($yearArr)"; } else { $yearArr = ""; $yearSort = ""; } if(isset($_POST['Model'])){ $modelArr = "'" . implode("','", $_POST['Model']) . "'"; $modelSort = "Model IN($modelArr)"; } else { $modelArr = ""; $modelSort = ""; } } else { $colorArr = ""; $colorSort = ""; $where = ""; } if(isset($_POST['Model'])){ $where = "WHERE"; if(isset($_POST['Color'])) { $and = "AND"; } else { $and = ""; } if(isset($_POST['Year'])) { $and = "AND"; } else { $and = ""; } $modelArr = "'" . implode("','", $_POST['Model']) . "'"; $modelSort = "Model IN($modelArr) $and"; if(isset($_POST['Color'])){ $colorArr = "'" . implode("','", $_POST['Color']) . "'"; $colorSort = "Color IN($colorArr)"; } else { $colorArr = ""; $colorSort = ""; } if(isset($_POST['Year'])){ $yearArr = "'" . implode("','", $_POST['Year']) . "'"; $yearSort = "Year IN($yearArr)"; } else { $yearArr = ""; $yearSort = ""; } } else { $modelArr = ""; $modelSort = ""; $where = ""; } $querySort = "$yearSort $colorSort $modelSort"; $query = "SELECT * FROM vehicles $where $querySort $sort"; // create the query object $sql = mysql_query($query); // Pagination // Logic $nr = mysql_num_rows($sql);// Get total number of rows if(isset($_GET['pn'])) { $pn = preg_replace('#[^0-9]#i', '', $_GET['pn']); } else { $pn = 1; } $itemsPerPage = 10; $lastPage = ceil($nr / $itemsPerPage); if ($pn < 1) { $pn = 1; } else if ($pn > $lastPage) { $pn = $lastPage; } $centerPages = ""; // Initialize Variable $sub1 = $pn - 1; $sub2 = $pn - 2; $add1 = $pn + 1; $add2 = $pn + 2; if ($pn == 1) { $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; } else if ($pn == $lastPage) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; } else if ($pn > 2 && $pn < ($lastPage - 1)) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub2 . '">' . $sub2 . '</a> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add2 . '">' . $add2 . '</a> '; } else if ($pn > 1 && $pn < $lastPage) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; }$limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage; $sql2 = mysql_query("$query"); // End Logic // Pagination Display $paginationDisplay = ""; if ($lastPage !="1") { $paginationDisplay .='Page <strong>' . $pn . '</strong> of ' . $lastPage . ' <img src="images/clearImage.gif" width="48" height="1" alt="Spacer" />'; if ($pn != 1) { $previous = $pn - 1; $paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> Back</a> '; } $paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>'; if ($pn != $lastPage) { $nextPage = $pn + 1; $paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '"> Next</a> '; } } $sql2 = mysql_query("$query"); $dynamicList = '<table border="0" cellpadding="10">'; $productCount = mysql_num_rows($sql2); // count the output amount if ($productCount > 0) { while($row = mysql_fetch_array($sql2)){ $id = $row["id"]; $stockNumber = $row["StockNumber"]; $status = $row["Status"]; $gasType = $row["GasType"]; $year = $row["Year"]; $make = $row["Make"]; $model = $row["Model"]; $category = $row["Category"]; $transmission = $row["Transmission"]; $engineSize = $row["EngineSize"]; $color = $row["Color"]; $internetPrice = $row["InternetPrice"]; $driveTrain = $row["DriveTrain"]; $msrp = $row["MSRP"]; $internetSpecial = $row["InternetSpecial"]; $dateCreated = strftime("%b %d, %Y", strtotime($row["DateCreated"])); $comments = $row["VehicleComments"]; $options = $row["Options"]; $shortComments = substr($options, 0, 50); $detailSummary = '' . $stockNumber . ', ' . $color . ', ' . $gasType . ', ' . $driveTrain . ', ' . $shortComments . ''; $dynamicList .= '<tr><td>' . $year . ' ' . $make . ' ' . $model . ' ' . $detailSummary . ' $' . $internetPrice . '</td>'; } } else { $dynamicList = "We don't have any items in our store yet"; } $dynamicTable .= '</tr></table></form>'; mysql_close(); ?> <?php include 'storescripts/connect_to_mysql.php'; $sql = mysql_query("SELECT Color FROM vehicles GROUP BY Color"); $i = 0; $dynamicTable = '<table border="0" cellpadding="10"><strong>Color</strong>'; while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $color = $row["Color"]; if($i % 2 == 0) { $dynamicTable .= "<tr><td><input name='Color[]' type='checkbox' value='" . $color . "' />" . $color . "</td>"; } else { $dynamicTable .= "<td><input name='Color[]' type='checkbox' value='" . $color . "' />" . $color . "</td>"; } $i++; } $dynamicTable .= '</tr></table>'; ?> <?php include 'storescripts/connect_to_mysql.php'; $sql = mysql_query("SELECT Model FROM vehicles GROUP BY Model"); $i = 0; $dynamicModel = '<table border="0" cellpadding="10"><br /><strong>Model</strong>'; while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $model = $row["Model"]; if($i % 2 == 0) { $dynamicModel .= '<tr><td><input name="Model[]" type="checkbox" value="' . $model . '" />' . $model . '</td>'; } else { $dynamicModel .= '<td><input name="Model[]" type="checkbox" value="' . $model . '" />' . $model . '</td>'; } $i++; } $dynamicModel .= '</tr></table>'; ?> <?php include 'storescripts/connect_to_mysql.php'; $sql = mysql_query("SELECT Year FROM vehicles GROUP BY Year"); $i = 0; $dynamicYear = '<table border="0" cellpadding="10"><strong>Year</strong>'; while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $year = $row["Year"]; if(isset($_POST['Year'])); { if($_POST['Year'] == $year) { $check = 'checked'; } else { $check = ''; } } if($i % 2 == 0) { $dynamicYear .= "<tr><td><input id='Year[]' name='Year[]' type='checkbox' " . $check . " value='" . $year . "' />" . $year . "</td>"; } else { $dynamicYear .= "<td><input id='Year[]' name='Year[]' type='checkbox' " . $check . " value='" . $year . "' />" . $year . "</td>"; } $i++; } $dynamicYear .= '</tr></table>'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Jay GMC Commercial - <?php echo $Year; ?><?php echo $Make; ?><?php echo $Model; ?> in Columbus, GA</title> </head> <body> <table width="100%" border="0" cellpadding="10"> <tr> <td width="64%"><h3><?php echo $query; ?> <br />PhP Grid Layout <br /><?php echo $yearSort; ?><?php echo $yearArr; ?></h3> </td> <td width="36%" align="right">Sort By:<form id="order" name="form1" method="get" action=""> <label for="order"></label> <select name="order" id="order"> <option value="ORDER BY Year ASC" <?php echo $selYa; ?>>Year (Low - High)</option> <option value="ORDER BY Year DESC" <?php echo $selYd; ?>>Year (High - Low)</option> <option value="ORDER BY Model ASC" <?php echo $selMa; ?>>Model (A - Z)</option> <option value="ORDER BY Model DESC" <?php echo $selMd; ?>>Model (Z - A)</option> </select> <input name="Submit" type="submit" value="Submit" /> </form></td> </tr> </table> <form action="sorttest.php" method="post" name="sort"> <table width="100%" border="1" cellpadding="10"> <tr align="left" valign="top"> <td width="24%"><input name="submit1" type="submit" /> <br /> <br /> <?php echo $dynamicTable; ?><br /> <?php echo $dynamicModel; ?><br /> <?php echo $dynamicYear; ?><br /></td> <td width="76%"><?php echo $dynamicList; ?></td> </tr> </table> </form> </body> </html> Thanks again! I have a task that seems to be complex.
Short Description: currently users of the application I am hired to develop have two steps to do when using the app:
1. Select a Product Line (A, B, C, D)
2. Select input parameters for that product line - all product lines have simlar "Main" input parameters, but also each line has its own special features that can be selected.
3. Selections for that product line are shown - the result is a long table or options for that particular product line. Things like price, discounts, product specifications, etc.
What the users want now is this:
1. Select input parameters (not sure how to handle individual product lines special parameters yet)
2. Selections for all product lines are shown
The code base is legacy code, with code thrown around everywhere. One idea me and my coworkers have been considering is a complete rewrite, since it will help us with writing tighter code, and do what the customer wants. But that will also take time, and there is no spec. The spec is in the code mess.
Another one is I am considering now is a "merge". Somehow merge the product lines, since we have the separate product modules (A, B, C, D), there must be a way to consider maybe extending one to include the others, or somehow get me to the end result -- allow users to see selections for all product lines.
Do you have any experience, any suggestions on how to do this? I know this needs details, and details are in my code that you don't see, and most likely won't have the time to read and understand anyway.
But I am looking for any ideas or encouragement though that may help. And my question is -- is there any kind of procedure or technique or something to deal with the problem I am facing -- merging several separate yet similar modules into one single merged module. How do I approach this, what are some things that could help, etc. That's what I'm looking for.
|