Displaying Records, But Not Identical Ones.
I have a table with several rows. One column is "State", where, of course, a state is listed. I'd like to query the database and list all states in the rows, but I don't want multiple instances of the same state? How can I prevent it from showing:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Displaying Priorty Records And Normal Records In The One Dataset.
I have a page which displays the records from the database and uses paging to display the records in groupes of 10 per page. I now want to be able to show results depending on the database field (display) in the database (can be set to either "full" or "limited"). If the record and the field display is equal to "full" i want to then display this record at the top of the record set and display all the fields. If the record is equal to "limited" i want to display different results and they must show after all the records which are equal to "full". I can't output two different recordsets as i use paging and only want to show 10 records per page. Code:
Displaying Some Records Once Only
I'm building a database via mysql/php which brings back records of events. My problem is that I only want to show the Venue for the event once and then list the events for that venue. ie Code:
Displaying # Of Records In A Table
Can anyone throw me a link to some prefab code, or a tutorial on how I can get a page to display the number of records that meet a certain criteria. example: I have a page that stores information on audio FX. I'd like to include a feature that would let the users know how many items are in a particular section. Player (10) Items (5) Weapons (0) etc. All help appreciated,
Displaying The Next/previous Records
I'm trying to stick some PHP code onto next and previous buttons to display the next / previous 10 records, then using; $result = mysql_query ("SELECT * FROM property_1 WHERE area='$whatarea' LIMIT $limitit,10"); but if the above code and the buttons themselves are on the same page how do you stick PHP code on the buttons to do the limitit+10 and limitit-10 and also to call the page?
Displaying Records After 2 Days
I trying to display only records that are 2 days old so the owner of the site can preview new records before they are available to others, this is what I've got so far... $sqlquery = "SELECT headline, news, date_format(date,'%M %D %Y') as time FROM $table WHERE date < NOW() ORDER BY date DESC"; is there a way to extend it by 1 or 2 days, i've tried the TO_DAY function but couldn't get it to work either.
Displaying Records After 2 Days
I trying to display only records that are 2 days old so the owner of the site can preview new records before they are available to others, this is what I've got so far... $sqlquery = "SELECT headline, news, date_format(date,'%M %D %Y') as time FROM $table WHERE date < NOW() ORDER BY date DESC"; is there a way to extend it by 1 or 2 days, i've tried the TO_DAY function but couldn't get it to work either.
Displaying Records In A Cyclic Fashion
I use the following code in-order to display records based on the week day.My intention behing writing this one was to display 90 records in a cyclic fashion.(i.e, first 90 on monday, next 90 on tue and so on...)
Problem Getting Identical Functions To Work The Same
I have created two functions in a script that are suppose to produce the same results, but the top one doesn't show the page title (the $page_title variable) for some reason. And for the life of me, I can't figure out what I missed. This is especially weird since I just copied the view_page function into the edit_page function w/a few minor changes. Anyway, here's the code: PHP Code:
Two Identical Class Methods, One Produces Segfault
Consider these two classes. Class Accepter in placement_classes.inc.php works as a form validation object, and it works like a charm: PHP: // placement_classes.inc.php - THIS ONE WORKS! class Accepter { function Accepter() { $this->dbAP =& new DBActionPerformer(); $this->dbAP->connect(); $this->validate(); $this->dbAP->disconnect(); $this->dbAP = null; } /** * Perform validation * * @access private */ function &validate() { // STATIC VOID METHOD foreach ($_POST as $key => $val) if (!isset(${$key})) ${$key} = $val; $varErrArray = array(); array_push($varErrArray, 'placement_name|setMandatory~setMinLength~setMaxLe ngth~setPattern|You must enter a location name~Your location name must be 2 or more characters~Your location name must be 50 or fewer characters in length~^(?!.*<[^>]+> )|Your location name configuration is unrecognizable by our system, please re-enter with legitimate characters|'); array_push($varErrArray, 'unique_key|setMandatory|You must have a unique key prior to posting||'); /*--------------------------------------------------------------------------------------------------------------------- createErrorMsgCollection function from formvalidation.inc standalone function returns an array of ErrorMsgCollection objects -----------------------------------------------------------------------------------------------------------------------*/ $this->errorMsgObjArray =& createErrorMsgCollection($varErrArray); // CREATE FORM OBJECT PASSING ARRAY OF OBJECTS AS PARAMETER $this->formValidator =& new FormValidator('', $this->errorMsgObjArray); $this->isValid = $this->formValidator->isValid(); $this->setErrorArray($this->formValidator->getErrorArray()); $this->formValidator = null; $this->errorMsgObjArray = null; /* if (strcmp(strtolower($action), 'add') == 0 || (strcmp(strtolower($action), 'edit') == 0 && $placement_name !== $origPlacementName)) $this->checkDuplicatePlacement($placement_name); // CHECK FOR DUPLICATE PLACEMENT */ } } This is the class Accepter from contacts_classes.inc.php and while it is now identical in code structure to the Accepter classe in placement_classes.inc.php, whenever this class method is invoked, all processes stop (no errors), arrays are unfinished, objects are unfinished, HTTP never produces, Apache goes down, literally everything crashes! PHP: // contacts_classes.inc.php - THIS ONE PRODUCES A POSSIBLE SEG FAULT! class Accepter { function Accepter() { // NEW 8/17/2004: SURROUND validate() METHOD WITH INSTANTIATION OF $this->dbAP OBJECT PROPERTY $this->dbAP =& new DBActionPerformer(); $this->dbAP->connect(); $this->validate(); $this->dbAP->disconnect(); $this->dbAP = null; } /** * Main method. Will perform all other validation methods and set isValid boolean property * * @access public */ function &validate() { // STATIC VOID METHOD foreach ($_POST as $key => $val) if (!isset(${$key})) ${$key} = $val; $varErrArray = array(); array_push($varErrArray, 'placement_name|setMandatory~setMinLength~setMaxLe ngth~setPattern|You must enter a location name~Your location name must be 2 or more characters~Your location name must be 50 or fewer characters in length~^(?!.*<[^>]+> )|Your location name configuration is unrecognizable by our system, please re-enter with legitimate characters|'); array_push($varErrArray, 'unique_key|setMandatory|You must have a unique key prior to posting||'); /*--------------------------------------------------------------------------------------------------------------------- createErrorMsgCollection function from formvalidation.inc standalone function returns an array of ErrorMsgCollection objects -----------------------------------------------------------------------------------------------------------------------*/ $this->errorMsgObjArray =& createErrorMsgCollection($varErrArray); // CREATE FORM OBJECT PASSING ARRAY OF OBJECTS AS PARAMETER $this->formValidator =& new FormValidator('', $this->errorMsgObjArray); $this->isValid = $this->formValidator->isValid(); $this->setErrorArray($this->formValidator->getErrorArray()); $this->formValidator = null; $this->errorMsgObjArray = null; /* if (strcmp(strtolower($action), 'delete_select') == 0 && @sizeof($delete_selected) == 0) { $this->isValid = false; $this->setErrorArray(array('action' => 'You must select at least one contact for deletion')); } */ } } I've been trying to debug this for days now to no avail. I can verify every object property is present and accounted for (and identical in every way), but if you evoke one it's fine, the other and a segfault!
$_POST Identical Text Fields Into Database
I have a list which is pulled and displayed from my MS Access database. Next to each row, is a text field which appears evertime a new row is displayed and that is called 'code'. I want any text field filled in by the user to be sent into my database, into one field all separated by commas. I have made an attempt at this in the second example script but it needs tweaking. I have here my script which pulls the list from my database: Code:
Select Count Query, 2 Tables With Identical Structures
I have 2 Tables that have the exact same structures, One is for Inventory, the other is for Relief Inventory (ie. when an item is sold it is moved to relief). What i want to be able to do is to run a query that will count the number of items tested by one person and display that sorted and grouped by the date cleared. I can get this to work when working with just the Inventory table, but the problem is that as items are moved out to relief the counts will change. $query = "SELECT COUNT( * ) AS `Count` , `Date Cleared` , `Tested By` FROM `Inventory` WHERE `Tested By` = ".'"'.$tester.'"'." GROUP BY `Date Cleared` ORDER BY `Date Cleared` DESC "; My question is, how do i run a similar query that will search both tables and combine the results. I have tried adding the other database to the FROM statement, and have been tring to figure out if i can use a join statement but that hasn't yielded any favorable results.
DNS Records
Hey everyone, I'm trying to get a DNS record of an IP using PHP's checkdnsrr() and getmxrr(). I used echo checkdnsrr($REMOTE_ADDR); and echo getmxrr($REMOTE_ADDR); but I receive an error that the PHP build does not support it, but I am using PHP 4.0.5 and in the manual, it shows that PHP 3 and 4 supports the two commands. Any help?
Next N Records
how do I create a "next n records" interface? I want to initially output a specific number of rows, and have a next/previous scenario where the user can click on either and scroll forward or back through the records. I'm currently outputting all rows through mysql_fetch_array: Code:
HOW TO GET HOW MANY RECORDS YOU HAVE IN DB
I finally discover the way how to get what I need. Let's look to my code: ----------------------- CODE ------------------------> $res = @mysql_query("SELECT COUNT(*) AS ToT FROM table_name"); $dato = mysql_fetch_array($res); echo($dato[ToT]); ----------------------- CODE ------------------------> With this code you will get how much records do you have in DB. PS: Whan you think that everything is over and that you are at bottom of trying push harder to see what is under.
Last 5 Records
is there an easy way to grab the last 5 distinct records from an unindexed database? (php/mysql)
Number Of Records
I want to find out how many records, but I am using LIMIT in mySQL so if set the limit to 20 and I have 56 records then it will display 20 instead of 56. I have been using: mysql_num_rows What should I be using?
What To Do If There Are No Records In The Database
I am pulling data from the database and displaying it using the code below: $db = mysql_connect("localhost", "root"); mysql_select_db("pyramid",$db); $result = mysql_query("SELECT * FROM table where area='Wales'",$db); while ($myrow = mysql_fetch_row($result)) { echo "blah blah"; } ?> What do I do if there are no records? At the moment it just doesn't display anything. How do I get it to display a message saying there are no records?
Updating Records
I am know to PHP i've been tring to do this **** for days now could someone PLEASE help me. Ok Im tring make an admin page where user can update multiple records at same time using checkboxes.Im using email as primary key. Here is the code **form page** <form action="update.php" method="post"> <input type="submit" name="submit" value="Select First 10 Names"> </form> **update.php** <?php if ($submit =="Select First 10 Names") { ?> <form method="post" action="<?php echo $PHP_SELF; ?>"> <hr size=3> <?php $query = mysql_query("select * from Names order by Last_Name limit 10"); while($row = mysql_fetch_array($query)) { $first_name= $row["First_Name"]; $middle_name = $row["Middle_Name"]; $last_name = $row["Last_Name"]; $email = $row["Email"]; $photo=$row["Photo"]; ?> <table width="100%" border="0" > <tr> <td align=right width=50%> <?php echo "First Name: <input type=text name="first_name" size="30" maxlength="40"value="$first_name" ><br> "; echo "Middle Name: <input type=text name="middle_name" size="30" maxlength="40" value="$middle_name"><br> "; echo "Last Name: <input type=text name="last_name" size="30" maxlength="40" value="$last_name"><br><br> "; echo "Email: <input type=text name="email" size="30" maxlength="40" value="$email" readonly><br><br> "; echo "Photo: <input type=text name="photo" size="30" maxlength="70" value="$photo"><br><br> "; echo "<input type="checkbox" name="email[]" value="$email"><b>Update?</b> "; ?> </td> <td align=right width=50%> <?php echo "$photo"; ?> </td> </tr> </table> <hr size=3><br> <?php } ?> <input type=submit name=submit value="Update Enteries"> <input type=reset> </form> <?php } if ($submit=="Update Enteries") { if (is_array($email)) { while (list($key,$value) = each($email)) { $query= mysql_query ("update Names set First_Name = '$first_name' Middle_Name= '$middle_name' Last_Name='$last_name' where Email='$value'"); } } } ?>
Need Help With Deleting Records
I'm trying to add a link on the display of a record to delete that record. The main part of the record is stored in pw_event, then there are several rating fields for that record stored in pw_rate, and there is also several records for the first record stored in pw_whois. I need to have a link that will deleted everything for that record in all three tables. Here is my display script: PHP Code:
Retrieving Records With Between
I am trying to convert my asp website to php. So far so good, but I am having a problem with my SQL Statement that needs to us the Between. Here is what I am using: $sql = "Select * From tblTrack Where DateEntered Between $start and $end"; the vars start and end come from the same form. I don't have a problem when I hard code the dates, but when I use the variables, it won't retrieve anything.
Delete Records
I`m just trying to figure out the best method to delete my records and wondered if it was possible to do a DELETE statement to remove any records that don`t match. Here is my code so far: $Query="select blah its huge:-)"; $RESULT=mysql_query($Query); $my_rows=mysql_num_rows($RESULT); for ($a=0; $a<$my_rows; $a++){ mysql_data_seek($RESULT, $a); $Array = mysql_fetch_array($RESULT); printf("%s<BR>", $Array['Email']);} My Query returns Matched Records, what I would like to achieve is deletion of the records that didn`t match, would it be possible to do that under the printf statement. So delete all the records in the table that don`t match up to $Array['Email']??
PHP/MySQL Records Per Row
Is there any way to have the records pulled from a mysql database display like this in a table: record1 | record2 record3 | record4 etc: I've been thinking about this for about three months and have yet to come to a good solution.
Inserting Records
I'm trying to insert as many as records as possible but less than 100 into a table. First, i get the count inorder how many to add and then depending on the count, i get so many blank form fields to enter. Now, I noticed something really strange. 1.Only the last entered record is inserted into the table. 2.For example, when I type a name, Let us assume "WORLD", only w is inserted into the table and the rest is not.It is the same with all the form fields.whether, i'm trying to enter text or a number,only the first character is inserted.This sounds weird. Could somebody pls tell me why is this peculiar behaviour Here is the code:
Insert Records
When I try to insert a records in the database "socios", it doesn't inserted at all. Code:
Different Hyperlinks To Different Records
I'm displaying few records from a mysql table - pretty straight forward one. For each record i display on the form, i want to add a link to it.so, each link would display a different page(an html). PHP Code:
Deleting Records
I've been trying to delete records since a week and i'm not able to do it. Before with this script, i was doing so many things at a time and i was confused.But, now, i just displaying the records from a table N trying to delete them.Would somebody pls guide me. I just wanna set the delete flag(i.e, i want to set the RBS_DELETE column to Y or something) when i check a check box to delete it. I've some 5 records displaying on my form and i want to check 3 of them and when i check them and hit submit, i want the RBS_DELETE column to have some value. PHP Code:
How Do You Sort Records?
I have a db table "person" that I can sort by title, first_name, last_name, or city with no problems at all because "title", "first_name", "last_name", and "city" are columns in the table. The requirement is to ALSO sort by department NAME. Problem is, I can't do that in the "person" table because the column is "department_id" which is a foreign key constraint to the department table. How do I sort the person records by department_name based on this? I am using PHP 4.3.2 and MySQL 4.0.10 Now, second problem and even more of a problem: The requirement is to ALSO sort by state NAME and country NAME. The fields "state" and "country" in the "person" table contain only an abbreviation of state and country; the corresponding full name of each state and country are found in respective XML files in /xml/state.xml and /xml/country.xml
Compare Records
is it possible to write a query to compare records in 2 tables, like if the number of records in the 2 tables are equal the query should return 1 if not equal the query should return 0. this can also be done in php like, get the number of records from one table and get number of records in another table, compare it and do the operation. but i wanted to know if its possible to do the compare records using the query itself. for example, if one table has 5 records, this should be compared with another table, if this table has 5 records, then the result of the query should be 1 else 0. if i use joints, it will return all the 5 records. so not sure how to make this in a query. anyone have any idea ?
Display Records
I want it to display all the records meeting the criteria specified in the script, but it only shows one records and should show about ten. any thoughts or pointers to get it to display more than one record. Code:
DESC Records
i want to make all the records be shown in a decending order, i've tried using: $sql = 'SELECT * FROM `repair` ORDER BY `repair` . `id` DESC';
Records Won't Delete
mysql_query("DELETE FROM guestbook WHERE id = '$recnum'"); It works fine on my local server but it doesn't delete records on the remote server. any ideas?
Count Records
How can I count how many records are in a table that match a news_id? I have this at the moment, but it doesn't seem to work. Code:
Retreiving All Records From Sql Db
IM trying to get cost values out of the db with a specific ID which is assigned to an item ID but i only get the last record in the database. $lala = mysql_query("SELECT `cost` FROM `table` WHERE `ID` = '1'"); while ($la = mysql_fetch_row($lala)){ $start = 0; $overall = $start+=$la[0]; } echo("$overall"); ...
Return Last 3 Records
I want to return the last 3 records added to my table called towns. sql = "select * from towns limit 3" This only returns the first three rows, I want the last 3. My primary key field is townID.
Getting ALL My Records To Display
In this code, almost everything is working perfectly, but for my second query, I have six records that I want displayed in their own table like I have. I know that a loop would probably work, but I am just really not sure how to go about this. I would like the code to display a table of each of the records. Code:
Deleteing From Records
Ive created a mailing list using php3, and i'm trying to make an unsubscribe, so far i have it set up to mail me with the email of the person(s) wishing to unsubscribe, and i have to do it manually. Code:
DELETE RECORDS
iv got the database adding new records, and now I want it to display all of the records that are there buy name and id number, then i want u to be able to type in the id number of the customer u wish to delete and it shoudl delete it, sounds good buts its not actually deleting the record. it says it does, but its not doing it. Code:
Printing Records With A Twist
I have a problem that I have been working on for weeks and I cannot get it to work. I thought someone might have done this or could be of assistance. I have name and football positions in a database. I want to retrieve those names print them on the screen. The twist is, I have a certain number of positions (3 QB, 4 RB, 6 WR, etc.). If I have only 1 QB I want to leave 2 blank lines before I print the RB position and if I have 2 RB, I want to leave 2 blank lines before I print the WR Position, etc. Name, QB Blank Line Blank Line Name, RB Name, RB Blank Line Blank Line Name, WR If anyone has a way to loop through the recordset and do these, I would really appreciate it. It is probably pretty easy but I am new at PHP and I have just not had any luck.
Updating Multiple Records
I'll try and explain my problem!! Database table : Book Table : BookWords Fields : BookWordID Word Description I want to show : The word is $word add your description $description using th code below: [PHP]$db = mysql_connect("localhost", "root",""); mysql_select_db("Books",$db); $result=mysql_query("select * from Bookwords",$db); while ($rec=mysql_fetch_array($result)){ $wordid = $rec["BookWordid"]; $description = $rec["description"]; echo "$wordid: <input type=text name=quantity[$description]><br> "; } This is ok so far. Now i want the user to be able to add the description from the form and have the db automatically updated. I've tried the different methods I've found on this forum and I cant get anything to work!!!
Finding Records Within The Last 48 Hours?
I can't seem to find anything on querying to find records dated within the last 48 hours. Not just two days/calendar dates, but 48 actual hours. I'm hoping to do something like: SELECT record FROM table WHERE postdate > (NOW - 48hrs) does that make sense?
Limited Records Showing
When I read from mysql database it shows all the records. How can i make them show by 5 each page?
Counting Records In A Table
Ok, I am trying to count the number of records in one of my tables. Seems simple. BUT! its not working. It returns a 2 no matter how many records are in there. Heres the code. <?php $sql = "SELECT count(*) from cam"; $result = mysql_query($sql); ?> I would think this would work. I have also tried mysql_num_rows, and max(), and sum()... a little help would be appreciated, and why is it returning a 2?
|