473,473 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to display a result uptop if it has the value of one?

Ajm113
161 New Member
Ok, how do I have it so the script will display a result with a value of lets say one in mysql up top of a while loop when it echoes out the results?
Jul 11 '07 #1
7 1050
pbmods
5,821 Recognized Expert Expert
Heya, AJM.

Do you want to output row numbers? Or are you trying to only display rows that have a certain value? Do you need to output a specific row ahead of all the others?
Jul 11 '07 #2
Ajm113
161 New Member
I want to display a row with a value of 1 up top I guest...
Jul 11 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, Ajm113.

I want to display a row with a value of 1 up top I guest...
Alrightey. Probably the easiest way to do it is to create a variable to hold the top row. While you're fetching your MySQL results, check for the value that you want. If it matches, set the top variable to that row. Otherwise, add the row to your array as normal.

Once you're done loading results, check for the top variable and output it.

Expressed as code:
Expand|Select|Wrap|Line Numbers
  1. $data = array();
  2. while($row = mysql_fetch_assoc($result)) {
  3.     if($row['desiredField'] === 'desiredValue')
  4.         $top = $row;
  5.     else
  6.         $data[] = $row;
  7. }
  8.  
  9. if(isset($top))
  10.     // Display the top row.
  11.  
  12. // Display the other rows.
  13.  
If you want the top row to be featured, but still appear in the rest of the table, just remove the else.
Jul 11 '07 #4
Ajm113
161 New Member
Thanks! :)

P.S Sorry, if you seen that post report someone was messing around with my PC at the time.
Jul 11 '07 #5
pbmods
5,821 Recognized Expert Expert
Heya, Ajm.

Thanks! :)

P.S Sorry, if you seen that post report someone was messing around with my PC at the time.
No prob. Post back if you need anything.

And yeah, I think that happened b/c the 'Report' and 'Reply' buttons are so close together. I've made a note of that for the future.
Jul 11 '07 #6
Ajm113
161 New Member
Heya, Ajm.



No prob. Post back if you need anything.

And yeah, I think that happened b/c the 'Report' and 'Reply' buttons are so close together. I've made a note of that for the future.
Its like having the self destruct button in a way right next to make coffee button with the same colors and look.
Jul 12 '07 #7
pbmods
5,821 Recognized Expert Expert
I've posted a suggestion to this effect here. Feel free to add your thoughts.
Jul 12 '07 #8

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

Similar topics

19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
2
by: slitchfield | last post by:
Sorry if this is real beginner's stuff, but I'm an old-school HTML guy and this is all another world to me. Is there an easy way to get the user to specify a number from 1 to 5 (in a pick list...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
2
by: j.m.osterman | last post by:
I haven't found exactly what I've been trying to do. All I am trying to do for now is just display usernames from Active Directory into a ListBox control on a page. I have found some code...
3
by: WSPL5 | last post by:
I have a hidden span within a table column and I cannot unhide it using style.display='block' ?? Sample code <table> <tr> <td><input name="status" value=""></td><td><input type="button"...
3
by: dlamarche | last post by:
Hello I am new to PHP and I am reading the book Build you own database driven website using PHP and MySQL. I am trying something on my own as an exercise from the book. I sucessfully created a...
36
by: beebelbrox | last post by:
Hi, I am new VB programming in Access and I am requesting help with the following code. WIndows OS MSaccess 2003 This code is attached to an unbound form that will display a specific recordset...
8
by: stekk | last post by:
Question: How do I display/echo the values in page the selected values from drop down lists in page 2? I think this is the line that I have to add some code to make the values SELECTED. Any help is...
3
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a webform with several entry boxes and the user enters numbers in each box. I keep a running total (just adds all of the entries together) but am posting back to the server to do this. ...
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...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.