Easy Way To Make "pages" From A Database List
If I list all the rows in a database and "LIMIT 20", how do I make it so I can go to, the next 20 rows? Say if I have 50 rows, and only want to show 20 per a page?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Pagnation - Limit Number Of Pages Between "Previous" & "Next" Hyperlinks
Was hoping for some advice with a part of page navigation.... It works at the moment so there is a "Previous" & "Next" Hyperlink underneath the records. In between the Previous & Next links are the number of pages that there is of these records. e.g: Previous 1234 Next This is fine if there are only a few pages of records, but when there are hundreds of pages the numbers are listed and they take up half the web page with them. How can i make it so only limited 10 numbers of pages say appear between the "Previous" & "Next" Hyperlink and as you progress through the pages they are as do the next 10 numbers of pages? Code:
Duplicate Entries - From "There Must Be An Easy Solution!!??? (by Mcsimon)"
Duplicate entries are not too harmful in the sites I have made. Usually the output is sorted (order by ...) and duplicate entries become apparent. However, I was thinking of warning users about 'duplicate' entries if they happen together. This would high-light the "BACK BUTTON - RE-ENTER" scenario. - store the mysql last_insert_id() in the user's table. - when an insert is processed, compare the new input fields to the last_insert_id row. Other people may be working on "Life and Death" situations. Could their concern lead to SELECTing using one or two "sort of unique" fields and, if any hits, SELECTing using all input fields? If a complete match occurs, they could do something.
Loading "unsupported" Extensions Or Easy Pdf Creation
Situation: o Site Hosting provided by 3rd party. o phpinfo() shows support for the PDF extension is not compiled into php. o Current PHP version is 4.2. Current apache is 1.3.X (I think 26). o Application requirements specify reports must be generated in PDF to ensure printed output meets certain specs. o All pertinent data resides in database. Data changes infrequently (~ once per two months). o Not all users see the same data. Since there appears to be no support for PDF's on the server, it probably is not a simple matter of doing a dl() call to load the module, or is it? Might I simply place a compiled pdflib.so in a directory, make that part of the path and dl() load it? If that is truly not feasible, in what other ways might a PDF file be created?
Easy Question: What Does "@" Mean?
Easy newbie question. I've searched all the PHP documentation I can find, but can't find an answer. What does the "@" mean, in this context: @mysql_select_db( "scripts"); (Have you ever tried Googling for the @ symbol? Doesn't work.
Make PHP Find Windows Directory. I Need The Php Equivelant To "%WINDIR%"
I've written a small gui for PHP.ini but I don't know how to make PHP find the windows directory itself. You'll probably understand better when you see the code below. I'm currently using the line: Code: $PHP = new Config ("c:windowsphp.ini",";"); And that works fine but only if PHP.ini is in c:windows. I tried Code: $PHP = new Config ("%WINDIR%php.ini",";"); but that dowsn't work, I need something that finds windows dir. itself, Any ideas? You can see an example of it at http://213.152.46.100/gui/php-config.php (Uses a temp PHP.ini so you can't mess nothing up, feel free to play about with it)
How To Make A "sophisticated" Insert Record Form ?
I have a DB with many inter-related tables (MySQL) My main table called "content" has almost only foreign keys (integers) some have a 3 level relation (ex: content->city->region->country) I would like admins to be able to insert new records including all the "content" fields (in 1 page form) But how can I make an insert form that would display the related tables as list menus instead of a textfield with a number? (ex: select country from a drop down menu instead of typing the foerign key number) Main content Table: IDRef = primary key IDLocation = foreign key --related to tables city->region->country IDDescription = foreign key --related to table Description (=several big and small text fields) IDImages = foreign key --related to image (=image and thumbs path, alt text, etc..) Do you know any tutorial, help or solution ?
How Do I Do Something Like $color = ("red", "yellow", "blue")[$colornum]?
How do I take an index of a literal array, instead of a variable? That is, say I want to get the short name of a month. Can I do something like: $monthname = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")[$month]; or do I always have to do: $blah = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $monthname = $blah[$month]; It seems a shame to have to create a variable specifically for this one-shot purpose.
Why Doesn't "make Install" Generate Libphp5.so?
I am trying to build a LAMP stack for the first time, and have encountered the following problem: CentOS 4.3 mysql 4.1.20 apache 2.2.3 php 5.1.6 I've compiled and installed apache as follows: ==apache=== ./configure --prefix=/usr/local/apache2 --enable-module=so make make install ===== That appears to work perfectly. The problem comes when I try and compile and install PHP. ==php== ./configure --prefix=/usr/local/php --with-mysqli=/usr/bin/mysql_config --with-apx2=/usr/local/apache2/bin/apxs make make install ==== According to my reading, a "libphp5.so" is supposed to be generated during this process, but there is no such file on the system after the fact, which is certainly a problem. Can anybody perhaps provide guidance as to why this file would NOT be generated?
Make A "semi-unique" Hit Counter
Let me explain. I put something like addToCounter(); in my INDEX page. Problem is, counter increments each time the same visitor opens/refreshes the index page. What aproach should I use so that if a visitor opens the index page, browses the site, and goes back to index page, it doesn't count anymore. But when he closes browser/goes to another site, then goes back to my site (index page), it counts again. I've tried sessions in the index page if (!isset($_SESSION["loggedIn"])... { $_SESSION["loggedIn"] = true; addToCounter(); } but doesn't work (or am i doing it wrong?).
Make "blabla" Into Keywords As In "php.net/blabla"
I know this must be documented, but I cant seem to find it. How would you transform the URL into values? Like how php.net does; www.php.net/date does a search for "date" in their database... I have built a simple search function on my site, and I would like to do the same.. anyone who knows how? Or who has seen an article in the subject? Or has any other tips?
PHP Pages Getting 404 Error, "Page Cannot Be Displayed"...
I tried putting this into the PHP Installation forum but don't get any answers or suggestions there so I'm going to try it here and hope it doesn't get moved. I'm on a Windows 2003/PHP 5.22 setup. I'm TRYING to upgrade from PHP 5.02 which did work on my server and quite well. I followed the upgrading and installation instructions layed out on the PHP.net set -- I still can't get it to work. The install dumped all the PHP related files under "c:program filesphp". I've ensured that path is in my windows PATH statement for my env vars. I've also verified that "c:program filesphpphp-cgi.exe" is in my Web Service Extensions listing in IIS and the status is set to "Allowed". From the command-line, I can execute my "test.php" file that has the phpinfo(); info function in it and it works fine. It's only when I try to use my web browser to access the php file that I get the 404 error, "page cannot be displayed". I know that IIS in general is working ok because I can point it to the default http://servername/iisstart.htm and it resolves to that page just fine. It's only when I change it to http://servername/test.php (which has my phpinfo()) function in it when I get the 404 error. My web server just doesn't seem to be interpretting PHP files anymore and I can't figure out why.
Cannot "make Install" With 4.3.3RC4 On HP-UX 11.00
I'm having problems getting PHP 4.3.3RC4 successfully to install on my HP-UX 11.00 server. After a (successfull?) compile, "make install" errors out with this error message: ################################################## ################################################## ######### Installing PHP CLI binary: /opt/php/bin/ Installing PHP CLI man page: /opt/php/man/man1/ Installing PHP SAPI module: apache2handler /opt/apache2/build/instdso.sh SH_LIBTOOL='/opt/apache2/build/libtool' libphp4.la /opt/apache2/modules /opt/apache2/build/libtool --mode=install cp libphp4.la /opt/apache2/modules/ cp .libs/libphp4.lai /opt/apache2/modules/libphp4.la cp .libs/libphp4.a /opt/apache2/modules/libphp4.a ranlib /opt/apache2/modules/libphp4.a chmod 644 /opt/apache2/modules/libphp4.a libtool: install: warning: remember to run `libtool --finish /root/admin/src/php-4.3.3RC4/libs' Warning! dlname not found in /opt/apache2/modules/libphp4.la. Assuming installing a .so rather than a libtool archive. chmod 755 /opt/apache2/modules/libphp4.so chmod: can't access /opt/apache2/modules/libphp4.so apxs:Error: Command failed with rc=65536 .. *** Error exit code 1 Stop. ################################################## ################################################## ######### You can see the whole "make" log at http://email-server.info/~askwar/stuff/PHP_MakeLog.txt /opt/apache2 contains the Apache 2.0.47 installation. root_s08nfs:/root/admin/depots/ > ls -la /opt/apache2/modules/ total 7074 drwxr-xr-x 2 root sys 96 Aug 21 12:32 . drwxr-xr-x 15 root sys 1024 Aug 21 07:21 .. -rw-rw-r-- 1 vz6tml pcei 8131 Aug 21 07:21 httpd.exp -rw-r--r-- 1 root sys 3609588 Aug 21 12:32 libphp4.a -rw-rw-r-- 1 root sys 2097 Aug 21 12:32 libphp4.la I'm wondering - why does "make install" (or rather apxs) look for libphp4.so? In HP-UX, shared library files have the extension .sl, not .so (that's Linux). And also - why was no libphp4.sl compiled at all? To configure PHP, I used the following configure "caller": ################################################## ################################################## #########
Make SQL Query "Safe"
Does anyone know of a good function that makes an sql query "safe" to put inside the mysq_query() function? I tried the mysql_real_escape_string() function, but that saves a backslash in front of every quote I have in the database. Which is annoying.
Check Variable Against A List (cf. Mysql "in")
Is there a PHP way to see if a variable is a member of a list? E.g. I want to know if $a is in the following list: "apple", "orange", lemon". I know I could loop through an array of values, or I could do a series of "or"s in an IF statement, but I'm looking for something easier and more elegant. I know in mysql, I could do a query like 'select * from table where id in ("value1", "value2", "value3")'..
Maintaing List Of "online" Users
I've seen a few posts asking for a way to keep a list of all "online" users. For example, when the user logs in, his/her record in the database is updated to show that the user is currently logged in. There can also be a "logout" script, which sets the user's status in the database to "logged off" when it is run. The problem is, however, that many users simply close the browser window, in which case the logout scripts does not run at all. So far, there only good solutions for this problem involved checking user's activity in certain time increments (like 5 or 10 minutes) and if there is none, assume that the user has logged out. However, this would not work for me, because I have to allow for arbitrary long periods of inactivity (while still browsing my website) before logging users out automatically (not just 5-10 minutes); but log users out immediately when they leave the website. While reading the user notes in PHP manual, I've come accross a possible way of solving this problem (this script can be included in an invisible frame on any website): PHP Code:
Preventing Visitors Ability To "re-visit" A Page Via The "back Button"..
I have a rather complex registration/member sign up form.. which gets a little confused, when a visitor "backs" completely out of the form, then for whatever reason returns to the form. The form contains 'cancel' buttons, which naturally cancel the reg process and redirects them to the document just before they started. JS provides us with the "location.replace()" method, but I can't seem to find a way to coordinate the use of location.replace() with the posting of the form values. In short, I want to "replace" the first step of the form with the "second step". I think what's making this tricky, is that each step of the form are located within the "same" page (register.php). The document works like so: The first step is the "Member Agreement" when they click "agree" (submit) the system creates a new row in the temporary register table of the db. It then issues a registration cookie, which carries the row id, and session value. in addition (for those cookie impared users) we carry the row id and session value in hidden elements. So far, as long as the user continues through the process all is fine, but if they (for whatever reason) back all the way out, and click 'agree' again, the process fails. I guess I have to find a way to force a reload of the 1st step "if they've gone back" OR "replace()" the first step with the second, so as to prevent the user from going "back" to the 1st step of the register page.
[regex] Stripping Out "name" And "value" Values Out Of Tags, Aaargh
Searched through the site, but couldn't find the right regex syntax I was looking for. the thing i want is, to extract with preg_match_all the given values in a tag... ex. $str = '<input type="text" name="name" value="value">' $pattern = some magic stuff I need to know preg_match_all($pattern, $str, $result); And in result I want to have the values text, name and value AND it's important that the order doesn't matter so structure of tags can be <input type =name= value=> or <input name= class= value= type=> etc, etc...
'Parse Error' Problem In "isset" And "empty"
I've been having some problems with a parse error that I can't figure out (PHP 4.3.11 on Solaris9). Sample code: <?php // getting strange parse errors on this class A { var $value; function A() { $this->value = 1; } function getValue() { return $this->value; } } $a = new A(); if (!empty($a->getValue())) { echo "success"; } else { echo "failure"; } ?> The result of this is: Parse error: parse error, unexpected '(', expecting ')' in /foo/public_html/parse_errors.php on line 15 I also get the same effect with "isset", however, testing with "is_null" or "is_int" produces the correct ("success"/"failure") result. Any ideas?
PHP Install Core Dump "make Install" PEAR On Solaris 9
php has been configured with the following two configure lines and core's during "make install" on the PEAR section. Is there something simple i'm missing? Any help would be appreciated. Environment: Solaris 9 php 5.2.1 GNU Make 3.81 gcc 4.1.1 ../configure --prefix=/opt/foo/php5 --enable-force-cgi-redirect -- enable-discard-path --enable-fastcgi --with-curl=/opt/foo --enable- sockets --with-zlib=/opt/foo --with-libxml-dir=/opt/foo --with- openssl=/opt/foo --with-nsapi=/opt/foo/sunone/current --enable-ftp -- with-ldap=/opt/foo/openldap --with-snmp=/opt/foo/net-snmp --enable- soap --with-xsl=/opt/foo --enable-libgcc --with-mysql=/opt/foo/mysql -- with-pear .....
Getting Rid Of "Index Of" Pages.
I run a sever in my home network and I'm planning to go on-line. But I've noticed that when you type in a file name in the address bar it will come up with a page that shows all the files in on my server. This is a major security risk and I'd like to know how to stop this. I'm using Apache 2 to host my server.
Looking For A Database-driven Email "contact Manager" Application
I'm going to be collecting lots (a few thousand) email addys. Each of these people will be interested in recieving mail on one or more topics, with an open ended and growing number of topics. Mailman with a BD application behing it might be ideal as it would let users add and delete themselves and each topic would have it's own email list name identity.
Problem With ""s Entering Stuff Into A MySQL Database
I have a database which is going to be used partly to store articles, which will basically be free-flowing text. So what if someone puts a single comma ' in? Because I am using the PHP: $query = "INSERT INTO quasimodo VALUES ($iNum,'$area','$sec1','$sec2','$sec3','$name','$phone','$email','$body')"; So surely when someone types the words it's or something like that with an apostrophe in the middle, it'll screw everything up? The stuff will be entered through a form. Please, how can I get around this problem? A similar problem would arise if i used "$body" instead of '$body' because someone might put a word in "inverted commas".
How Do I Use "foreach" Construct With Database Extraction
Below are excerpts from two PHP scripts that I am working on. What I am wanting to do is determine if the $UserName variable exists in the database tables "California" and "NewYork". If the $UserName variable is present on the first iteration the script will output "UserName is in this table!" and so forth for each iteration. PHP Code:
Deleting From Database, "SQL Sytax Error"
I searched the forums and I couldn't come up with anything, so I'm sorry if this has been solved before. But my problem is that when I want to delete a comment from the database, it just says, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1". At line one I have a Session_start...and I doubt that would interfere with deleting. Here's my query: $com = $_GET['del']; if ($com != NULL && is_numeric($com)) { if ($ip == $okip) { mysql_query("DELETE FROM `comments` WHERE `id` = '".$com."' LIMIT 1 "); echo "Comment has been deleted.<META HTTP-EQUIV="REFRESH" CONTENT="2; URL=show.php"> "; } else { echo "You do not have permission to delete comments."; } }
Echo "<!--#include File="top.html" -->";
I have a search script which returns a page of results, however I'd like the returned page to be in the same format as the rest of my site. To do this I've tried adding the HTML for my site to my PHP page with echo" " commands. This works for the plain HTML, but my regular pages also use SSI to do other stuff (some of them even execute other PHP scripts to generate tables of data etc). I've tried echo "<!--#include file="top.html" -->"; but it doesn't work as I get a parse error. My question is, how do I go about doing this properly? Is this possible at all? And if not have you guys got any suggestions to get around this?
Any File Size Limit In <PARAM Name="***" Value="***"> ?
I embed an applet in my php script which has a parameter providing an input file for the jar. Does this file has size limit? The code is as follows: <APPLET ARCHIVE="myapplet.jar" WIDTH=372 HEIGHT=360 VSPACE=0 HSPACE=0 ALIGN=middle> <?php echo "<PARAM NAME="data" VALUE="myfile.">";?> when "myfile" is beyond 15M, my applet cannot load sucessfully, but while this file is limited like 5M or 7M, it works well. Does anybody know is the reason caused by php script limit, applet mechanism, or by different browser?
How To Do PHP "require()" Or TCL "source" In Bash Script
I can't figure out how to explain this any better than this. In PHP we have a command "require()" that obtains a file and logically places it into another file. I cannot figure out how to do this in bash script as the requirement is necessary for a migration script to obtain the code from a .cfg file and then be able for the "parent" script to run the code it "imported" from the .cfg file, much like PHP's require() or TCL's "source". This is what I have so far and it fails: if [ -f ivc.cfg ]; then cat ivc.cfg fi Anyone really know bash script well please help, it's a barrier for me not to be able to get just this one piece working.
Error In Page When Checking Http_get_vars("myvar") And "myvar" Was Not Passed In URL String
PHP, coming from ASP coding if (HTTP_GET_VARS['b']==1){ print "Yes"; }else{ print "No"; } when "b" is not passed via (http://www.mydomain.com?b=1 an error occurs and the "NO" is printed but an error is printed too. How can I check for the value of "b" so that no error occurs if b is not passed?? example http=www.mydomain.com $myvar=HTTP_GET_VARS['b'] causes an error because "b" does not exist (ie. its not passed in the URL string. $myvar maybe evaluated as NULL or Empty but the error is printed in the page, anyway.
Coding "NEXT" And "PREVOIUS" Buttons
Hi I am stuck here. I am doing a form which dispalys details of client companies. My query includes this statement: .... WHERE CompanyName LIKE %$name% .... What I need is following: if a query returns more then one result I what to "flip" through result with NEXT and PREVIOUS buttons.
Mysql/php - "LIMIT" And "ORDER"
In the following fragment of code, I am querying a database that in order to display a list of films. The list is very long and I would like to offer the possbility to restrain the range of results showned by page keeping in mind that the user should be able to browse forward or backward data if applicable. I know that I have to add the LIMIT method in the MySQL query but I have a hard time figuring how not to get lost in setting it dynamically in the PHP script. Then I have a second question. Is there a more elegant / straightforward way to deal with the display order of the data (cf. $ot, $od and $oy)? Code:
Sticking "if" Or Changes Within A MySQL "where" Array?
I'm not exactly sure how to even ask the question, and I know my terminology is not good as I'm a SQL beginner, but, here goes. I need to find a way to make an if statement within an array...or, the "while" portion of a recordset. The best way I can ask is show what I mean. http://oscarguy.mechphisto.net/awardbrowse.php If you go there and select an award (like Best Picture), leave the year field alone, and select YES and submit, you'll see a lot of results. And I have HR's dividing each entry. What I need to do is group all the entries of the same year, or at least only put HR's between the blocks of years. So, I'd have all the entries for 2002, an HR, then all for 2001, an HR, etc. Here at the bottom I'll include my PHP code I'm using so far. But I have no idea where to even start looking for an answer...if it's even possible. If someone can just give me the name of the function or process or technique, then I can go Web/book searching myself...I just need a direction of where to go. PHP:------------------------------------------------------------------------ ------ $query_RS_award = "SELECT * FROM $award WHERE id != Ƈ' ORDER BY year DESC, w DESC"; //$query_RS_award = "SELECT * FROM $award WHERE year = "$year""; $RS_award = @mysql_query($query_RS_award, $connection) or die("Couldn't query: " . mysql_error()); $totalRows_RS1 = mysql_num_rows($RS_award); while ($row_RS_award = mysql_fetch_assoc($RS_award)) { $award_id = $row_RS_award['id']; $award_tblid = $row_RS_award['tblid']; $award_award = $row_RS_award['award']; $award_year = $row_RS_award['year']; $award_category = $row_RS_award['category']; $award_won = $row_RS_award['w']; $award_film = $row_RS_award['film']; $award_nominee = $row_RS_award['nominee']; $award_note = $row_RS_award['note']; if (!($award_category)) { $award_category = "n/a"; } else { $award_category = $award_category; } if ($award_won == "1") { $award_won = " - Award Winner"; } else { $award_won = ""; } $display_block_Award .= "YEAR: <span class='normalText12White'>$award_year</span><br>FILM: <span class='normalText12White'>$award_film</span><br>CATEGORY: <span class='normalText12White'>$award_category</span><br>NOMINEE: <span class='normalText12White'>$award_nominee</span><span class='normalText12BoldWhite'>$award_won</span><br><blockquote><span class='normalText12White'>$award_note</span></blockquote><hr>"; }
Cookies And "include" Or "require"
i'm having a problem with my setcookie() instructions. Although there are absolutely no html tags in front of them,for some reason PHP3 sends me back the message "oops...php3_SetCookie called after header has been sent"... I do however use two "require" calls, one to a file with a .php extension, and one to a file with an .inc extension. At the beginning of each files there's a Could the cookie failure and the include functions be related ? In my text, I have even wiped out any HTML tags such as "bold, paragraph, line break" tags, even in "echo" commands, but to no avail what am i doing wrong ?
FTP_login + $pass="" And $user=""
I use the following scrit in an Intranet with the user name = "" and the password = "" : <?php $ftp_server = "192.168.25.25"; $ftp_user = ""; $ftp_pass = ""; $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) { echo "Connected at $ftp_user@$ftp_server "; } else { echo "Can't connect with $ftp_user "; } ?> I have the following message : Connected to 192.168.25.25 Warning: ftp_login(): 'USER': Invalid number of parameters in E:www est_ftp.php on line 26 I tried to : ftp_login($conn_id, "", "") but i have the same result...
Why Use "Stripslashes" And "Addslashes" Function
Can someone let me know why one would use strip slashes or add slashes functions. I know what they do but cannot see the exact use for them e.g. if i have a textfield and encase it in an stripslashes function, it will escape any back slashes etc...
Parse Errors With "case "action":
I want to call an action that is in a file called "configm.php" but I get a parse error on line 8. (the bit that goes 'case "add":') Code:
Multiple Selected="selected" In A List.
I have a database with 1 to many and the many is a list with multiple selects in a list. When I click on a master record I have as part of my form the select statement for the multiple choice list. I want the list to highlight the multiple chosen values. here is part of the code. $dresscat = specdresscat($dresstypeid); //this is the query to get the values in the detail table $drcatrow = pg_fetch_array($dresscat);// the array for the detail table. <select name="stages[]" multiple="multiple"> <?php $allstages = allstages(); // this is a function to query my database to get the value for the list. while ($allstagerows=pg_fetch_array($allstages)) { $eachstage= $allstagerows["stageid"]; $specstage= $drcatrow["stageid"]; // this is the point I need help if ($specstage == $eachstage){ ?> <option value=<?php echo $eachstage;?> selected="selected"><?php echo allstagerows["stage"]?></option> <?php }else{ ?> <option value=<?php echo $eachstage;?>><?php echo $allstagerows["stage"]?></option> <?php } } ?> </select>
How To Count "Hit" And "View"
I would like to know when a user logs in, he clicks Mike's E-mail. It will count one which mean "Hit". So that I will be able to know how many times users click Mike's E-mail. Like Sitepoint. When other users read other problems. Views will count 1. I would like to know how to do it. Could you explain with script?
"echo" Or "print" ?
Can tell me someone is some big different between "echo" and "print". What You prefer to use?
Error Using Header("", FALSE) To Show Multiple Images From MySQL Db
Many people seems to have problems when displaying multiple images from their database (mySQL db). Often you can read error statements like "Header already sent out ...". To solve this, people often propose to use include files. To keep the scipt it would be nice not having this problem, being able to sent out multiple headers to a browser without getting these error messages. In the PHP4 manual, we can read an option that can be added to the header statement, Header("xxx",FALSE). It would enable multiple headers to be sent out. For instance the following statement: while ($product = db_fetch_object($result)) { header("Content-type: pv($product->filetype)",false); echo pv($product->image)" } However, it doesn't work. Anybody has any idea why? Does anybody use this option FALSE with success?
Reading An Array Of Records From MYSQL Then "Save As" Them Back As Copy
Hi all, Ok here is what I want to do then I will show you what I have. I have some records in a MySQL DB that I want to store in an array and then immediately copy them back where the only thing that would change would be one field - the date. So here is my table: ------------------------------------- |userName | date | value | -------------------------------------- | theDano | 200005 | 123 | -------------------------------------- | theDano | 200005 | 345 | -------------------------------------- | theDano | 200004 | 678 | -------------------------------------- | joeUser | 199908 | 897 | --------------------------------------- So if I am querying for the user "theDano" on a specific date (format yyyymm) in this case 200005 (year 2000 month of May) Here is my array to query all records to fullfill this request: if ($update=="future") { if ($month!="01") { $db = mysql_connect("localhost", "dbuser"); if($db) { mysql_select_db("dbName",$db); $result = mysql_query("SELECT * FROM tableName WHERE userName = '$userName' AND date = '$date' ORDER BY value DESC ",$db); if ($result) { $num=mysql_numrows($result); $i=0; while($i < $num) { $userName = mysql_result($result,$i,"userName"); $value = mysql_result($result,$i,"value"); echo "<tr>"; echo "<td width=Ê×'>" . $userName . "</td>"; echo "<td width=ï`'><div align='right'>" . $value . "</div></td>"; echo "</tr>"; ++$i; } } } } } Now I want to take the array of records queried which was: | theDano | 200005 | 123 | -------------------------------------- | theDano | 200005 | 345 | and copy them to look like this back into the database: | theDano | 200006 | 123 | -------------------------------------- | theDano | 200006 | 345 | so you can see that the only thing changed was increasing the month by one. Would seem simple to most but I am having a tough time wirting the code to read the array and increase each date value by "1". Thank you in advance for anyone that replies. ) Dano
|