Jump to content

xProteuSx

Members
  • Posts

    476
  • Joined

  • Last visited

Everything posted by xProteuSx

  1. PHPFreaks folks, How in the heck do I name an array within an array (multidimensional array), so that I can bring it up by array name instead of array number? Please help me out here -- its over my head, I guess.
  2. Maybe I am not understanding your suggestions (thanks by the way!), but the themes that I am thinking of are drastically different so I am not sure I can adopt your suggestions. These themes do have a core style.css file, but each and every theme has completely different content formatting for each page, so calling up different .css files won't do the whole trick. I've implemented a temporary work-around, that I am confident I will be frowned upon by one and all: www.website.com/index.html -> all content = include('theme/' . $themedirectory . '/index.html') www.website.com/about.html -> all content = include('theme/' . $themedirectory . '/about.html') www.website.com/contact.html -> all content = include('theme/' . $themedirectory . '/contact.html')
  3. I am starting a project that is way over my head. As usual, I will be learning a lot as I go. The short and skinny: a website that allows users to select which theme they would like to use. My file structure is like this: www.website.com www.website.com/index.html www.website.com/about.html www.website.com/contact.html //default theme www.website.com/theme/default/index.html www.website.com/theme/default/about.html www.website.com/theme/default/contact.html //theme 1 www.website.com/theme/theme1/index.html www.website.com/theme/theme1/about.html www.website.com/theme/theme1/contact.html //theme 2 www.website.com/theme/theme2/index.html www.website.com/theme/theme2/about.html www.website.com/theme/theme2/contact.html So, I think its pretty self explanatory. I would like the URL's to always be: www.website.com www.website.com/index.html www.website.com/about.html www.website.com/contact.html But I want these files to change depending on the theme selected. So, if the user selects "theme 1": www.website.com/index.html -> will display content of -> www.website.com/theme/theme1/index.html www.website.com/about.html -> will display content of -> www.website.com/theme/theme1/about.html www.website.com/contact.html -> will display content of -> www.website.com/theme/theme1/contact.html I have done a bunch of research, but all I seem to find are tutorials and articles about using the include(), include_once(), and require() functions. Any pointers to some better content? Is there a shortcut that can be taken? Something akin to .htaccess rewrite?
  4. Thank you very much requinix, kicken.
  5. I have a website with a series of directories that are created "on the fly". These images are used exclusively for storage of image files, and I've written a script that copies a default index.html file to each directory as it is created. This index.html file has nothing but a redirect script, so that if someone tries to access the directory instead of a file listing they are sent to the home page of the website. Is there any way to achieve this using the .htaccess file? Is there any way to get around having to copy this silly index.html file to every single directory? I don't even know how to phrase this issue for Google ...
  6. Hi guys. I am having a hell of a time finding a WYSIWYG editor that can also handle image uploads. I have a website where I would like users to be able to enter text and images as part of their articles, but not just URLs to images, but to actually upload their images to the site through the WYSIWYG editor so that they can be used in the articles. Is this possible? I can't seem to get a straight answer ... TIA.
  7. Where the heck is the "Solved" button??
  8. Got it working. Did this: $year_value = 'val_' . $_SESSION['add_value_year']; Then: $value = "SELECT rb_values." . $year_value . ", rb_images.img_thumb, rb_images.img_lock, rb_notes.not_general, rb_notes.not_modern, rb_notes.not_specialized FROM rb_values, rb_images, rb_notes WHERE rb_values.val_id = $note[0] AND rb_images.img_id = $note[0] AND rb_notes.not_id = $note[0]"; Then I could use: $row[$year_value]
  9. I've got something like this: $value = "SELECT rb_values.val_" . $_SESSION['add_value_year'] . ", rb_images.img_thumb, rb_images.img_lock, rb_notes.not_general, rb_notes.not_modern, rb_notes.not_specialized FROM rb_values, rb_images, rb_notes WHERE rb_values.val_id = $note[0] AND rb_images.img_id = $note[0] AND rb_notes.not_id = $note[0]"; Then I use mysql_fetch_assoc(), but I don't know how to retrieve the data for: rb_values.val_" . $_SESSION['add_value_year'] . " because that row could be val_2015, val_2014, val_2013, etc. depending on the value of $_SESSION['add_value_year']. I have tried using index number, but to no avail. I really don't know what to do here.
  10. You know, I've always been very grateful for the help that I've gotten on this website. I've always looked into the different options and suggestions that I have received because I know that I am not an expert coder. I've always come back here, and contributed whenever I could (not often because I am not an expert coder). However, the last 10 times of so I've kindly asked for help, I've come up against some prick such as yourself, how deems me too stupid to be worthy of help, or himself too awesome to help. Its really sad to see the website going in that direction. If you don't want to help, just stay out of it.
  11. mac_gyver, Thanks for your reply. I am totally going to have to look into this PDO API stuff. I am putting together some long term projects, and I definitely don't want to be updating all my MySQL queries in a year. In the mean time, database normalization aside, can you help me build the function that I've outlined? Cheers.
  12. I am trying to write a function that I have never attempted before, but would save me TONS of code if I can get it to work. I have a table with an expanding number of columns. The data is annual, so the table column names go something like this: data_2010, data_2011, data_2012, data_2013, etc. With every coming year another column is added, obviously. On the webpage that accesses the data, I have set up variables for each column. However, I have to edit this code every time a new column is added. I am trying to create variables based on column names. Something like this: -> get column names (done!) -> add each column name to an array (done!) -> create variable for each column in the array Here is what I have: function getValueColumns() { $res = mysql_query('DESCRIBE table_name'); $yearcol_array = Array(); while($row = mysql_fetch_array($res)) { $outputrow = "{$row['Field']}"; if ($outputrow != 'val_id') //ignores the table primary key column { $year = substr($outputrow, -4); //checks if the year is included in the table column name if (is_numeric($year)) //if the last four digits of the table name are a number, as in a year ... {array_push($yearcol_array,$outputrow);} } } return $yearcol_array; } So now I have to write the code that will create the variables, and collect the data from those columns at a certain row. Something like this: function returnYearlyData() { $yearswithdata = Array(); foreach ($yearcol_array as $yearcol) { $select = "SELECT * FROM table_name WHERE val_id = x;"; $[column_name_here] = mysql_result(mysql_query($sql), 0, 0); if ($[column_name_here] != '') { array_push($yearswithdata,$[column_name_here]); } return $yearsdiwthdata; } So now I would have an array with variables named after the table column IF the row and column specified in the select statement is not empty. I am not sure whether I have explained this well, but I cannot figure this out myself. I've always been curious as to whether you can append text to a variable name, for example, which is a related scenario. Either way I would appreciate help. Cheers guys and gals! Oh, and happy new year! TIA!
  13. Ok, this is something that I used to know how to do. Its a local windows file, that you edit to redirect your browser when a certain URL is being looked for. The thing is that I have a website that gives me revenue via the eBay Partner Network. Unfortunately, instead of going to my website to click on the link to eBay and then looking for items (so that I can collect revenue on my purchases) I am in the habit of going to my.ebay.com. What I would like to do is have the browser take me to mywebsite.com every time I type in my.ebay.com into the browser. How can I do this? TIA.
  14. My .htaccess files usually contain something like this: AddHandler application/x-httpd-php5 .html .php .htm .shtml This tells the server to look for php code within those file types, and process it as php code, and not plain text.
  15. Seems like you've got this in a .htm or .html file. Try saving the file as .php, and see if the code runs properly. There are ways to make PHP code run in .html or .htm or .shtml files, by editing your .htaccess file.
  16. Thank you for your help guys! In the end, it proved to be mac-gyvers reply that helped, because he was right: I was using urls instead of file system paths. As soon as I changed the includes to file system paths everything started to work. Cheers, and my thanks to you all!
  17. Here is the setup: login.html with a simple login form (username, password) --> login.php (checks username, password) --> if login is good login.php sets a bunch of session variables based on some database info, sends user to members/members.html (different directory). At the top of members/members.html I have some include statements (navigation.php, which uses some of the session variables to display different navigation options). So, here's the problem: If the login is successful, and the session variables are set the session variables are not accessible within the included navigation.php file, which is at the top of the members.html page, but the same session variables are accessible on the members.html page, but outside the included navigation.php file. What is going on? Does this have something to do with scope? Here's what I know: - session variables are being set properly in the login.php file - session variables are accessible in on the members/members.html file - session variables are not accessible in the included file navigation.php which is at the top of the members/members.html file I have checked over all the code tons of times, and have checked session variable accessibility and values everywhere. I cannot understand why the session variables cannot be accessed in the included file on this page, though they are accessible in other files where navigation.php is included. The only thing that I can think of is that everything is happening in the root directory, and then the user is being sent to the /members/ directory. Could this have something to do with it? Not as far as I know, but what do I know?
  18. Please help ... I've spent 6 hours trying to fix this, with nothing to show for it
  19. I am trying to customize a bootstrap template, and I am having a massive problem which has me pulling my hair out. Here is the project, in the worx: https://www.haupysbeaverrub.ca/newest/index.html In the CSS file: https://www.haupysbeaverrub.ca/newest/css/beaverrub.css ... on line 89 I have the following: .beaverhomeheader { position: relative; top: -225px; z-index: 8; } This is because the logo is larger than the navigation bar, so I've used zindex to float it in front of the image rotator at the top of the page. So, I've had to move things around, and this top: -225px has caused all kinds of havoc. So now when you scroll to the bottom of the page, there is a huge blank space (225px of nothingness). Also, when you resize the window to reflect a smartphone resolution, there is an additional blank space below "What is Haupy's Beaver Rub Spice?". There is also something "funny" that happens near the minimized navigation in this state: a small yellow rectangle with 2 rounded corners appears near the menu widget, and it has a shopping cart and the value $55 within. I don't know how to get rid of this either. Please help oh fantastical people of PHPFreaks! Thank you in advance.
  20. And as is customary, I figure this all out about 2 seconds after I post for help. The trick is that you don't need this: $countries_array = sort($countries_array); You simply do this: sort($countries_array);
  21. I have an array that looks like this: Array ([0] => 1 [3] => [4] => 285 [6] => 190) and I would like to sort it from highest value to lowest. As is, when I print_r() this array, I get: 1 104 285 190 I would like to get: 1 104 190 285 I have tried the following: sort(), asort(), ksort(), and krsort(). What else can I try? My code looks like this: $countries_array = array_unique($countries_array); print_r($countries_array); which returns: 1 104 285 190 However, when I do this: $countries_array = array_unique($countries_array); $countries_array = sort($countries_array); print_r($countries_array); It simply returns: 1 Thanks in advance.
  22. I am looking at this example: <?php // Obtain a list of columns foreach ($data as $key => $row) { $volume[$key] = $row['volume']; $edition[$key] = $row['edition']; } // Sort the data with volume descending, edition ascending // Add $data as the last parameter, to sort by the common key array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data); ?> And also this one: <?php $array = array('Alpha', 'atomic', 'Beta', 'bank'); $array_lowercase = array_map('strtolower', $array); array_multisort($array_lowercase, SORT_ASC, SORT_STRING, $array); print_r($array); ?> However, I don't know whether is possible to combine the two and, if it is, how to do it.
  23. I am not sure whether I am not understanding something, or whether this function does not sort multidimensional arrays. When I run this nothing happens (still an unordered mess): $users_array = sortmulti($users_array, 1, 'asc'); sort($users_array, SORT_FLAG_CASE); So then I try this, but get an error: $users_array = sortmulti($users_array, 1, 'asc'); sort($users_array[1], SORT_FLAG_CASE); //index 1 is the 'username' field in the sub-arrays
  24. So I've got a list of members, that looks something like this: aardvark CandyFISH Anthony55 Beezl3bub angie13 007_bond I am trying to sort these members alphabetically, but case insensitively as well. My sorting function looks like this, and sorts an array of arrays based on the first character of the second field of each sub-array: function sortmulti($array, $index, $order, $natsort=FALSE, $case_sensitive=FALSE) { if(is_array($array) && count($array)>0) { foreach(array_keys($array) as $key) {$temp[$key]=$array[$key][$index];} if(!$natsort) { if ($order=='asc') {asort($temp);} else {arsort($temp);} } else { if ($case_sensitive===true) {natsort($temp);} else {natcasesort($temp);} if($order!='asc') {$temp=array_reverse($temp,TRUE);} } foreach(array_keys($temp) as $key) { if (is_numeric($key)) {$sorted[]=$array[$key];} else {$sorted[$key]=$array[$key];} } return $sorted; } return $sorted; } Then I call the function up like this: $users_array = sortmulti($users_array, 1, 'asc'); In the end I end up with sorting that looks like this: 007_bond Anthony55 Beezl3bub CandyFISH aardvark angie13 As you can see the sorting considers all upper case characters to be first, followed by lower case characters. I am looking for something like this: 007_bond aardvark angie13 Anthony55 Beezl3bub CandyFISH Any pointers on how I can do this? Thank you in advance.
  25. Of course, I figure it out 3 minutes later ... SELECT * FROM my_table WHERE DATE(tbl_time) > date_sub(now(), interval 1 month); Turning tbl_time, the timestamp, into a date made it all work. Cheers.
×
×
  • 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.