Associative Array Question - Newbie
I am in the process of designing (before coding) my first serious PHP/MySQL application and I have a question about the best way to store information.
The application will allow users to view the voting record of different legislators. I have concluded that the most efficient way to store the data is in two tables: one that has details about each legislator (mp) and another that has the details of each piece of legislation (bill). Each legislators record will have a field that holds info in an associative array in the form (bill ID, vote result). This way, when a new piece of legislation is added to the database, one more value pair (bill ID, vote result) will be added to each legislators voting record field.
My question is two part:
Is this the most efficient way to store the data?
and
I suspect I will have to be using regular expressions to extract and format the data from the MySQL query. Are there some PHP or MySQL functions or syntax I would find useful in this process of retrieving the data? Any online tutorials? (mysql_fetch_array appears to create an array out of two fields - not really what I am looking for...) I realize this is a rather vague question, but if you have any suggestions, please let me know.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Using The $value Of An Associative Array
I am using an associative array to populate one field of a form. I use the $key to obtain the numeric value I want to enter into one of my tables. I use the $value to display in nice text what the numeric key represents. I have no problem entering the $key into the table or displaying the $value on the form. My problem is in displaying the results of the processed form to the user: My form "action" is "processform". In processform I do the INSERT query and return a message to the user. It is in the message to the user where my problem comes in. I've only captured the $key from the form. How can I capture also the $value from the form post, so that when I display to the user what he or she has chosen on the form, the nice text will display rather than the (to them) meaningless id number? Code:
Associative Array
I have to search a db table, and count distinct records to get some results from a survey we've done. The record needs to be echoed along with the number of times it is recorded. Each field in the table has to be searched individually, so that we can see the answers for each question separately. I thought that I could do this with one query, maybe 'count distinct', but I couldn't get it to show both the value of the row, and the amount of times that value had been recorded. So, I have to do 2 queries, one getting the distinct values of the field, the other counting how many times they are recorded. Here's the 2 queries: Code:
Associative Array
I have a list of word/number pairs. I need to retrieve the word that has the highest number associated with it. I have put this list into an associative array... $array['apple'] = ཈' $array['orange'] = Ɖ' $array['pear'] = ཮' ...and ordered it using arsort() so that "pear" in this case is the first value, then hit a brick wall when I realised that echoing $array[0] didn't work on an associative array. Indeed, why would it? :) Is there a simple way to retrieve the top value after it's sorted, or do you always need to know the name of the key to manipulate associative arrays? Else, do I need to look into multidimensional arrays? Something like... $array[0] = array('apple' => ཈'); $array[1] = array('orange' => Ɖ'); $array[2] = array('pear' => ཮'); At which point, I'm not clear on how this would be sorted based on the values of the nested arrays, and how you would then specify to retrieve the key of the nested array of the first key of the original array!
Associative Array In Class
In PHP Version 4.3.6 I am trying get a value from a class member that is an associative array... class MyClass { $var row; function MyClass() { $this->$row = array("A"=>"Apple", "B"=>"Bob"); echo "One: " . $this->$row["A"] . "<br>"; echo "Two: " . $this->row["A"] . "<br>"; $cache = $this->$row; echo "Three: " . $cache ["A"] . "<br>"; } } But this is the output... One: Array Two: Three: Apple How can I get at the value of the associative array without making a local copy first!
Array_push() With An Associative Array?
Is there a way to add a key/value pair to an associative array? I'm tryint to do this, but it dosn't work. $author = array(); while ($row = mysql_fetch_array($result)){ array_push($author,$row[id],$row[name]);}
Make Associative Array Out Of String
I have a string that look something like this: $string = "weight, kg|1200|width, mm|220|prize|20000"; and I would like it to an associative array and print keys and value: weight, kg: 1200 width, mm: 220 prize: 20000 (The string above is fetched from a database) Anyone have any bright ideas how to do it?
Adding Values Onto An Associative Array...
I'm trying to develop a simple class which through the interface you can add elements to an array. The method I have used to add the elements is setContentFields($name, $field_type), I have used an array counter variable to increment the array index each time. To me this seems like a workaround, and I wondered if there was a more elegant way of doing this. The class is as follows:
Sorting An Associative Array Of Objects By Value?
I'm trying to sort an array of objects within an object. Included is a dumbed down example so that we can get at the meat of the issue without worrying about complexity or validation. Basically, Funk is an object that has a name (string) and a value(int). FunkThis represents an object containing a list of Funks, with each key corresponding to the name of the Funk. I want to sort this list by val, but I get a Warning: usort(): Invalid comparison function error when I run the script. Keep in mind that this is for PHP 4 I'm open to suggestions to getting this to work. <?php class Funk { var $name; var $val; function Funk($name,$val) { $this->name = $name; $this->val = $val; } function getVal() { return $this->val; } function getName() { return $this->name; } } class FunkThis { var $list; function FunkThis() { $this->list = null; } function add($funk) { $this->list[$funk->getName()] = $funk; } function compareFunks($a,$b) { $aVal = $a->getVal(); $bVal = $b->getVal(); if ($aVal == $bVal) return 0; if ($aVal $bVal) return 1; if ($aVal < $bVal) return -1; } function sortByFunk() { $list = $this->list; $this->list = uasort($list,"compareFunks"); } function show() { print_r($this->list); } } $a = new Funk("A",3); $b = new Funk("B",7); $c = new Funk("C",1); $d = new Funk("D",9); $e = new Funk("E",6); $funkthat = new FunkThis(); $funkthat->add($a); $funkthat->add($b); $funkthat->add($c); $funkthat->add($d); $funkthat->add($e); $funkthat->sortByFunk(); $funkthat->show(); ?>
[smarty] Addressing Associative Array
Given this assoc array: $dtl_array[0]['uom_array'][0][0]='key1' $dtl_array[0]['uom_array'][0][1]='value1' $dtl_array[0]['uom_array'][1][0]='key2' $dtl_array[0]['uom_array'][1][1]='value2' $dtl_array[1]['uom_array'][0][0]='key3' $dtl_array[1]['uom_array'][0][1]='value3' $dtl_array[1]['uom_array'][1][0]='key4' $dtl_array[1]['uom_array'][1][1]='value4' $sample->assign("dtl_array",$dtl_array); $sample->display(); How could I create a combobox out of $dtl_array in the templates? The following does not work: <select name="aname"> {section name=mm start=0 loop=$dtl_array.0.uom_array step=1} <option value="{$dtl_array.0.uom_array.mm.0}"> {$dtl_array.0.uom_array.mm.1} {/section} </select>
Values From Form Via Associative Array
I have a form which has a text field and a select box. There are many other fields also in the form . I need get the value of the text field or the select box, depending on which one has a value. Additionally it has to give the value only from the text field even if there is a selection made from the select box. I know that i can get post values from form like this: PHP Code:
How To Add An Element To The Middle Of An Associative Array ?
I got an array that consists of elements that are arrays also. Now I wish I could add an element to the middle of it. Let mi give you an example: array ( - array(1,15,apple), - array(2,28,banana), - array(3,41,orange) } I would like to add, let's say, carrot on 2nd position: array ( - array(1,15,apple), - array(2,57,carrot), - array(3,28,banana), - array(4,41,orange) } Array_splice() does not work (or maybe i use it in a wrong way? - it splits an adding element for, in that case, 3 elements). Array_push() adds only to the end of an array. can samobody tell me how to add and element to the middle of an associative array?
Sort An Associative Array Alphabetically
I am working on a product catalog where it displays a product type on a page via the type variable. The products should be displayed alphabetically by $make and $model and i couldn't find any snippets or info other than asort etc. Just curious if anyone else needed such a sort function and how they did it. ie: product makes Maico, Madsen, Bio-logic etc and their models MA-300, Itera, AC-200. So I would have listings like Maico MA-300, Maico MA-800, Madsen Itera etc., and I need these alphabetical using make and model values. PHP Code:
How To Print A Multidimensional Associative Array?
I have the following associative array: $user["john"]["mozilla"]=1; $user["john"]["xmms"]=1; $user["doe"]["mozilla"]=0; $user["doe"]["office"]=1; $user["paul"]["mozilla"]=0; $user["paul"]["xmms"]=1; $user["paul"]["office"]=1; How can I print such an associative array using a loop statement like foreach?
Setting Values In Associative Array To 0
Ive tried almost every combination of while,foreach, key, value , array,0 I can some up with Ive got an associative array that Ive been using as a counter eg if (blah blah blah ) {$array['beans']++} elseif (something else){$array['peas']++} else {$array['carrots']++} I then want to reset all the values to zero foreach ($array as $key=>$value) { ??????? } or array_walk ?
XML Formatted String To Associative Array
I'm working on a php socket server for my chat room, and I need to parse some very short XML messages like this: <msg t="usr"><body a="pubMsg" u="username"><![CDATA[some message]]></body></msg> Right now I'm using a bunch of substrings (start laughing. lol), but it's very inflexible. However somehow it works... The problem arises when I try to store user variables (ignore the indents and line brakes, in reality, there will be non of them; we don't want to waste bandwidth) <msg t="usr"> <body a="updVar" u="username"> <var t="s" n="varname"><![CDATA[some variable]]></var> <var t="n" n="someNum"><![CDATA[3]]></var> </body> </msg> I have no idea how to parse those stuff from a string to an associative array... What I want is an associative array that I can access those stuff similar to this way: echo myXML['firstChild']['firstChild']['firstChild']['attributes']['t']; and it should output "s"
PHP Stops Processing On Multidimensional Associative Array
When using a multidimensional associative array to cross-reference data in a second, single-dimensional array, PHP stops processing data after a few iterations. Memory usage according to the task manager doesn't seem to spike and CPU usage only gets as high as 11 to 13 percent. A sample script is provided below, any help or alternative solutions are welcome. (By the way, the script below works fine on Linux with the same version of Apache and PHP. Possibly a PHP configuration issue?)
Printing Out An Associative Array - Whats Wrong?
I have this code segment: $query = "Select * from Payments order by CustID"; .. .. /* execute the query */ .. if (ora_exec($cursor)) { $recordset=array(); while (ora_fetch_into($cursor,$recordset,ORA_FETCHINTO_N ULLS| ORA_FETCHINTO_ASSOC)) { echo $recordset["CustID"]."<BR>"; echo $recordset["Amount"]."<BR>"; } } Gives me the following error Notice: Undefined index: CustID Notice: Undefined index: Amount The table Payments has only CustID and Amount as attributes. is my usage of the array offset incorrect?
Complex Associative Array To XML FIle And Back
We're using php 4.1 and it doesn't seem to have built in support for this. Coming from a dotnet background this surprised me...Anyways, thats a different topic altogether... I'm looking for a php class that can allow me to save a complex associative array as an xml file on our server and also be able to read in back into a complex array when needed. (you'll find an example of the array below). Because of the complexity if the array, I feel it would be easier to use this method as opposed to saving to a db. I know i could write a class to do it, but I'm trying not to reinvent the wheel. Googleing only refers me to extentions like pear which I dont want. And I 'm sure someone else has had to do this before. //ARRAY EXAMPLE ...
POST (or GET) Associative Array To Script From Form
Actually thought I understood this but I can't seem to make it happen this morning, and I can't seem to find a clear simple reference here. Can I pass an associative array from a form (using either POST or GET) to a .php script all at once, in one simple step? ie. Say I have the following variable/associative array $graphtable = Array ( [TESTPHASE] => G085 [GRADE] => 3 [0_LE_1_A] => 0 [1_LE_1_A] => 7 [2_LE_1_A] => 28 [3_LE_1_A] => 22 [4_LE_1_A] => 7 [null_LE_1_A] => 0 [PROTOCOLS] => 64 ) And I pass it as a hidden variable in the following form: ....
Newbie Array Question
I have a php form, where I want to "weed out" not-so-good customers. It began with if stristr('offensive_customer',$name) { exit; } ....then, over time, there were other form variables I needed checking, and that list grew. Now it looks like this: if (stristr('offensive_customer',$name) || stristr('offensive_city',$city) || stristr('offensive_customer2',$address) || stristr('offensive_customer',$address) || stristr('offensive_customer',$address) etc. etc. etc. you get the idea) { exit; } I then realized that the "$globals" variable holds ALL form variables, so I was wondering if there is a more "efficient" and speedy way for PHP to check. Here is some "pseudocode," to clarify where I was hoping to go with this: $offending= array ( 'bad_person', 'unwanted_city', 'bad_check_writer', 'bad_apple', 'etc.,etc.' ) if (in_array($globals),"$offending") { exit; } Any thoughts on this? Or, is PHP faster doing a large number of stristr lookups using the "||" (or) operand?
Associative Arrays
Basically I am writing a shopping cart from scratch. I can get my first item looking good but I can never add to my cart. If I choose another item it seems to overwrite the first one. Code:
PHP ADODB DB2 Associative Arrays
I know this doesn't -exactly- match php, but its still related, and adodb doesn't have its own google group yet, so i thought I'd go generic. The problem is, I created a nice little script for Oracle using oci8 and tried to convert to db2, but ran into issues. In case you don't know what ADODB is, checkout http://adodb.sourceforge.net/ The GetAssoc, or SetFetchMode(ADODB_FETCH_ASSOC) methods to get an associative array from a DB2 database don't function properly. The result of a simple query, for example: select firstname, lastname, dob from person results in an array something like: Array ( [LASTNAME] => 'Bob' [DOB] => 'Henry' [0] => ��-12-01' ) Now -that- is a real pain, and I've tried looking through the db2 driver, but couldn't pin-point myself where the problem was, as the ADODB code is a little out of my league, and the complications of the new 'extension' don't help. I was just wondering if anyone knows what I'm talking about? Or maybe a possible solution to the problem? I'd prefer a solution at the base level, not a 'quick-fix', as I use this library often. Some further information that might be useful is that i'm running DB2 v8.2 Enterprise, on WinXP (up-to-date). I'm using the latest ADODB 4.8.1 (NOT the extension). And i'm using Apache/2.2.2 + PHP/5.1.4 served on WinXP, same machine as DB2.
Associative Arrays Keys
I have a some text that i have to sort according to their year. The text is in this format.. A Short Story (2000) A long time ago (1999) A list (2004) Before Time (1999) Car parts (2004) so basically i want the output to be.. A long time ago (1999) Before Time (1999) A Short Story (2000) A list (2004) Car parts (2004) I thought the way to go about this would be to extract the years and put the whole thing in an associative array with the years as keys, but of course the keys have to be unique so in this case values override each other. PHP Code:
Sorting Associative Arrays...
I have an associative array which assigns arrays of 4 values to strings (see the example below): Array ( [value1] => Array ( [0] => 65 [1] => 2 [2] => 75 [3] => -10 ) [value2] => Array ( [0] => 65 [1] => 2 [2] => 0 [3] => 65 ) [value3] => Array ( [0] => 15 [1] => 2 [2] => 5 [3] => 10 ) ) Up to now, I've been using ksort on the big array and it sorted it by the "value1", "value2", etc., alphabetically. Now, however, I want it sorted numerically by the 4th value of each array inside the big array (the -10, 65, and 10 in the above example). How would I go about doing this?
Associative Arrays And Loops
I am trying to make database calls on what will potentially be a very large database. I would like to receive query results from the database using mysql_fetch_array() to get an associative array. Once I have this array, I want to show certain fields using my own formatting. If there are no fields, I want to show a "No Results" message. My code thusfar looks like this, and it does nothing if there is an invalid database query: Code:
Associative Arrays: Are Keys Strings?
I am wondering if it is 'wrong' (although it works) to work with associative arrays like this: $array[somekey] = blah instead of specifying the key as a string: $array["somekey"] = blah What would you say? What is right, what is wrong from the point of view of correct PHP coding?
Beginner With A Question About Associative Arrays
Is it possible to reference an index of an associative array using a variable? e.g.: If I had an array: $myArray["first"] = "myValue"; and if I were to declare a variable: $myVariable = "first"; I can't get PHP to display "myValue" by referencing this index using $myArray[$myVariable];
Interesting Insight Into Associative Arrays Versus Non-associatives...
We should all be familiar with the explode() and implode() functions. explode("Some String") --> "Some Array" implode("Some Array") --> "Some String" The idea is that each function goes back and forth between an array and string, provided you use a common delimiter. Now, let's look at a simple example, before I post my issue. Code:
Help With XML DOM Using PHP (XML Newbie)
I tried posting in the XML board, but there isn't much traffic there, so since I'm using PHP to use the XML DOM, I figure I'll try posting here too... sorry if this qualifies as a cross-post. I've read through (skimmed, really) the PHP & XML articles on devshed, in the XML section... and I've been playing around with using the XML DOM, but have a few questions. My XML document looks something like this: Code: <?xml version="1.0"?> <SITE> <SECTION1> <PAGE1>This is the first page of section 1.</PAGE1> <PAGE2>This is the second page of section 1.</PAGE2> <PAGE3>This is the third page of section 1.</PAGE3> </SECTION1> <SECTION2> <PAGE1>This is the first page of section 2.</PAGE1> </SECTION2> </SITE> Now, I'm using the DOM to extract the root, and then list all of the children of the root. However, what's happening is that even though I have 2 children of the 'SITE' node, my code is reporting that there are more. I've checked the type for these other nodes, and they say they're text objects, but I can't figure out what they are. Here's my code:
Newbie 2
Notice: Undefined variable: username in /home/fhlinux169/c/ clashoff.co.uk/user/htdocs/create_entry.php on line 11 Notice: Undefined variable: password in /home/fhlinux169/c/ clashoff.co.uk/user/htdocs/create_entry.php on line 11 Ive got a new error message please help.Am trying to setup userlogin on my website. This is the code: <?php mysql_connect("localhost","root") or die ("Could not connect to database"); mysql_select_db("user") or dir ("Could not select database"); if ($_POST['submit'] == "Register") { $query = "insert into users (username, password) values ('$username', '$password')"; mysql_query($query) or die (mysql_error()); ?> <h3>You are now registered</h3> <a href="index.html">Go back to main page</a> <?php } else { print("not registered"); } ?>
Can Anyone Help Out A PHP Newbie?
Just now learning my way around PHP, and I'm having trouble with something that I'm sure is a breeze for more experienced PHP coders. Hoping someone can help. I have a Web directory filled with text files that I need sorted alphabetically. The details are: · The files are numbered sequentially with a filename in the format #.txt, such as 1.txt, 2.txt, 3.txt, etcetera. · I need to sort them by a client name that appears in the first line of each file. The files look like something like this: XYZ Corporation Aaron Winslow Contacted May 12, 2004 Entry Code 2355239 · It's crucial that the sorted files be renumbered sequentially, as a report routine that pulls reports from the files freaks out if it finds a missing number. They numerical order would have to match the alphabetical order. · All the files exist in a single Web directory with no other files, so paths are not a consideration. And since there is nothing in the directory but the files to be sorted, operations on the entire directory are possible. Can anyone suggest anything appropriate to accomplish this, even something quick and dirty? I've been doing bubble sorts for years in other languages, but I'm not up to speed on PHP enough yet to get it working. I could probably be tacky and resort to doing it in QuickBASIC, but who on earth wants to do THAT? ;-)
Newbie Pdf Problem
Fatal error: PDFlib error: function 'PDF_begin_page' must not be called in 'object' scope in c:inetpubwwwroot test.php on line 9 I have enabled the pdf.dll I have 'write enabled' every file listed in phpinf();
Newbie: Xsl(xml)2sql2mysql
Is it possible to apply xsl to xml and produce sql insert statement that will be used by php to insert data to mysql.
Newbie PHP/SQL Problem
I've install a supposedly compatible combination of PHP, SQL with an Apache server. Generally all individual components seem to operate fine. I can create tables in the database using mysql and I can run basic PHP code in my browser using the Apache server. Everything's running on my desktop PC. However, whenever I use the mySQL related functions in my PHP, the php script just stops. No error messages. Just nothing. For example, using something like: $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); in my php just stops the script dead. Everything up to this line executes but nothing after it. This appears to be the same behaviour as if I put in a non-existant function call. So my question is, how does the php know where to find the SQL functions?. Is there any configuration required?. All of my components came out of a book (with CD) and have been configured as suggested.
Cookie Newbie -- Please Help
I'm writing a discussion board app that will store a user's name in a cookie after they log in so that for the duration of their visit to the site and for a half hour afterwards, they will not have to log in again. I realize that cookies must be sent in the header of a page before any content, so on my 'write message' page, I have the following in the header section, before even the doctype declaration:
PHP Newbie - Converting From ASP
I'm making the switch from ASP to PHP, and I'd appreciate it if someone could tell me the equivalent of the following. I'm basically looking for keywords to look up, but examples would be nice too. Any good PHP resources for ASP people like me? cheers. Response.Buffer and Response.Flush Response.ContentType = "text/HTML" Response.AddHeader "Pragma", "no-cache" Response.CacheControl = "no-cache" Response.Expires = 0 If Len($title) = 0 Then $title = "the default" and finally, this one: $TheDate = Right("20" & Year(Now()), 4) & "-" & Right("0" & Month(Now()), 2) & "-" & Right("0" & Day(Now()), 2) & " " & Right("0" & Hour(Now()), 2) & ":" & Right("0" & Minute(Now()), 2) & ":" & Right("0" & Minute(Now()), 2)
Htmlspecialchar Newbie
I'm a little confused on where to place the htmlspecialchar. I have the following form: <form name="project" method="post" action="add_project.php"> <p> </p> <table width="640" border="1" cellpadding="5" style='border-collapse: collapse'> <tr> <td width="606" bgcolor="#CCCCCC"><div align="center"><strong>Create a Project</strong></div></td> </tr> <tr> <td height="131"><div align="center"> <table width="100%" border="0"> <tr> <td width="33%"><div align="right">Project Name: </div></td> <td width="63%"><div align="left"> <input name="pname" type="text" size="25"> </div></td> </tr> <tr> <td><div align="right">Project Description: </div></td> <td><div align="left"> <input name="pdesc" type="text" size="25"> </div></td> </tr> <tr> <td><div align="right">Active:</div></td> <td><div align="left"> <input name="active" type="checkbox" id="active" value="yes" checked>
Newbie Looking Where To Start
After being a lurker in here for some time, I got the PHP bug, and downloaded Apache 2.0, PHP 4.summat and MySQL I installed, registered the dll's edited the conf files and finally got it all working (i think) after a few nights of faffing about. Now... where should i start? I know naff all about PHP or MySQL and would be greatful if someone could point me in the direction of some tutorials to start learning about PHP and MySQL. I am from a programming background (visual basic) and have a welly load of knoledge on relational databases so wheres the best sources... Book/Web/Forums etc...
Newbie With IF Problem
The following code works. It's suposed to jump to start.php. If I uncomment the comments then the code doesn't jump to start.php. Why is this? Do the IF's work from top to bottom or bottom to top? It's almost like the uncommented code in the second section of code is being ignored. Note that ob_start,session_start are in header1.php. ---------------- Code below jumps to start.php------------------------------ <?php include("general_scripts_etc/header1.php"); if (empty($_SESSION['site_name'])) { ob_end_clean(); header("Location: start.php"); } if (empty($_SESSION['site_logo_location'])) { ob_end_clean(); header("Location: start.php"); } if (empty($_SESSION['site_admin_email'])) { ob_end_clean(); header("Location: start.php"); } $_SESSION['email']=$_POST['email1']; if ("a"=="a") { ob_end_clean(); header("Location: start.php"); } /* if ($_POST['email1']==$_POST['email2']) { ob_end_clean(); header("Location: enter_dob.php"); } else { ob_end_clean(); header("Location: reenter_email.php"); } */ include("general_scripts_etc/footer1.php"); ?> -------------- Code below jump's to enter_dob.php if email1=email2 OR jumps to re_enter_email.php --------------------- <?php include("general_scripts_etc/header1.php"); if (empty($_SESSION['site_name'])) { ob_end_clean(); header("Location: start.php"); } if (empty($_SESSION['site_logo_location'])) { ob_end_clean(); header("Location: start.php"); }
Php Newbie Want To Use Php To Do The Following Things
I wanna use a textarea and a submit to transfer the text area into a file. and then the PHP program using a .exe program open this file, processing the file, and save the output in another file then PHP will open this file and update the html within the text file and send to the customer My question is: if this possible? what if the users input is not valid for the .exe file? how to analyze this in php? what if multiple users click this php file?
PHP Help For New Webiste.... Newbie!!!
This is my first post in this group so bear with me.... I am setting up a website where visitors will log in and input data into their own particular fields. These fields will be viewable by other members so I need to set up some access rights on the SQL backend. I have limited knowledge of PHP but have grasped a fair bit from tutorials. I don't mind paying someone to get the PHP sorted but it is going to be a free site so would like to keep costs to a minimum. Also I would like to group members into groups? Does this seem possible and how difficult would this be. I will be using MYSQL and PHP
Newbie Mysql Help
Any way to retrieve data from mySQL database in the order of user input? Example: select * from fruit_database where color='red' or color = 'blue' or color = 'orange' I want this result: apple blueberry orange I don't want this result: blueberry orange apple Currently, my mySQL database is returning results in order of my Primay Key Column. I'm wanting the results to be returned in the same order as the user input.
Session In Php (newbie)
I'm trying to use sessions to preserve data across different pages. I'm currently using apache 1.3.29 and php 4.3.1. My problem is, when I store object in the session, when I retrieve that object in other pages, it gives me an error stating that the object is not complete. This is strange as I did it before and it suddenly gives me this problem now.
[NEWBIE] Setting Cookies!
Hey, I want to be able to filter the content of a page according to a username. I think the best way to do this is to set a cookie at the login page, taking the username, and then using that cookie as the criteria for my SQL statement in the query.... How do I set the username into a cookie from a form in a previous page? Can anyone show me the code that i would need to write into the form?
Displaying 10 Rows (Newbie)
I need help....I want to display 10 hits from my sql database..... A function that wil select the first 10 rows of my database and then also provides me with a link to the script itself to diplay the next 10 hits (Or less, if there is no more).
|