Ordering Info Returned From Database
I have a PHP page on my site which pulls back info from my MySQL database and displays it in a table under appropriate headings. Is there code that I could add to these headings so that
a) the same page could be redisplayed with the information sorted by the third column instead of the first b) information in the columns could be displayed in reverse order (maybe Z to A or highest figure to lowest figure)
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Ordering Rows In A Database(output)
I am trying to do the following: My Client needs to be able to go into a certian table (we'll say table1) which has the following columns: id - unique ID stock_id - ID input by user when added description - short description ordering - what position to display Basically this question is about the "ordering" column. The client wants to be able to select a certain row and change the ordering column to where she wants the product to be ordered. For instance: ID| stock | description | ordering ------------------------------------------- 1 | 2222 | description | 2 2 | 3123 | description 2 | 1 3 | 2341 | description 3 | 6 So when these 3 rows are displayed through PHP the item with ID number 2 would be displayed first, then the item with ID number 1 and so on...My problem is what would be the easiest way to let her change the order of the products.
No Database Query Is Allowed Yet Value Is Still Returned
I am developing. One of types of users we allow is "justTestingTheSite", a type of user I developed to give demo's to prospective clients. The purpose of this level of security is to let someone log in and see everything as if they were root, and yet not be able to update or delete anything, as they have no real priveledges at all. I just logged in as root and created such an account, then I log out and logged back in using the new account. I tried to edit the weblog on the front page of the site. Everything worked as it should of: I was able to get to the screen, edit it, and hit submit, and then, because of my low security rating, the software did not change the values. Perfect. But the results message said "You've just updated 26 items." I was expecting it to say "You've just updated 0 items." 26 just happens to be the number of entries on the weblog which is the front page of the site. For the life of me, I can not figure out how the software got the number 26. More so, the message seems to be incorrect, none of the 26 items seems to have been updated. function standardUpdate($functionForEditing) { global $users; $users->check(); .....
Recall Database Info
Hi, I want to create a page where users can put in certain information like you normialy would in a form but when they click submit another page will load that will look like the original form the signed up with and everything they filed in that time will be there and they can make changes to that and then click submit and the changes are made to databse automaticialy.
How To Send Info To Database
im wondering how to submit info into a database. i know the code goes something lie $sql = "UPDATE <tablename> set $var = "var" but i know that is wrong and i want to put it in form so on submit it posts it in the database.
Info Deleted Itself From Database?
I got some info (news system) in a SQL database but after some days it deletes by itself it happened to me once but i thought i didnt remembered that i deleted it but today it happened again...it deleted by itself! lol I have other tables in the same database so its a table problem... How can i fix this? Did i miss something at the table configuration?
Get And Insert Info Into Database
I have one table (form) that has multiple fields. Here are few fields we need to know: ID, NAME, CITY, STATE, PROFESSION, x, y, z (x, y, z means more than 50 fields that give me more information about each name). The ID and NAME are unique and they don't change (each name has it's own ID). A NAME and its ID can be in any CITY, STATE or PROFESSION but this is fixed. That means if ID# 123 for Mr JOHN is Austin, TX, that will stay in Austin, TX for ever. I have more than 5000 NAME and it's ID, 9 professions, all US States and all Cities in my database. Here is what I need to do: I want to have a form on my site that my visitor finds his name first and then enters more information about him/her that will complete my database fields of x,y,z. What I'm thinking to do is to create a drop down list that the visitor first selects the profession. Based on the profession the second list shows the states that has that profession. Then by selecting the state, all the available cities will show up in the third list, and by selecting the city all the names related to that profession in that city, state will show up and he can select the name from the forth list. Then he enters other required information about him that will be send and saved in the database. Here is what I have done and I know to do so far: I have created the database with all the information in one table. I also know how to send data to database to be saved. But my problem at this point is how to create this list selection that narrows the search to find the right person.
Retrieving Info From A Database
I would like the code below to fetch and display in an html table the Ad_Id, Date, and Type_Job fields from the 1st 10 rows of a table called employment. I'd like the results to be sorted first by date and then by the Ad_Id #. I have replaced my username and password with "user" and "password". Currently, the script returns the error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource Also, the script is ignoring the css info that I have supplied. Code:
Populating A Form Wth Database Info
I've coded a piece of code which populates a form with data read from the database: $connection=mysql_connec ("localhost", "f2821842", "f2821842"); $result=mysql_select_db("QUERIES"); $query=mysql_query("Select * from Emp_Details where emp_num = '$employnum'"); while($row=mysql_fetch_array($query)) {$empname=$row['emp_name'];} <form name="webregform" action="webadmin2.php" method="post"> <input name="requiredname" type="text" size="30" value="<?php echo "$empname"; ?>"> </form> When I echo the $requiredname, I get spaces and no data, and I know that $empname is not a space-it does read a value in a database. 1. How can I get $requiredname to print a value?
Session Variable Info To Database
I have a 2 page form. The first page page of the form POSTS to the 2nd page which, after being filled out, should send all the information (from pages 1 and 2) to the database. I have created a session variable and have placed it at the top of the 2nd page. For brevity´s sake I have placed only one of the variables in this example: <?php session_start(); $_SESSION["sessanimals"] = $_POST["animals"]; ?> After filling out the remaining variables on page 2, I want all the information (the info from page 1 brought over in the session variable and the info from page 2) sent to the database. I tried creating an INSERT RECORD on page 2 but only the variables on page 2 are subsequently sent upon submission. How do I get all the info into my database?? Here are a list of my questions: 1. Is there any way of creating one session variable for all my page 1 form variables (I have 20+ variables)? 2. is there a way to denote ALL the variables in = $_POST[]; or do they have to be listed separately? 3. How do I post all the data from page 1 and 2 into my database at once?
Insert Form Info Into Database
i am trying to enter info from a form into a mysql database. when i submit the form, a new row is created, but the information isn't contained in it? any thoughts? PHP Code:
Filling Form With Database Info
I have a table with 5 fields for a tour business activity list : (1) id -table key (2) name (3)description (4)picture -text link not binary(5) country. I would like to create a form that takes all the activitys an puts it neatly down on site in checkboxes so user can select activtys.this will be linked to form mail.i would like the activitys to be seperated by the country they r in?
Update Database Info Using Forms
i have a page uses select and cases. i already have setup and working, auth/login to the page, create a new row in the table. i am now trying to have the user alter the information that the just put into the table. this is the code where i have setup to modify the info, $id is passed over. this puts the correct information into the form field. when i hit submit, the information, $name, $content, $id are not passed over. echo-ing results blank. PHP Code:
Hiding Database Connection Info
In a php script, I have to connect to a remote mysql database. I'm a bit worried that some user might be bale to retrieve the source of the page and see the user name and password to connect to the db. Is this resonable? What's the best way to avoid it?
Obtaining Info From Database Table
How do you obtain fields from a table and assign each field to a variable to be used as needed. An example: Say i had: table name : user Field 1 : User name Field 2: Password then i wanted: $username = field 1 $password = field 2.
User Info Not Posting To Database
I am trying to figure out why my script isn't updating the information of the user names stored in the database. Can anyone give me the solution? Below is the script: Code:
How To Obscure Database Info In PHP Pages
I'm moving from Cold Fusion to PHP and I have a question that none of the books I have answers adequately: In Cold Fusion, database connection parameters like the table, username and password are configured on the server. Since they are at the backend, nothing is exposed on the page except the queries themselves. In PHP, from what I see, the database info is on the page. Is this not a security risk? How can one be sure that this info is not on the page sent to the user?
Validating Form Info Before Inserting It Into Database
I have been trying to create a PHP application where you can add customer contacts to a MySQL database. Now, my problem began when I created a form where the user can add in a customer's name and info to the database. In an effort to alert the user that they may be adding a customer that is already setup in the database, knowing that some of the customers may have the same names, e.g. there is more than one Bobby Ray Brown, I decided to add a script that queries the "customers" table in the database and searches for all results that match the input from the user. Code:
Entering/checking Info Into Mysql Database
I have set up a client database where one can view, add, edit and delete entries. I ran into a problem setting up the add page. On this page i have set up forms to add info into the DB, and it works fine, but i dont want duplicate clients. Is there a way to set it up so that when you submit the form with the info it checks for duplicates and if there is one returns "sorry this record exists?"
Retrieve An Image In Folder From Info Out Of Database
i am having problems displaying an image once i have uploaded it. i upload it to a folder and store its name in a database. below is the code to display the image. I have figured out the the code is not grabbing the name from the database but i can not figure out why. can anyone help? //Retrieves data from MySQL $data = mysql_query("SELECT IMAGE_NAME FROM item") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo "<img src=http://www.abcxyz.com/pics/".$info['photo'] ."<br>"; }
Sends SMTP Mail From Database Info
I've got this script that I want to use to send SMTP mail from a form that allows the user to select recipients from a dropdown list that is created using database info and send a message. Two of the selections in the dropdown list are groups. My script works fine when the user selects only one recipient. I run into trouble when the user selects one of the two groups. The message ends up getting sent numerous times to the people in the group. I received the message 9 times. I think the script is looping more times than it should. Does this make sense so far? Here's the script that receives the form data and connects to the DB to get the recipient email addresses and then sends the message: Code:
Retrieving Database Info Based On User
I'm still quite new to php and mysql but I have been unable to figure this out. I'm attempting to display a specific row and column from a mysql database based on the user. $result = mysql_query("SELECT fbleague FROM users WHERE username = $_SESSION[username]"); fbleague is the column users is the table username is the primary key column $_SESSION[username] is the username variable Then later I try to display it with echo "You are in league $result "; I know $_SESSION[username] is set correctly because I can display that with no problems.
Uploading Info From A Text File Into A MySQL Database
what would the PHP and SQL code be to say basically: make a new row and put this in the field, what comes after each comma goes in a new field, and each new line should be a new row. I have a huge text file that i don't have a way to upload directly into a MySQL database because my webhost isn't allowing it for some reason.
Upload & Query MySQL Info Database With Image Files
I want a database I can enter information and upload a photo from a web form. Then I want to query that database for the text info with its related photo and display it (formatted) in a browser (html). Summary: 1. upload photo's and text information to database with my add article form. 2. Query the database and page the results with the text and related photo. It comes in three parts: 1. add_article.php [Text / Photo Upload Form] 2. insert_article.php [Inserts into database] 3. articles.php [View Output] Here is what I have this far:
Putting Info Into A DB / Passing Info Between Pages
I have run into an issue...I have posted previously, but my scenario has changed. Here is the situation... If a user clicks on a link ('abc123' for example) I want to insert into my database some predefined information about 'abc123' - I have assigned a value that is echoed in future pages for 'abc123'. So, what I need is some mechanism to, when a user clicks 'abc123', have a pre-defined username and password be entered into the database. I need this so future pages can utilize the session values.
Ordering By ASC
I am having trouble ordering by ASC. I made a tagbox, and when it loads up it takes you to the bottom of the page, and it should show the newest comment first, but it doesn't. It shows the first 25 tags then stops... mysql_query("SELECT * FROM {table} ORDER BY id ASC LIMIT 25");
Ordering From DB
If I have a db for an auction site and I want to display the auctions closing soonest, how do I do this? I know how to code it, just the theory behind it?
Ordering Before Grouping
In my particular database table, I have many rows which its common element is the `username`, now the most unique and method I wish to order on, is `time` (timestamp). In my code my base query currently is: SELECT `username` FROM `download_counter` GROUP BY `username` ASC Which then as expected, on page rows are ordered by username in alphabetical order. What I wish to do is, on page view, rows are ordered by the `time` value. However heres my two problems: For starters it probably comes to no surprize that when using GROUP BY, the query remembers the first row it comes across and ignores the laters, so if there are three rows, oviously the first one it finds is the earliest of times, which is exact opposite of what I want. My other problem involves my attempt at a query: SELECT `username` FROM `download_counter` ORDER BY `time` DESC GROUP BY `username` this brings back: #1064 - You have an error in your SQL syntax ... near 'GROUP BY `username` I guess a ORDER cannot be before a GROUP. But then what do I do? Is there a way maybe to query all results, then after that preform a GROUP?
Columnar Ordering
lets say i got a table with 2 columns on my database. one column is a unique_id set to auto increment, and the other (we'll call "name") contains: andy anne bob carry cj paul pete saul i've figured out how to print that stuff in a while loop into two column in html like: PHP Code:
Ordering From A MySQL DB
I have a MySQL database that has 400 entries in it, What i want to do is extract these from the database. say I want to extract all the people whos name starts with the letter "C" ...Im not sure of the query for that?
Ordering Numbers.
Say I'm selecting a few numbers from a database... Example: 12, 80, 100. // MYSQL SELECT number FROM db.numbers ORDER BY number ASC; Results: 100, 12, 80. How can I get these numbers to display in the proper numerical order: 12, 80, 100?
Ordering By Date
$query = "SELECT eventid, name, DATE_FORMAT(date, '%d %b %y') AS date, time, type, extra FROM events WHERE type = 'Training' AND date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 21 DAY) ORDER BY 'date' desc"; This displays any events within the next 21 days, but not quite in the right order! The outputted result is: 25 Mar 07 24 Mar 07 08 Apr 07 07 Apr 07 06 Apr 07 As you can see the months are in the correct order but how can the days be reversed? eg: 24 Mar 07 25 Mar 07 06 Apr 07 07 Apr 07 08 Apr 07
Ordering Rows By Value
Is it possible to display rows in order of a value within the rows? I need to do this without saying 'order by' in the 'select from' statement. The reason is because i'm using values from my select from statement to work out totals. Once i've worked out the totals i'm displaying the rows as per the code below. This works fine but I want to display the row containing the smallest $TOTAL_REDUCED value first, with the next highest next, and so on. Code:
Ordering Lists
I have developed a script (with help) that tries to order events stored in my .txt file by date. The .txt file looks like this: 1st|Jan|Meeting at House| 15th|Feb|Meeting at your House etc The script orders the dates from lowest to highest but does not order dates before the 10th. Apparently 1st - 9th comes after 31st.. Code:
Ordering SQL Results
How do I order my sql results in descending order? This is my query: mysql_query("SELECT * FROM members order by uid limit 1 descending");
Ordering Users In Table
I've got this code which displays the users which display this in a table order by user: <table cellpadding="2" cellspacing="2" border="1" width="100%"> <tr> <td><b>Position</b></td> <td align="center"><b>User</b></td> <td align="center"><b>Correct Answers</b></td> <td align="center"><b>Percentage</b></td> </tr> <? $result=mysql_query("select count(*) FROM quiz_questions,quiz_category where quiz_questions.qzid=$qzid AND quiz_questions.catid=quiz_category.catid"); list($quest_count)=mysql_fetch_row($result); $result=mysql_query("select quiz_input.fuid,fname,surname,count(*) from quiz_input,quiz_answer,quiz_questions,users where quiz_questions.qzid=$qzid and quiz_input.qsid=quiz_answer.qsid and quiz_input.qsid=quiz_questions.qsid and quiz_input.qaid=quiz_answer.qaid and correct='yes' and users.fuid=quiz_input.fuid group by fuid order by 2 LIMIT 10"); $i=0; while (list($DBfuid,$DBfname,$DBsurname,$DBcount)=mysql_fetch_row($result)) { $i++; echo "<tr><td>$i</td><td align=center>$DBfname" ." ". "$DBsurname</td><td align=center>$DBcount</td>"; $percent=round(($DBcount*100)/($quest_count)); echo "<td align=center>$percent" . "%". "</td></tr>"; } ?> </table> What would be the best possible way to achieve 1==,1==,2,3,4==,4== etc?? Would be best idea to compare one row at a time??
Ordering A Joined Table
I'm currently working on my own forum and so far everything's working. I have made four tables, CATEGORY, FORUM, TOPIC, POST. I've completed the category part of my forum and I am almost done with the forum coding, but there's one question which I can't answer. I want to order my posts/topic on date,time (in that order), but I have no clue whatsoever on how to do this. I mean, when a new topic is made it's added to the TOPIC table (so no data added in the POST table) and so the topic's date is stored in the TOPIC table, but a reply is added to the POST table and it's date and time are stored in the POST table. How do I have to make my query in order for it to sort my posts and topics on date? (like on this forum for example).
Mysql Results - Ordering Them.
i need an mysql query to rank the results, like SELECT field FROM table and to order them greatest to least by the value of a different field.
Returned Emails
When sending email from a php script, is there a way to tell if the email was returned as undeliverable? My server uses MailEnable and when I send emails from php I never know if they got to their destination or were returned. I would think that if the email was returned, it should be put in the log files somewhere. But I couldnt find anything in my logs about returned mail. Any one know how I might do this?
Problem With Ordering By DATE In MySQL
I have a mysql DB table with a DATE column. I also have a page which queries the database depending on what selections are made in a form select box. However, I am having a problem with the SQL statement and keep getting an error. (Warning: Supplied argument is not a valid MySQL result resource in c:program files usphereapachesdocsspecialsarchivedisplay.php on line 10) The code is being ported over from a Java Servlet but I thought the SQL statement would be the same. PHP Code:
Ordering Mysql Request By Part Of A Key
I have a database of kennels. One page lists the kennels alphabetically by kennel name. I have a field for kennel name and an index with kennel name as the only field. Some of the kennels have the word "The" as the first word in the name and they do not want to be listed alphabetically by "The..." Is there a way that I can request that mysql ignore "The" in a kennel name when ordering it or must I create a new field for the ordering and remove the "The" from the kennel name for that field ?
Six-random No Generator, But Not In Good Ordering
how to put a randomly generate in to an array, so that I can sort them with sort function? result is: B1 38 + 41 + 34 + 30 + 27 + 22 B2 34 + 22 + 10 + 35 + 18 + 11 B3 34 + 2 + 7 + 34 + 37 + 1 B4 30 + 34 + 7 + 2 + 27 + 25 //$holdno = array ($rno); //sort ($holdno); //echo sort($holdno); //reset ($holdno); I follow from php.net, they are wrong. I need something like: $holdno(1)=no(random draw1) $holdno(2)=no(random draw2) $holdno[sixno] = $rno; echo $holdno[sixno]; I tried this but I can't sort them. .... ....etc its very difficult, when a nos is drawn, it is not put back to pool, and continue to draw a nos. leave question 2 for the time being. PHP Code:
Manually Change Ordering On Records
I have a mysql database full of pictures, and I need to have the abilty to short the results through an ORDER field in mysql that will give the ASC ordering I want. Problem is that there isn't any field ORDER so I must create it. Can you give me some suggestions hot to alter the ordering results? Its impossible to do it manually and write 1,2,3,4 ....500 with the order that I want in each picture. So there must be a way to see the id of the picture and swap it ( back or forward) through a new column...Should be float? Code:
Ordering By Date & Time Not Working
I have the following query which does select all the relevant information from the 'news' table but does not display them in descending order by date(&time) as requested. // Define the number of results per page $max_results = 4; // Figure out the limit for the query based // on the current page number. $from = (($page * $max_results) - $max_results); // Perform MySQL query on only the current page number's results $sql = mysql_query("SELECT title, description, picture, DATE_FORMAT(date, '%d %M %y %H:%i:%s') AS formatted_date FROM news ORDER BY formatted_date desc LIMIT $from, $max_results"); any ideas where it is going wrong?
Apache Returned Nothing With Php Script
The new problem I have now is this: I have configured everything that needs to be confired in the apache server after I installed the php. The server worked. Now, to test the entire configuration, I typed <? phpinfo() ?> into notepad and saved it in my apache root directory (htdocs) as phpinfo.php. Then on my browser I typed http://localhost/phpinfo.php and the server gave me error message that it couldn't be found. I am not sure what I am doing wrong. My Add line looks like this. # AddType allows you to tweak mime.types without actually editing it, or to # make certain files to be certain types. # AddType application/x-tar .tgz AddType image/x-icon .ico # I added these three lines AddType application/x-httpd-php .php .phtml AddType application/x-httpd-php-source .phps AddType application/x-httpd-php .php .phtml .html I don't know if php4ts.dll is causing the problem. I can't see it. I see php4ts.lib. I also can't see mscvrt.dll. However, the server is running except that it gives error when I run my test script. Please help.
Php Cannot Accept Negative Value Returned From Cgi (c)
Using system()in php to call a cgi (in C), which in turn will return a status value. Whenever a negative value (eg -1) is returned, the php will show it as another value (255). The sequence is like, -1 = 255, -2 = 254 ...If it is a positive value then it's working fine. Any idea on how to solve this and why is php behaving this way?
|