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?
How to display a result uptop if it has the value of one?
Collapse
X
-
Heya, Ajm113.
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.Originally posted by Ajm113I want to display a row with a value of 1 up top I guest...
Once you're done loading results, check for the top variable and output it.
Expressed as code:
[code=php]
$data = array();
while($row = mysql_fetch_ass oc($result)) {
if($row['desiredField'] === 'desiredValue')
$top = $row;
else
$data[] = $row;
}
if(isset($top))
// Display the top row.
// Display the other rows.
[/code]
If you want the top row to be featured, but still appear in the rest of the table, just remove the else.Comment
-
Heya, Ajm.
No prob. Post back if you need anything.Originally posted by Ajm113Thanks! :)
P.S Sorry, if you seen that post report someone was messing around with my PC at the time.
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.Comment
-
Its like having the self destruct button in a way right next to make coffee button with the same colors and look.Originally posted by pbmodsHeya, 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.Comment
Comment