PHP - 404 Error Page For Database Driven Pages
Sorry for my bad english but i hope you would understand my query.
How can i set 404 not found for database driven pages..? I am using header("HTTP/1.0 404 Not Found"); in my 404 error page and ErrorDocument 404 /404.html, whereas 404.html is my error page. i have an URL http://www.example.com/folder/my-test-for-url-95/ which is opening correctly because it has existence on database. but when i am opening http://www.example.com/folder/my-test-for-url-951/ which has existence on database is also opening without any information but i want here a 404 not found page. How can i do so. Thanks Similar TutorialsI am trying to write out a calendar style html table with data in each cell, and with a column on the left that shows the times. Basically it should look like this when written out to the webpage: Time Mon Tues Wed Thur Fri Sat 8:00 data data2 9:30 data3 data4 10:00 data5 data6 11:00 data7 data8 The times on the left will vary each month, and the 'data' (these are actually fitness classes held each month) will appear on various days of the week. There is no need to toggle from one month to the next and such, it's just a listing of the current month to display the classes held on which days and at which times. Very easy to do statically in html, but a bit more challenging dynamically. Using MySQL, the table that holds the data looks like this: Code: [Select] schedule_id class_time class_title day_order 1 08:00 data 1 2 08:00 data2 3 3 09:30 data3 2 4 09:30 data4 4 5 10:00 data5 3 6 10:00 data6 5 7 11:00 data7 1 8 11:00 data8 3 The day_order field corresponds to the weekday - Mon is 1, Tues is 2, etc. My query looks like this: Code: [Select] SELECT schedule_id, class_time, class_title, day_orderFROM `class_schedule` order by class_time, day_order Here is the html/ php code to write it out: Code: [Select] <table border="0" cellpadding="2" cellspacing="0" width="625"> <tr> <td class="calheader">Time</td> <td class="calheader">Mon</td> <td class="calheader">Tue</td> <td class="calheader">Wed</td> <td class="calheader">Thu</td> <td class="calheader">Fri</td> <td class="calheader">Sat</td> <td class="calheader">Sun</td> </tr> <? $i=0; $first_time = ""; while($i<$num_rows){ $sid = mysql_result($sql,$i,"schedule_id"); $ctime = mysql_result($sql,$i,"class_time"); $cdate = mysql_result($sql,$i,"CURDATE()"); $strtime = date("h:i:s",$cdate.$ctime); $ctitle = stripslashes(mysql_result($sql,$i,"class_title")); $order = mysql_result($sql,$i,"day_order"); if ($ctime != $first_time){ if (isset($first_time)){ echo ""; } if ($first_time == ""){ echo "<tr>\n"; echo "<td class=\"timecell\">". $ctime ."</td>\n"; } $first_time = mysql_result($sql,$i,"class_time"); } $j = 1; while ($j<8 && $first_time != ""){ if ($order == $j){ $thetitle = $ctitle; } else { $thetitle = " "; } echo "<td class=\"calcell\">". $thetitle ."</td>\n"; $j++; } unset($first_time); if (!isset($first_time)) { echo "</tr>\n"; } $i++; } unset($ctitle); unset($thetitle); unset($weekday); unset($sid); unset($clink); unset($order); mysql_close(); The above code sort of works, but the trouble I am having is that it is creating a new table row for each class, even if they occur at the same time slot. It should be putting them on the same row, to the right of the time slot across the days of the week. If anyone could assist, that would be wonderful - I am really stuck with this... Thanks Hello, I am making a small CMS and I having some trouble with making a dynamic menu. I am wondering for a few days how I should make this menu system. I have the follow MySQL table: Code: [Select] CREATE TABLE `pages` ( `id` int(4) unsigned NOT NULL AUTO_INCREMENT, `time` varchar(10) DEFAULT NULL, `lastby` varchar(2) DEFAULT NULL, `order_id` varchar(2) DEFAULT NULL, `text` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB; Now I would like to have a menu system as following that I make menu's in a menu table with a name and a menu ID and that I could place those pages as parent or as subparent. How could I manage to turn my theory into reality? Whats the best way to make a database driven menu ? Right now I have a db that looks like id | boats | Inshore id | boats | Offshore id | boats | Bay Boats and so on I'm think of going to database 1 id-1 | boats database 2 id | 1 | inshore or would a multideminsional array work best. My goal is to have the short term format be Boats Inshore Offshore Bay Boats and in the long term a format whose style I can change later, I wanted to get ideas from people in the know and have done this before. Thanks in advance Hi all, I am wondering what the best way to do this is... Take GoDaddy for example, if your domain is about to expire you will get an automatic email. I am wanting to do something similar, If someone orders a Soap Dispenser, I want to send an email (if they accept to receiving emails on the order) each month asking/reminding them to top up on soap. I have been reading but cant find anything adequate, I have seen something about Cron Jobs, but never heard of this before, please could you point me in the right direction. Thanks in advance. Peter Hi everyone. I would like to do this: In page1.php, I need to make a few checkboxes, which when the user clicks "next" button, transfers the data (which checkboxes were clicked) to a database table. Then, when the user clicks a button "next", he is moved to another page, page2.php, from which he is automatically transferred to page3.php. At page3.php those values are gathered from the database, and the user has to click "next" button again, then those values are written into another table, in the same or another database. How can I do this? I've not much knowledge with neither SQL, neither PHP. I hope you will help me make this work, I'm making a little system for my HTML website. Thanks, if you do! Hi im a little stuck... What im trying to do is when you request a page that is not there it goes to a custom error page. I have set the redirect via the .htaccess file. Basicly what im trying to do is only have one php file which displays the server response i.e. 404 error or 401 error and so on rather than having several error pages. So in the code Code: [Select] <h1>Oopppsss!!!! <!-- ERROR TO DISPLAY HERE i.e. 404 page not found --></h1> <p>There seems to be a problem... The page you are looking for does not exist or has moved. This is a permanent error. If you think this is a mistake please get in touch either by giving us a ring on 101010 or by filling out the web form on the <a href="contact-me.php">contact me</a> page...</p> Any thaught on how i can do this or is it not possible... Cheers I am writing a database using php mysql. I have a page which works fine but if I add one extra query it just produces a blank page. I remember once that someone said I could put in some code at the start of the page and it would display any errors but can't remember the code!
Could someone let me have the code and does anyone have any suggestions as to why this blanking is happening?
Many thanks
Hi everyone, I am a beginner web designer and a novice php user. I am a regular forum user and understand that you should always do a search and try to find the answer yourself but I have done that and didn't get any results (or I didn't understand them!). So I ask for some assistance - either you can tell me the code or link me to the correct answer. I am working on a website that I have built a enquiry form for and it has a php script for it. I have managed to get the form running properly and got the reCaptcha working correctly (with a custom error page) but I do not understand how to add custom error pages for incomplete email addresses, empty email addresses, or for a blank form? I tried using the same tactic I used for the reCaptcha error page but it didn't work - probably because I was guessing and just tried it in a bunch of different places. The error msg that displays now is just a plain white page with the msg - Email address is invalid appearing at the top left. While this is suitably functional it doesn't really look like much so I want to build a custom page for each error that could happen. So the code is below - if anyone can point a beginner in the right direction I would be super happy. :mrgreen: if you need anymore code or other details just tell me and I will post them up. The url of the form page is http://www.sunsolutionshomeimprovement.com/onlinesales.html This is the code I think you will need - I got it from a demo php script that I have modified. As I said I don't have much clue what I'm doing so I just posted it exactly how it looks - if I over did it I apologize... :oops: 68.// Validate email field. 69. 70.if(isset($_REQUEST['email']) && !empty($_REQUEST['email'])) 71.{ 72. 73.if(preg_match("/(%0A|%0D|\n+|\r+|:)/i",$_REQUEST['email'])){$errors[] = "Email address may not contain a new line or 74.a colon";} 75. 76.$_REQUEST['email'] = trim($_REQUEST['email']); 77. 78.if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}} 78. 79.) 80. 81.// Check referrer is from same site. 82. 83.if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";} 84. 85.// Check for a blank form. 86. 87.function recursive_array_check_blank($element_value) 88.( 89. 90.global $set; 91. 92.if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}} 93.else 94. 95. 96.foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);} 97. 98.) 99. 100.) 101. 102.recursive_array_check_blank($_REQUEST); 103. 104.if(!$set){$errors[] = "You cannot send a blank form";} 105. 106.unset($set); 107. 108.// Display any errors and exit if errors exist. 109. 110.if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;} 111. 112.if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");} 113. 114.// Build message. I don't think there is anymore that is relevant? I just want to reiterate that I know nearly nothing about this stuff so if you could keep your answers simple it would help a lot - cheers! I have a standard form that displays users current data from a mysql database once logged in(code obtained from the internet). Users can then edit their data then submit it to page called editform.php that does the update. All works well except that the page does not display the updated info. Users have to first logout and login again to see the updated info. even refreshing the page does not show the new info. Please tell me where the problem is as i am new to php.
my form page test.php
<?PHP require_once("./include/membersite_config.php"); if(!$fgmembersite->CheckLogin()) { $fgmembersite->RedirectToURL("login.php"); exit; } ?> <form action="editform.php?id_user=<?= $fgmembersite->UserId() ?>" method="POST"> <input type="hidden" name="id_user" value="<?= $fgmembersite->UserId() ?>"><br> Name:<br> <input type="text" name="name" size="40" value="<?= $fgmembersite->UserFullName() ?>"><br><br> Email:<br> <input type="text" name="email" size="40" value="<?= $fgmembersite->UserEmail() ?> "><br><br> Address:<br> <input type="text" name="address" size="40" value="<?= $fgmembersite->UserAddress() ?> "><br><br> <button>Submit</button>my editform.php <?php $con = mysqli_connect("localhost","root","user","pass"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } mysqli_query($con,"UPDATE fgusers3 SET name = '".$_POST['name']."', email= '".$_POST['email']."', address= '".$_POST['address']."' WHERE id_user='".$_POST['id_user']."'"); header("Location: test.php"); ?> Hello, I'm new here and need some help. I'm a beginner with PHP Here's what I have.... The index page looks like this: <? include("header.php"); ?> <? include("sidebar.php"); ?> <? include("main.php"); ?> <? include("footer.php"); ?> On all of the pages for the site, the only thing that will change will be: <? include("main.php"); ?> When viewing the home page, the title in the browser shows: Home Page (which is what I want). However, when clicking on links in the nav bar, I want the title to reflect those page names. For example, the code above displays the home page, but then if you click on (for example) "Bio's" in the navigation bar, it will take you to the Bio's page, obviously. the link for that menu item is: bio.php. The bio.php page looks like this: <? include("header.php"); ?> <? include("sidebar.php"); ?> <div> All the data and formatting for this page </div> <? include("footer.php"); ?> ............. I would like to put some php code in the header that will automatically detect the title of each page, how can I do this? Should I put <? title=Bio's Page ?> (or whatever page) at the top of each page, then call to it somehow from the header? Any help would be appreciated. this is my code which is using to check login from database calledchklogin.php Code: [Select] <?php session_start(); include('connect.php'); $tbl_name="members"; mysql_select_db($Db, $link); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $mypassword = md5($mypassword); $sql="SELECT * FROM $tbl_name WHERE uname='$myusername' and upass='$mypassword'"; $result=mysql_query($sql,$link); $row=mysql_fetch_array($result); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("username"); //Create the session session_register("myusername"); session_register("mypassword"); $_SESSION['uname'] = "$myusername"; $_SESSION['utype'] = $row['utype']; header("location:loginsuccess.php"); } else { //include ('index.php'); echo ("<script type='text/javascript'> window.alert('Wrong username or password!')</script>"); exit(); } ?> & this code is from another file called loginsuccess.php Code: [Select] <? session_start(); if(!session_is_registered(myusername)){ header("location:index.php"); exit(); } require_once("login-index.php"); ?> so when everything is right in chklogin.php then it open loginsuccess.php after that when all is true then it open login-index.php after that this page open it show double page one is index.php where the login form & another is this login-index.php at one time okay this sounds strange I know but but apart from html code in pure php the database values display correctly but when I combine with HTML code i get an offset error when retrieving certain values example results from database file no HTML coding: February10 2012 5pm MY EVENT NEW YORK ERROR when combined with HTML: February MYEVENT 2012 NewYork A friend of mine must of changed something on the site while I was asleep last night and now all the site says when you go to it is: Error Database query error Warning: mail() [function.mail]: SMTP server response: 530 SMTP authentication is required. in C:\xampp\htdocs\inc\utils.inc.php on line 449 I'm not exactly sure what he did since I can't contact him. Can anyone help me fix this? I have script on my web hosts server built into pages that will be offered to the public, eg: index.php will have some script amongst the html, this script calls other webpages on the net eg: wiki.org Now my question is, when that script runs when somebody accesses that page, will the website eg: wiki.org record the users browser info and ip who called my index page or will it record the webhosts server details as the one making the requests? Hi guys so i want to make page acces to certain ranks. So im thinking for something like this
rank1 -> home.php, admins.php So the ranks are in a database with the page names. So now when someone logs in they will get a certain rank. So now i need to make a function that will check if the rank has access to this page. $curPageName = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1); This will detect the current page that the logged in person is at now. But now how do i check if the $_SESSION['rank']; (rank1) has the access to get in page admins.php, and obviously to make $_SESSION['rank'];(rank2) redirect from the page admins.php Could someone point me in the right direction? Do i select the ranks and page names from database then put it into a array? Thanks. I'm trying to set up a very simple (WIP) members page that you can click registered users to see their profile page that will display basic information. I'm having trouble with the sessions and retrieving this info from my database. I'm very new to this so it's all pretty amateur. I've been looking at this code for several hours trying to fix things but I start to make some progress, then change stuff, and go backwards. I had a members page that displayed the registered users in my database, but after a while of altering to try to get the profiles to work, I messed it up :mad:. I have basic login and register pages. I need some seperate eyes to take a look. Any help is so much appreciated. Thanks! members.php Code: [Select] <?php session_start(); require 'mysql-connect.php'; $auser=$_SESSION['user']; if(isset($auser)){ $Members = mysql_query("SELECT * FROM user WHERE username='$username'") or die(mysql_error()); $numRowsMembers = mysql_num_rows($Members); ?> <table border="1"> <?php for($count = 1; $count <= $numRowsMembers; $count++) { $name = mysql_fetch_array($Members); ?> <tr> <?php echo '<td><a href="member_profile.php?username=' . $name['username'] . '">' . $name['username'] . '</a></td>'; } } ?> </tr> </table> member_profile.php Code: [Select] <?php session_start(); require 'mysql-connect.php'; $auser=$_SESSION['user']; if(isset($auser)){ $username = $_GET['username']; $user = mysql_query("SELECT * FROM user WHERE username = '$username'"); echo $user; $user=mysql_fetch_assoc($user); echo "<h1>User Info</h1>"; echo "<b>Username:".$user['username']."<br>"; echo "<br>"; echo '<form name="backlistfrm" method="post" action="members.php">'; echo '<input type="submit" value="Back to The List">'; echo '</form>'; echo "<br>"; } ?> my login handler Code: [Select] <?php include 'mysql-connect.php'; $username = $_POST['user']; $password = $_POST['pass']; $query1 = mysql_query("SELECT * FROM user WHERE username='$username'"); $result = mysql_num_rows($query1); if($result == 0) { echo '<h1>Error!</h1>The username you specified does not exist!'; } else { $checkuser = mysql_query("SELECT * FROM user WHERE username='$username'"); $row = mysql_fetch_array($checkuser); $password2 = $row['password']; //$status = $row['status']; if ($password == $password2) { echo "Hi $username."; include("index.php"); } else { echo '<h1>Error!</h1>The username and password combination you entered does not match the ones we have in the database.'; } } ?> mysql-connect.php Code: [Select] <?php $host = "localhost"; $username = "root"; $password = ""; $database = "ug54"; $link = mysql_connect($host, $username, $password);//Connects to database with host, username, and password $select = mysql_select_db($database); ?> and my simple database Code: [Select] CREATE TABLE IF NOT EXISTS `user` ( `id` int(4) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(32) NOT NULL, `password` varchar(32) NOT NULL, `firstname` varchar(20) NOT NULL, `lastname` varchar(20) NOT NULL, `email` varchar(30) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; -- -- Dumping data for table `user` -- INSERT INTO `user` (`id`, `username`, `password`, `firstname`, `lastname`, `email`) VALUES (1, '', '', '', '', '0'), (2, 'abc', '123', '', '', '0'), (3, 'a', 'b', 'c', 'd', '0'), (4, 'hfg', 'rgfdg', 'gdfg', 'dfgdf', '0'), (5, '999', '999', '999', '999', '999'); Hi everyone, I have this script that identify's the current page in the navigation Code: [Select] <?php $currentPage = basename($_SERVER['SCRIPT_NAME']); ?> <ul id="nav"><!-- Open Nav --> <li><a href="index2.php" <?php if ($currentPage == 'index2.php') {echo 'class="selected"';} ?>>Home</a></li> <li><a href="salon-information.php" <?php if ($currentPage == 'salon-information.php') {echo 'class="selected"';} ?>>Salon Information</a></li> <li><a href="about-us.php" <?php if ($currentPage == 'about-us.php') {echo 'class="selected"';} ?>>About us</a></li> <li><a href="hair-care-advice.php" <?php if ($currentPage == 'hair-care-advice.php') {echo 'class="selected"';} ?>>Hair Care Advice</a></li> </ul><!-- Close Nav --> My problem is that hair-care-advice.php has a number of sub pages. How do I get it so the selected class remains selected for all the sub pages as well as the main page. Any help would be greatly appreciated Thank you Barry when the user clicks the submit button from a html form, it needs to go back two pages with that loaded page refreshed. for the javascript i only have history.go(-2); with php, I have tried cookies and sessions which i discovered that neither will work because the loaded page is not refreshed. I could do a html body onload but that would break the w3c validator. what are my options?
Hi Everyone, I have an ecommerce store that I have done some coding for, and each category has some coding to create pages to display items in that category. For some reason, I am getting a couple of "ghost" pages on the end of a couple categories. For example, look at this page: http://www.autismcommunitystore.com/view.php?category=4 Pages 5 & 6 are blank - page 4 has the last of the items in the category. I have a table called prods_to_cats which connects the products and the categories (a many to many relationship). I'm posting the code here - could someone just let me know if they spot something that looks like trouble? Thank you in advance for your time! Code: [Select] <? $category=$_REQUEST['category']; $showcategory=$category; include 'connect.php'; $thiscategory = mysql_query("SELECT * FROM category WHERE category_id=$showcategory", $dbh); $thisrow = mysql_fetch_array($thiscategory); $this_des=$thisrow["category_description"]; $this_text=$thisrow["category_text"]; $titlekey="Products listed in $this_des at Autism Community Store 877-422-5932"; // If current page number, use it // if not, set one! if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } // Define the number of results per page $max_results = 40; // Figure out the limit for the query based // on the current page number. $from = (($page * $max_results) - $max_results); echo '<div id="product">'; $result = mysql_query("SELECT DISTINCT product.id, product.* FROM prods_to_cats INNER JOIN product ON prods_to_cats.id=product.id WHERE prods_to_cats.category_id=$showcategory ORDER BY product.title ASC LIMIT $from, $max_results", $dbh); $numresult = mysql_num_rows($result); if($numresult==0) { echo "<p style='padding-left: 50px'>There are no products listed in this category.</p>\n"; } else { $thiscategory = mysql_query("SELECT * FROM category WHERE category_id=$showcategory", $dbh); $thisrow = mysql_fetch_array($thiscategory); $this_des=$thisrow["category_description"]; echo "<table width='100%'><tr>"; echo "<div style='position:relative; left:150px;'><font size='2'>Return To: <strong><a href='http://www.autismcommunitystore.com'>Home </a></strong></font></div><br/>"; echo "<div style='position:relative ; width:100%' align='center'>"; echo "<br />"; echo "<img src='http://www.watchesandthings.com/autism/images/suppliesHeader.gif'>"; echo "</div>"; echo "<h2>"; echo "<div style='padding-right:20px ; position:relative ; width;100%; text-align:right;'>"; echo "<div style='position:relative ; width;80%; text-align:center; left:20%;'>"; echo $this_des; echo "</div>"; echo "</div>"; echo "</h2>"; echo "<div style='position:relative ; padding-left:30px ; padding-right:30px ; '>"; echo "<p>"; echo "$this_text </p>"; echo "</div>"; echo "</tr>"; $count = 1; $column = 1; //initialize column 1 or 2 //-----------------------code for drop down menu---------------------------------------- include 'browserChecker.php'; /* echo $browser; echo "<br/>"; echo $browser_version; echo "<br/>"; $main_version=$browser_version[0]; echo $main_version; */ if ($browser=='IE' && $browser_version<7){ echo '<br />'; //make version 6 compatible select box if ($category==1 || $category==24){ }else{ ?> <center> <div id="hiddendiv" style="display:;"> <form method="get" enctype="multipart/form-data" action="http://www.autismcommunitystore.com/viewsubcategory.php"> <select id="myselectbox" name="subcategory" > <? $sql="SELECT * FROM subcategory ORDER BY sub_description ASC"; $result=mysql_query($sql, $dbh); while($myrow=mysql_fetch_array($result)) { if ($myrow['category_id']==$category){ $myrow['sub_description'] ?> <option name="subcategory" value="<? echo $myrow['sub_id'] ?>" ><? echo $myrow['sub_description'] ?> </option> <? }//close if for category check }//close drop down while loop ?> </select> </center> <div id="go_subcat"> <input type="submit" value=" GO " style="background-color: #E4DFF3; color: #6F5079; border: 2px solid #6F5079"> </div> </form> </div> <? }//end check category }else{ //make normal select box if ($category==1 || $category==24){ }else{ ?><div style="z-index:2"><br /><form method="get" enctype="multipart/form-data" action="http://www.autismcommunitystore.com/viewsubcategory.php"> <div align="center" style='z-index:5'> <select name="subcategory" size="1" style="background-color: #ffffff; color: #6F5079; border: 2px solid #6F5079"> <? $sql="SELECT * FROM subcategory ORDER BY sub_description ASC"; $result=mysql_query($sql, $dbh); while($myrow=mysql_fetch_array($result)) { if ($myrow['category_id']==$category){ ?> <option name="subcategory" value="<? echo $myrow['sub_id'] ?>" ><? echo $myrow['sub_description'] ?> </option> <? }//close if for category check }//close drop down while loop ?> </select> <input type="submit" value=" GO " style="background-color: #E4DFF3; color: #6F5079; border: 2px solid #6F5079"> </div> </form> </div> <? } }//end browser checker if //-----------------------end code for drop down menu---------------------------------------- //reste variables $result = mysql_query("SELECT DISTINCT product.id, product.* FROM prods_to_cats INNER JOIN product ON prods_to_cats.id=product.id WHERE prods_to_cats.category_id=$showcategory ORDER BY product.title ASC LIMIT $from, $max_results", $dbh); echo "<TABLE cellspacing='20'>"; while($myrow = mysql_fetch_array($result)) { extract($myrow); $location=$image; $price=$sale_price; $item=$myrow["id"]; $stockstatus=$stat; if($stat=='IN STOCK') { $stockstatus=""; } else { $stockstatus="--Item Coming Soon--"; } if($price>0) { $printout="<table border=0 height=70 width=250><tr><td width='100px' align='center' ><a href=http://www.autismcommunitystore.com/item/$item/><img src=http://www.watchesandthings.com/autism/files/thumbnails/$location border=0 alt=$product_id></a></td><td><a href=http://www.autismcommunitystore.com/item/$item/>$title</a><br><span class=prod-dollar>$$price</span><br>$stockstatus</td></tr></table>"; } else { $printout="<table border=0 height=70 width=250><tr><td width='100px' align='center' ><a href=http://www.autismcommunitystore.com/item/$item/><img src=http://www.watchesandthings.com/autism/files/thumbnails/$location border=0 alt=$product_id></a></td><td><a href=http://www.autismcommunitystore.com/item/$item/>$title<br /><span class=prod-dollar>Click for Pricing</span></a><br>$stockstatus</td></tr></table>"; } if ($column=="1") { echo "<tr><td>$printout</td>"; // first column } else { echo "<td>$printout</td></tr>"; // 2nd column } // end of columns $count += 1; // this is a modulus operator it gets the remainder of the equation $column = $count % 2; } // end of while loop echo "</table>"; ; // Figure out the total number of results in DB: $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM prods_to_cats WHERE category_id=$showcategory"),0); //$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM product"),0); // Figure out the total number of pages. Always round up using ceil() $total_pages = ceil($total_results / $max_results); echo "<p><center>Pages<br />"; // Build Previous Link if($page > 1){ $prev = ($page - 1); echo "<a href='http://www.watchesandthings.com/autism/view.php?category=$showcategory&page=$prev'><<Previous</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href='http://www.watchesandthings.com/autism/view.php?category=$showcategory&page=$i'>$i</a> "; } } // Build Next Link if($page < $total_pages){ $next = ($page + 1); echo "<a href='http://www.watchesandthings.com/autism/view.php?category=$showcategory&page=$next'>Next>></a>"; } echo "</center>"; }//end of else> echo "</table>"; echo "</div>"; ?> |