Jump to content

kyleldi

Members
  • Posts

    148
  • Joined

  • Last visited

    Never

Everything posted by kyleldi

  1. So I've got this form that has a drop down menu, pulling data from the db. What I want to do is create a static value, "Other" and use PHP to display a new field underneath the drop-down for the user to enter in the value for "other" if it is selected. Is this possible, and if so how would I go about it? Thank You! <label><select name="material" id="material"> <option value="No Material Chosen">- Material Types -</option> <?php do { ?> <option value="<?php echo $row_rs_materials['material']?>"><?php echo $row_rs_materials['label']?></option> <?php } while ($row_rs_materials = mysql_fetch_assoc($rs_materials)); $rows = mysql_num_rows($rs_materials); if($rows > 0) { mysql_data_seek($rs_materials, 0); $row_rs_materials = mysql_fetch_assoc($rs_materials); } ?> <option value="Per Print">Per Print</option> </select></label>
  2. I've got a repeat region set up to repeat this db query, yet it fails on do {, Any idea what i'm missing? <?php if(isset($_GET['id'])){ echo '<h1 class="style5">'.ucwords($row_rs_newsfeed['headline']).'<br /> <span class="newsubheading">Posted: '.ucwords($row_rs_newsfeed['date']).' @ '.$row_rs_newsfeed['time'].'</span></h1> <div class="fullarticle"><p>'.$row_rs_newsfeed['abstract'].'</p></div>'; } else{ echo '<h1 class="style5">News Archives<br /> <span class="newsubheading">Keeping you up to date with Laser Dynamics</span></h1> do { <div class="newsrelay"> <h3>'.ucwords($row_rs_newsfeed['headline']).'</h3> <p>'.substr($row_rs_newsfeed['abstract'], 0,150).'... <a href="news.php?article='.$row_rs_newsfeed['id'].'">Read More</a></p> </div> <div class="addinfo">Total News Articles To Date: '.$totalRows_rs_newsfeed.'</div>'; } while($row_rs_newsfeed = mysql_fetch_assoc($rs_newsfeed)); ?>
  3. Ok, I put that in my code but i'm getting an "unexpected $end" error. Any ideas? What it's supposed to do is output the url variable if there is one, otherwise it shows one thing if there are items in the db that are active, or another thing if there are no active items. <?php if(isset($_GET['positionid'])){ echo $_GET['positionid']; echo '<div class="jobdetail"> <p><span class="style8">Position:</span>'.ucwords($row_rs_positiondetail['title']).'<br /> <span class="style8">Date Added:</span>'.ucwords($row_rs_positiondetail['date']).'<br /> <span class="style8">Pay:</span>'.ucwords($row_rs_positiondetail['pay']).'</p> <p class="style8">Summary: <span class="jobdetail">'.ucwords($row_rs_positiondetail['summary']).'</span></p> <p class="style8">Duties & Responsibilities: <span class="jobdetail">'.ucwords($row_rs_positiondetail['duties_responsibilities']).'</span></p> <p class="style8">Qualification Requirements: <span class="jobdetail">'.ucwords($row_rs_positiondetail['qualification_requirements']).'</span></p> <p class="style8">Education/Experience: <span class="jobdetail">'.ucwords($row_rs_positiondetail['education_experience']).'</span></p> <p class="style8">Language Skills: <span class="jobdetail">'.ucwords($row_rs_positiondetail['langauge_skills']).'</span></p> <p class="style8">Mathmatical Skills: <span class="jobdetail">'.ucwords($row_rs_positiondetail['mathmatical_skills']).'</span></p> <p class="style8">Reasoning Ability: <span class="jobdetail">'.ucwords($row_rs_positiondetail['reasoning_ability']).'</span></p> <p class="style8">Physical Demands: <span class="jobdetail">'.ucwords($row_rs_positiondetail['physical_demands']).'</span></p> <p class="style8">Work Enviornment: <span class="jobdetail">'.ucwords($row_rs_positiondetail['work_enviornment']).'</span></p> <div class="apply"> <p align="center" class="style8"><a href="apply.php?positionid='.ucwords($row_rs_positiondetail['positionid']).'">Apply For This Position</a></p> </div> </div>'; } else{ if ($row_rs_positions['active'] == 'Yes') { do { echo '<div class="displayjobs"> <div class="jobheading"> <p><a href="careers.php?positionid='.ucwords($row_rs_positions['positionid']).'">'.ucwords($row_rs_positions['title']).'</a><strong> - <span class="style5">Added: '.ucwords($row_rs_positions['date']).'</span></strong></p> </div> <div class="jobdesc"> <p>'.substr($row_rs_positions['summary'], 0,150).'... <a href="careers.php?positionid='.ucwords($row_rs_positions['positionid']).'">View Position</a></p> </div> </div>'; } while($row_rs_positions = mysql_fetch_assoc($rs_positions)); } else{ echo '<div class="jobopenings"><p align="center">Thank you for your interest. Currently we do not have any job openings within The Company. We are, however, always accepting resumes and applications. If you would like to be considered for a future position here, please submit a resume or application <a href="submitapp.php">here</a>.</p><p align="center"><span class="pdfdownload">Download a copy of our <img src="images/pdf-icon.jpg" alt="Adobe PDF" width="16" height="15" /> <a href="downloads/pdf/employment_application.pdf">Employment Application</a> (PDF, 3690K)</span></p></div>'; } ?>
  4. Is it possible to make an IF statement run from a url variable? What I want to do is write a small script that states IF a url variable exists, a script runs, while if it does not that script is skipped and the next script is ran. any ideas? Thank You!
  5. I've got an IF Statement that echo's some html/php if the statement is true, but I keep getting an error "Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' " so I know i'm missing some syntax somewhere in the string, but I can't find where. Did I do this right? Here's my code: <?php if ($row_rs_positions['active']=='Yes') { echo 'do { <div class="displayjobs"><div class="jobheading"><p><a href="careers.php?positionid= . ucwords($row_rs_positions['positionid']) ."> . ucwords($row_rs_positions['title']) .</a><strong> - <span class="style5">Added . ucwords($row_rs_positions['date']) .</span></strong></p></div><div class="jobdesc"><p> . ucwords($row_rs_positions['summary']) .... <a href="careers.php?positionid= . ucwords($row_rs_positions['positionid']) .">View Position</a></p></div></div> } while ($row_rs_positions = mysql_fetch_assoc($rs_positions))'; } else { echo '<div class="jobopenings"><p align="center">Thank you for your interest in Laser Dynamics. Currently we do not have any job openings within The Company. We are, however, always accepting resumes and applications. If you would like to be considered for a future position here at Laser Dynamics, please submit a resume and application <a href="submitapp.php">here</a>.</p></div>'; }?> Thank You!
  6. Then I guess my question is how do I call for that value before sending the header?
  7. So what i'm trying to do can't truly be that hard, but I can't get it to work. I'm trying to make a form post information to a database (which it does), then output the entered value into a url. Here's my code to see if I can get it to make sense. Form code: <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="driving_directions" target="_blank" class="directions-form" id="driving_directions"> The editFormAction is supposed to post to a db as I said, and forward to data.php?data= which it does, but it does not fill in the posted information. I created a recordset that's supposed to pull the most recent post to the db and display it, but I still get no results. Here's the code for that: $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "driving_directions")) { $insertSQL = sprintf("INSERT INTO driving_directions (from_addr) VALUES (%s)", GetSQLValueString($_POST['from_addr'], "text")); mysql_select_db($database_ldregister, $ldregister); $Result1 = mysql_query($insertSQL, $ldregister) or die(mysql_error()); $insertGoTo = "data.php?data=$fromaddress"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } mysql_select_db($database_ldregister, $ldregister); $query_rs_directions = "SELECT * FROM driving_directions WHERE from_addr = '$editFormAction'"; $rs_directions = mysql_query($query_rs_directions, $ldregister) or die(mysql_error()); $row_rs_directions = mysql_fetch_assoc($rs_directions); $totalRows_rs_directions = mysql_num_rows($rs_directions); $fromaddress = str_replace(" ","+",$row_rs_directions['from_addr']); ?> Any ideas? Thank You!
  8. I've got a basic if statement that keeps giving me an unexpected $end error when I try to execute it. Any idea what I'm missing? Here's my code: <?php if ($row_rs_staff['title']=="N/A") { echo ''; } else { echo '<p>Department Title: ' . ucwords($row_rs_staff['title']) .'</p>'; } if ($row_rs_staff['extension']=="N/A") { echo '<p>Phone: 616.892.7070</p>'; } else { echo '<p>Phone: 616.892.7070 Ext. ' . ucwords($row_rs_staff['extension']) .'</p><p>Fax: 616.892.7072</p>'; if ($row_rs_staff['email']=="N/A") { echo ''; } else { echo '<p>E-Mail: ' . ucwords($row_rs_staff['extension']) .'</p>'; }?>
  9. It errors out that headers have already been sent. "Warning: Cannot modify header information - headers already sent." This is what I've been running into.
  10. I'm using recaptcha to validate my form- but I can't manage to manipulate the code properly. I need it to submit my file 'submit.php' instead of echoing 'you got it'. Is there an easy way to do this? if ($_POST["recaptcha_response_field"]) { $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($resp->is_valid) { echo "You got it!"; } else { # set the error code so that we can display it $error = $resp->error; } } echo recaptcha_get_html($publickey, $error); Thanks!
  11. I'm trying to echo a field of my database and limit its characters using substr, but I can't seem to get it right. Any ideas? It's supposed to limit character output to 15 characters. My Code: <?php echo substr($row_rs_news['fulltext'], 0,15); ?> Any suggestions would be appreciated
  12. Hi All, I'm working on this if statement that basically shows a customer a box for their email address and the option to submit it for inclusion in a contact list if an item is not available. However, when I try to load it in browser it tells me theres a parse error. What have I done wrong? Here's my code. I've done a few statements like this before, but this one seems to be marked up incorrectly. Thanks! <?php if ($row_rs_store['stockstatus']==Yes) { echo '<p>Shopping Cart Content Goes Here. Such as QTY, Add To Cart Button.. etc. This will only show up if the item is declared as in-stock in inventory. This elminates customers purchasing items that you may not have in stock, but keep in mind it is important to update this value often.</p>'; } else { echo '<p>Currently this product is unavailable for purchase. If you would like to be notified when it becomes available, please provide us with your email address below and we will contact you.</p></br><form action="notify/notifyme.php" method="get" enctype="application/x-www-form-urlencoded" name="notify" target="_self"><input name="date" type="hidden" id="date" value="<?php print date("F d, Y"); ?>" /><input name="date" type="hidden" id="date" value="<?php echo ucwords($row_rs_store['name']); ?>" /><input name="email" type="text" size="25" /><input name="submit" type="button" value="Submit" /></form>'; }?>
  13. I re-wrote the URL Variable script and made it pull $category instead of %s (technically doing the exact same thing) and now it works. Thanks for all your help!
  14. Yes, it is. If I only call out the requirement of %s (my url variable) the query works fine. It's only when I try to add another requirement that it won't work. It's weird because I can do one or the other, but not both.
  15. When I try that I get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' AND active = 'Yes' ORDER BY id ASC' at line 1. Any ideas?
  16. Hi All, I'm doing something quite simple here, but for some reason I can't get it to work. My sql query (in php) needs to select data based on two requirements. $query_rs_store = sprintf("SELECT * FROM store WHERE category = "%s" AND active = "Yes" ORDER BY id ASC", GetSQLValueString($colname_rs_store, "text")); The problem is I keep getting this Parse Error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in ere.php I've tried using ' instead of " for the specific categories, but it still doesn't work. %s is a url variable, while active is not. Does this make a difference?
  17. Hi All, I'm doing a simple if/then statement that will display a certain image if a users permissions are a certain number (1), while displaying a different image for all others. Here's my code: <?php if ($row_rs_nav['permissionlevel']) = 1 echo <div class="headingsplash" id="headingmanage"><a href="http://www.domain.com"><img src="images/manageusers.jpg" alt="Manage Users" width="60" height="45" /></div> else echo <div class="headingsplash" id="headingmanage"><img src="images/blue.jpg" alt="Manage Users" width="60" height="45" /></div> ?> For some reason, when I execute the page, i get the error "Parse error: syntax error, unexpected '=' in /services/main.php on line 144" This line is of course, the if statement. Can anyone see what i'm doing wrong? Thanks!
  18. If i'm not terminating the session (logging out), then how do I go about pulling the data from that session? The user never types their name, but it's stored under the same table in which the login page validates the username/password and permissions that got them to that page in the first place.
  19. I've already started the session, this is merely continuing it on this page. Here's the code: //initialize the session if (!isset($_SESSION)) { session_start(); } Here's the code for the entire query portion of the page. The only additional PHP in this is the dynamic text echo displaying the results. <?php require_once('../Connections/bmc.php'); ?> <?php //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "login.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = "1,2,3,4"; $MM_donotCheckaccess = "false"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && false) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_bmc, $bmc); $query_rs_nav = "SELECT * FROM admin_navcategories"; $rs_nav = mysql_query($query_rs_nav, $bmc) or die(mysql_error()); $row_rs_nav = mysql_fetch_assoc($rs_nav); $totalRows_rs_nav = mysql_num_rows($rs_nav); $colname_rs_user = "-1"; if (isset($_SESSION['firstname'])) { $colname_rs_user = $_SESSION['firstname']; } mysql_select_db($database_bmc, $bmc); $query_rs_user = sprintf("SELECT * FROM admin_users WHERE firstname = %s", GetSQLValueString($colname_rs_user, "text")); $rs_user = mysql_query($query_rs_user, $bmc) or die(mysql_error()); $row_rs_user = mysql_fetch_assoc($rs_user); $totalRows_rs_user = mysql_num_rows($rs_user); ?>
  20. Hi All, I've got a user login form that forwards the user to a page based on their permissions. This part of the form works fine, so I know it is passing the SESSION variable correctly. What i'm trying to do though, is on the landing page, I want to says "Welcome, Username!. Right now that information is stored in a table called firstname, and here is my query attempting to gather that information. Any ideas what I have missed? Thanks in advance for your help! $colname_rs_user = "-1"; if (isset($_SESSION['firstname'])) { $colname_rs_user = $_SESSION['firstname']; } mysql_select_db($database_bmc, $bmc); $query_rs_user = sprintf("SELECT * FROM admin_users WHERE firstname = %s", GetSQLValueString($colname_rs_user, "text")); $rs_user = mysql_query($query_rs_user, $bmc) or die(mysql_error()); $row_rs_user = mysql_fetch_assoc($rs_user); $totalRows_rs_user = mysql_num_rows($rs_user);
  21. I managed to get it to work (had a space in the wrong place). But if the captcha is wrong, it refreshes the page before it displays the error, and all the input data is lost. Is there a way to make it echo w/o refreshing? That way the page information isn't lost.
  22. Hi Everyone, So i'm working on this captcha script- using recaptcha, and it doesn't seem to make any difference if the input information is correct or not, yet it still posts the form. Here's the code, can anyone see what i'm doing wrong? The script (recaptcha) works fine if i don't use it integrated into my form- so I know it's actually working. Any help is much appreciated <div class="quoteform"> <form action="" method="post" enctype="multipart/form-data" name="form" class="forms" id="form"> <table width="100%" border="0"> <tr> <td width="30%"> </td> <td width="70%"><input name="date" type="hidden" id="date" value="<?php print date("F d, Y"); ?>" /></td> </tr> <tr> <td>Company Name:</td> <td><input name="company" type="text" id="company" size="30" /></td> </tr> <tr> <td>Contact Name:*</td> <td><input name="name" type="text" id="name" size="30" /></td> </tr> <tr> <td>Email:*</td> <td><input name="email" type="text" id="email" size="30" /></td> </tr> <tr> <td>Instructions:*</td> <td><textarea name="instructions" id="instructions" cols="30" rows="5"></textarea></td> </tr> <tr> <td>Quantity:</td> <td><input name="quantity" type="text" id="quantity" size="30" /></td> </tr> <tr> <td>Attach File #1:</td> <td><input name="file01" type="file" id="file01" size="30" /></td> </tr> <tr> <td>Attach File #2:</td> <td><input name="file02" type="file" id="file02" size="30" /></td> </tr> <tr> <td>Attach File #3:</td> <td><input name="file03" type="file" id="file03" size="30" /></td> </tr> <tr> <td> </td> <td><?php require_once('recaptchalib.php'); // Get a key from http://recaptcha.net/api/getkey $publickey = "****"; $privatekey = "****"; # the response from reCAPTCHA $resp = null; # the error code from reCAPTCHA, if any $error = null; # was there a reCAPTCHA response? if ($_POST["recaptcha_response_field"]) { $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($resp->is_valid) { header("Refresh: 0;url=quotesubmitted.php"); } else { # set the error code so that we can display it $error = $resp->error; } } echo recaptcha_get_html($publickey, $error); ?></td> </tr> <tr> <td> </td> <td><input name="loggedip" type="hidden" id="loggedip" value="<? echo getenv('REMOTE_ADDR'); ?>" /></td> </tr> </table> <div align="center"> <input type="submit" name="submit" id="submit" value="Request Quote" /> </div> </form>
  23. Hi All, So i'm attempting a script that basically echos "thank you for submitting" when a brief form is filled out. I've been running into trouble because the information is posted to a sql db, and i could not get the script right so I resorted to dreamweaver for one of their scripts. The only problem, is dreamweaver only allows the user to go to another page when the post is complete, where I'd like it to echo. Here's my code, is it possible anyone can tell me what i need to modify? I don't usually resort to scripts like this, but I need it to work and all... Thanks everyone! $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "referral")) { $insertSQL = sprintf("INSERT INTO referring_website (referalid) VALUES (%s)", GetSQLValueString($_POST['referral'], "int")); mysql_select_db($database_admin, $admin); $Result1 = mysql_query($insertSQL, $admin) or die(mysql_error()); $insertGoTo = "index.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } Form Code: <form id="referral" name="referral" method="POST" action="<?php echo $editFormAction; ?>"> <table width="76%" border="0"> <tr> <td width="43%"><div align="right">ThomasNet</div></td> <td width="57%"> <div align="center"> <input type="radio" name="referral" id="referral" value="2" /> </div></td> </tr> <tr> <td><div align="right">Google</div></td> <td><div align="center"> <input type="radio" name="referral" id="referral2" value="1" /> </div></td> </tr> <tr> <td><div align="right">Directly</div></td> <td><div align="center"> <input type="radio" name="referral" id="referral3" value="3" /> </div></td> </tr> </table> <br /> <input type="submit" name="submit" id="submit" value="Submit" /> <input type="hidden" name="MM_insert" value="referral" /> </form>
  24. I've got a simple search script set on my page, retreiving information off of my sql databases. For some reason when I limit the data I get an error : Parse error: syntax error, unexpected T_VARIABLE in search.php on line 140 Line 140 is: $limit=10; The actual script code is: <?php // Get the search variable from URL $var = @$_GET['q'] ; $trimmed = trim($var) //trim whitespace from the stored variable // rows to return $limit=10; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search...</p>"; exit; } // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //specify database ** EDIT REQUIRED HERE ** mysql_select_db($database_quotes, $quotes); // Build SQL Query $query = "select * from ldi where id like \"%$trimmed%\" order by date"; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; // google echo "<p><a href=\"http://www.google.com/search?q=" . $trimmed . "\" target=\"_blank\" title=\"Look up " . $trimmed . " on Google\">Click here</a> to try the search on google</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>Displaying Search Results For: "" . $var . ""</p>"; // begin to show results set echo "Results"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["date"]; echo "$count.) $title" ; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>&nbsp "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> Does anyone have any idea where I went wrong here? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.