473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

More objects from a database

5
Hello there,

I want to make a list, where I have to fetch more than one object from a database.
So with the query and the "fetch_object"-function I need to sort get the "Omschrijving" and "Verkoopprijs" from a database.
They have to be sorted according to the value (selected with a dropdown menu in the html code).

What I'm getting now as a result is only the last item from the database, so nothing cheaper.

If there are any questions, please ask them.


Highlighted in bold you can find the important items in the code.

thanks in advance

Expand|Select|Wrap|Line Numbers
  1. <?
  2.         if(isset($_POST['submit'])){
  3.         $infomin = $_POST['minimumprijs'];
  4.         $infomax = $_POST['maximumprijs'];
  5.         $keuze = mysql_query("SELECT omschrijving, verkoopprijs FROM artikel WHERE verkoopprijs BETWEEN '$infomin' AND '$infomax'");
  6.         $obj = mysql_fetch_object($keuze);
  7.  
  8.  
  9.         $minprijs = $_POST['minimumprijs'];
  10.         $maxprijs = $_POST['maximumprijs'];
  11.  
  12.         if($minprijs>$maxprijs){
  13.             print "Foutmelding: De minimumprijs mag niet hoger zijn dan de maximumprijs!";
  14.         }
  15.         else{
  16.             print "<tr> <td> Artikelnaam: </td> <td> Prijs: </td> </tr> <br/> ";
  17.             print "<tr> <td> $obj->omschrijving </td> <td>$obj->verkoopprijs</td> </tr>";
  18.         }
  19.     }
  20. ?>
Oct 8 '11 #1

✓ answered by Dormilich

They have to be sorted according to the value
you have to do that already in the SQL, check the ORDER BY clause.

I want to make a list, where I have to fetch more than one object from a database.
then you would have to fetch it in a loop (with the outdated mysql_* functions and the modern MySQLi classes you typically use a while() loop, while the PDO classes work best with a foreach() loop).

2 1112
Dormilich
8,658 Expert Mod 8TB
They have to be sorted according to the value
you have to do that already in the SQL, check the ORDER BY clause.

I want to make a list, where I have to fetch more than one object from a database.
then you would have to fetch it in a loop (with the outdated mysql_* functions and the modern MySQLi classes you typically use a while() loop, while the PDO classes work best with a foreach() loop).
Oct 9 '11 #2
zero 0
5
@dormilich
Thank you very much. I solved it :)
Added a while loop with $obj++ and print the $obj. it gave all values ^^
Oct 9 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Simone | last post by:
Hello. Could you guys please share with me what problems have you faced if any? At work we store all our tables in SQL and use Access as the front end. The access file has many queries...
6
by: Helmut | last post by:
Hello, I am Helmut, my database has a Frontend of 15.4 MB which cause Acc2K to corruption: Limit is 12.5 MB. Service Pack 3. On three different PCs with 256, 512 and 1.000 MB RAM. All on W2K,...
12
by: Noel | last post by:
Hello, I'm currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded...
1
by: ImageAnalyst | last post by:
In my setup/installer for my solution, I get several warnings: Warning 16 Two or more objects have the same target location ('\interop.shell32.dll') Warning 18 Two or more objects have the same...
1
by: Red Daly | last post by:
Hello group, I have been using JSON for a while and it has made many things a breeze. However, JSON does not natively describe certain things like pointers and custom types. I created a simple...
6
by: mask.sd | last post by:
Can anybody Suggest a book that can be used as Referance from Scratch to atleast Intermediate level & is available easily in India So it should Contains the things from Basics to Experts.. ...
3
by: Himmel | last post by:
I have added a section of code to a function that is designed to copy data from several tables and place them into a single table. The new table already contains a unique ID and name, and I am...
2
by: webcm123 | last post by:
People say that structural programming isn't good for database connection. I code fast-running structural oriented CMS and I don't know what I should do. I use mysql connection using mysql_*. I...
23
by: raylopez99 | last post by:
A quick sanity check, and I think I am correct, but just to make sure: if you have a bunch of objects that are very much like one another you can uniquely track them simply by using an ArrayList...
7
Niheel
by: Niheel | last post by:
When should one use access over a database like SQL Server or MySQL ?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.