Jump to content

robj

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

robj's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm attempting to rewrite the following: /test,name.php to /test Here's the short story: The files are being generated by a different department and are automatically placed on the server. There are 2 parts to the file name. The first is the type of data (which will always be different), and the second is the time/date/version/revision#/ stamp. The parts are currently being separated by a comma, but could be changed to a hyphen or period (underscore is cannot be used unless it's possible to define the last underscore as the separator). I only want to display the first part of the file name, and preferably drop the .php extension. Example: http://www.MYURL.com/first_name,123456789.php would read http://www.MYURL.com/first_name My current .htaccess file: RewriteEngine On RewriteBase / # Externally redirect direct client requests for .php files to non-.php URLs RewriteCond %{THE_REQUEST} ^GET\ /([^/]+/)*[^.]+\.php(\?[^\ ]*)?\ HTTP/ RewriteRule ^(([^/]+/)*[^.]+)\.php$ http://www.MYURL.com/$1 [R=301,L] # # Internally rewrite extensionless page URLs to PHP files # if no extension or trailing slash on requested URL RewriteCond %{REQUEST_URI} !(\.¦/$) # and if filename exists when .php is appended RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule (.+) /$1.php [L] I've tried quite a few attempts without getting close. I'm not as skilled with apache as I'd like (hence the notes) The above works perfect, but I need help with remove the comma and everything past it. All help and ideas are appreciated. Thanks.
  2. I guess the other option is to merge both columns then COUNT and ORDER BY. Anyone know the best way to accomplish this task?
  3. Certainly. Keeping the long story short. I created an app to assign and manage tasks. I'm very comfortable with the mysql query basics, but not the 'advanced' queries. The table in question is made up of 6 fields (id, date, department, task, assign_to, assign_by). assign_to and assign_by are made up of a 2-digit ID assign that's related to a user/employee/client via another table. I want to generate a 'top assigned to', and 'top assigned by' report, which the above has accomplished. However (and really just for learning purposes), I want to know how many times an ID/user has been referenced. Explained: SELECT assign_to,assign_by, COUNT (*) as cnt FROM table_name GROUP BY id_within_added_column ORDER BY cnt DESC LIMIT 5 I'm not entirely sure where the breakdown lies. The query is definitely reading both columns and counting within them, but not adding the ID from both as 1 column. So when I GROUP BY assign_to, the output is of results is correct, but not when I GROUP BY assign_to,assign_by I get a low count and no ID.
  4. So how would i accomplish multiple columns? I'm able to get the data from 2 columns, but I'm having issues with GROUP BY: $query = "SELECT your_column1, your_column2, COUNT(*) as cnt FROM your_table GROUP BY ?????"; while($row = mysql_fetch_assoc($result)){ echo "NUMBER {$row['?????']} appears {$row['cnt']} times<br />"; } GROUP BY your_column1,your_column2 does not work
  5. Works perfect PFMaBiSmAd, Thanks.
  6. // Initialize array for ($i = 0; $i < 100; $i++) { $numbers[$i] = 0; } // Count the 300 numbers, I'm assuming they're in a database while ($current_number = mysql_fetch_assoc($result)) { $the_number = intval($current_number['two_digit_number']); $numbers[$the_number]++; } // Output the number counts foreach ($numbers as $number => $count) { echo "$number appears $count times<br />"; } The above doesn't exactly work. It's outputs as follows: 0 appears 0 times 1 appears 0 times 2 appears 0 times 3 appears 0 times 4 appears 0 times The code below is excellent in it's current form. Add as many numbers in the array as you'd like and it does the job great. $numbers = array(1,5,2,1); $count = array_count_values($numbers); ksort($count); foreach($count as $key => $val) echo "Number {$key} appears {$val} times"; However, I cannot get the data from the database into either of these scripts. I can only assume the way I'm connecting my DB is causing the issue. So here it is: // MySQL Connection $connection = mysql_connect("localhost", "root", ""); if (!$connection) { die('Counld Not Connect, Dummy! ' . mysql_error()); } mysql_select_db("tasks", $connection); $result = mysql_query("SELECT userID FROM marketing"); Keep in mind, that I'm use XAMPP locally to develop this project (might also be issue). So Orio, if you have any suggestions, I'd appreciate it. rob
  7. I have a field that contains about 300 2-digit numbers. I want to count how many times each number appears. I've tried using 'count', but can't for the life of me get it to work correctly(ehem... at all). I honestly don't know how to program this. Can someone provide me with a script that would accomplish the following: 1. count how many time a number appears in the field, starting with 00 as the base number 2. auto increment the base number up to 99 3. echo as such: NUMBER## appears ## times Thanks in advance. rob
  8. I'm pretty new to ajax, but I'm a quick learner and here is my test application. To keep it short: I have a simple main screen with 3 option. Add, Update, Delete. You click Add and It loads a form under these 3 options. Pretty easy, but I don't know how to submit the form to that case. I had the form posting to itself originally, but once I load the form using a get ID tag, the form breaks unless the action is set to the file location. I want this form to submit within the page without redirecting. Here's some relevant code: index.php: <body onload="init()"> <div id="load"> </div> <div> <a href="#" class="tabs" id="additions">Additions</a><br /><br /> <a href="" class="tabs" id="update">Update Entries</a><br /><br /> <a href="" class="tabs" id="delete">Delete</a><br /><br /> </div> <div id="Postjax" class="clearer"></div> </body> javascript: function init () { var tabs = document.getElementsByClassName('tabs'); for (var i = 0; i < tabs.length; i++) { $(tabs[i].id).onclick = function () { getTabData(this.id); } } } function getTabData(id) { var url = 'ajaxSwitch.php'; var rand = Math.random(9999); var pars = 'id=' + id + '&rand=' + rand; var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} ); } function showLoad () { $('load').style.display = 'block'; } function showResponse (originalRequest) { var newData = originalRequest.responseText; $('load').style.display = 'none'; $('Postjax').innerHTML = newData; } Form.php: <?php if (isset($_POST['submit'])) { $con = mysql_connect([REMOVED], [REMOVED], [REMOVED]); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db([REMOVED], $con); mysql_query([REMOVED]); mysql_close($con); ?> <div style="width:600px;"> Success </div> <?php } else { ?> <form method="post" action="form.php"> [iRRELEVANT INPUT BOXES] <input type="submit" name="submit" value="Send"> </form> </div> <?php } ?> Ajax Switch/Case: <?php if ($_GET['id'] == 'additions') { switch($_GET['id']) { case 'additions' : include_once('Form.php'); break; //case 'update' : include_once('upForm.php'); break; //case 'delete' : include_once('delForm.php'); break; default: echo 'There was an error.'; break; } } //print $content; usleep(1000); ?> Any help, suggestions, and/or new methods would be greatly appreciated. Thanks rob
×
×
  • 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.