Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. You would just modify the query logic so that if no search term is provided, you retrieve all rows from the table - <?php public function __construct() { if(isset($_GET['s']) && $_GET['s'] != '') { $safeQuery = mysql_real_escape_string($_GET['s']); $theQuery = "SELECT * from parts WHERE part_num LIKE '%$safeQuery%' OR dealer LIKE '%$safeQuery%' OR retail LIKE '%$safeQuery%' OR uom LIKE '%$safeQuery%' OR page LIKE '%$safeQuery%' OR product_desc LIKE '%$safeQuery%'"; } else { $theQuery = "SELECT * from parts"; } $res = mysql_query($theQuery); $this->numRows = mysql_num_rows($res); $i = 0; while ($result = mysql_fetch_array($res)) { $this->ResultArray[$i] = $result; $i++; } } The starting query does not have any ORDER BY term in it, so you just get the rows in the order that they are stored in the table. You should probably add an ORDER BY term to both queries so that your product information is retrieved in some specific order, such as alphabetical by product name.
  2. ^^^ You need one table with all your events in it. If you need to distinguish the type of event, you would have a `type` column. ^^^ Yes. Since the primary key is the day of the month, you simply directly access the data, if any, for the day as you loop over the days of the month. If you mean you are storing multiple events on any particular day as an array for that day, you would simply loop over that sub-array for the current day - <?php $data[2][] = 'event 1 on day number 2'; $data[2][] = 'event 2 on day number 2'; $data[2][] = 'event 3 on day number 2'; //$day would loop over the days for the current month - 1, 2, 3, ...,31 //$data[$day] would access the array of events for day number 2. if(is_array($data[$day])){ foreach($data[$day] as $event){ echo "$event<br />"; } }
  3. Sample code that would do this - <?php // retrieve your data into an array (faked here for demo) $data[] = 'Academic Advisory'; $data[] = 'Academic Assistance'; $data[] = 'Academic Calendars'; $data[] = 'Academics Office'; $data[] = 'Administration'; $data[] = 'Adult Learners'; $data[] = 'Alumni Chapters'; $data[] = 'Alumni Events'; $data[] = 'Athletics'; $data[] = 'Campus Life At a Glance'; $data[] = 'Campus Recreation'; $data[] = 'Campus Safety & Security'; $data[] = 'Class Schedules'; $data[] = 'Counseling Center'; $data[] = 'Course Descriptions and Catalog'; $data[] = 'Department Directory'; $data[] = 'Departments & Programs'; $data[] = 'Fellowships'; $data[] = 'Finals Schedules'; $num_rows = 12; // number of rows down $num_cols = ceil(count($data)/$num_rows); // calculate number of columns echo "<table>"; for($i=0; $i<$num_rows;$i++){ echo "<tr>"; for($j=0; $j<$num_cols;$j++){ $element = $i + $j * $num_rows; if(isset($data[$element])){ echo "<td>$data[$element]</td>"; // cell with data } else { echo "<td> </td>"; // empty cell } } echo "</tr>\n"; } echo "</table>";
  4. It looks like your search class is what does the searching. You would need to post the search.php code.
  5. Are you using a URL in your browser? It would be http://localhost/your_file_name.php
  6. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=357493.0
  7. ^^^ The problem is the output that your code is sending at line 12 of include/authenticate.php. Since the second piece of code you posted is including include/authenticate.php, that's probably not the code for authenticate.php since it would be pointless for a file to include itself, it also doesn't have 12 lines to it. What's the actual code for include/authenticate.php? Also, session_unregister was depreciated 10 years ago, throws a depreciated error message in php5.3, and has been completely removed in php5.4 that was just released. You would instead unset the MemberArea $_SESSION variable.
  8. Mysql 5.0 and below used either the ENGINE or TYPE keyword. Mysql 5.1 and above uses ENGINE only. What version of mysql was your backup made under and what version are you trying to restore under?
  9. And the error or exact symptom you are getting is???
  10. AFAIK, the correct syntax should be - ENGINE=MyISAM
  11. You cannot unconditionally use stripslashes on data as that would prevent you from actually using the \ character in the data. You must fix what the magic_quote settings do so that your data is stored and retrieved correctly (if you double escape the data and the extra \ characters get stored in your database, you cannot correctly perform any searches on that data should the magic_quotes setting get altered after the data has been stored.)
  12. Further to the above, if your external data contains arrays, you would need to write a function to unescape the data and use array_walk_recursive to process all nested levels of the external data. Edit: Specifically - <?php function unescape_deep(&$item, $key){ $item = stripslashes($item); } if(get_magic_quotes_gpc()){ array_walk_recursive($_GET,'unescape_deep'); array_walk_recursive($_POST,'unescape_deep'); array_walk_recursive($_COOKIE,'unescape_deep'); }
  13. The php.net documentation has a section on what the magic_quotes settings do, didn't do, and why php.net tried to get the language to do something that the programmer should have been doing only when he needed it to be done - http://us.php.net/magic_quotes If you cannot turn off magic_quotes_gpc or want your code to be universal, see this link - http://www.phpfreaks.com/forums/index.php?topic=357226.msg1688577#msg1688577
  14. The symptoms you stated are not possible. For the $string variable with that content, you will not end up with any \ characters stored in your database after using mysql_real_escape_string once on the data. You must have something else going on in your actual code OR the $string variable is actually coming from external data (get, post, cookie) and magic_quotes_gpc is ON and is escaping the value once before it reaches your code. You need to use mysql_real_escape_string on string data being put into your query statements to both properly escape data (the escaping that magic_quotes_gpc does, does not take into account different character sets, which is why it has been completely removed in the latest php version), and to prevent sql injection. I also hope you are validating/casting external numerical data being put into your queries to prevent sql injection through it as well. If you are not already using mysql_real_escape_string on string data and validating/casting numerical data (or using prepared statements), you will need to modify your code to do so, assuming you don't want database errors to occur for legitimate visitors or hackers dumping the content of your database tables. If your 40+ pages are largely the same, but for different content or different data value, you need to re-factor/simplify what you are doing and make your pages data driven (i.e. have one or just a few pages where the data defines what your code does on the one or just a few pages.)
  15. Variable-variables are also three times slower than using an array.
  16. I just checked with a 5th grader and she correctly got that you multiply by 6/10 or .6 to find 60% of something.
  17. LOL. Don't make it harder than it really is.
  18. 50% is the same as multiplying by .5 (i.e. multiplying by 1/2), 60% is the same as multiplying by .6 I'm pretty sure your middle school and/or high school math teachers would be disappointed about now.
  19. A) You would use an array, instead of a sequence of named variables. Arrays are for sets of data. You would then simply loop over the array. See: foreach B) How do you know which images are to be used for any page? What defines the range of images? Are they present in a specific folder for each page, in which case you would simply get a listing of the images and loop over them to output the <img tags?
  20. See: gmmktime
  21. mktime uses your current timezone setting when interpreting the date/time parameters. It will give you the Unix time that date/time occurred at in your timezone.
  22. It sounds like your code responsible for getting and displaying the data is executed first. The logic on your page needs to be organized with the main php code that operates on submitted data first, followed by any code that produces the content to be displayed on the the page. The general flow in any code should be - inputs, processing, output. In any case, we cannot directly help without seeing the code that reproduces the symptom (I can think of 2-3 reasons other then the organization of the logic on the page that could cause the same symptom.)
  23. To get specific rows within a group, see this link - http://dev.mysql.com/doc/refman/5.5/en/example-maximum-column-group-row.html
  24. Eval() executes a (valid) php statement. If you wanted to produce and execute $c = 10 * 1.2;, that's what the "string" you supply to the eval() statement would need to be after all the $a, $b variables have been replaced with their contents. Edit: Specifically - <?php $a = '* 1.2'; $b = '10'; eval("\$c = $b $a;"); echo $c;
  25. I suggest you re-read the series of posts I made in your previous thread about this. One of the pieces of information that was mentioned is that your form can only submit one item at a time via the 'Buy' submit buttons. Therefore, the following code only has one product to loop over, is overwriting the $_SESSION['cart'] variable, not adding items to it, and is pointless - foreach($_POST as $fieldname => $fieldvalue) { $item[$fieldname] = $fieldvalue; } $_SESSION['cart'] = $item; In fact, someone handed you working add to cart and display cart functions in that thread.
×
×
  • 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.