Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5848321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:50:33+00:00 2026-05-22T12:50:33+00:00

Greetings! This is my first question. I’ve searched all over the web as well

  • 0

Greetings! This is my first question.

I’ve searched all over the web as well as on SO, but I believe it is too specific for me to find an answer. I’m guessing my code may need a logical rebuild.

Background of problem:

I am building a simple site containing user-editable inventory data (a list of used RVs) for a friend’s business. This is basically my first big project with php, well, ever, and I’m on a tight deadline (we’re in season right now!), so my code is absolute filth. To add to that, I’m mixing procedural and object-oriented programming like a nutjob.

Explanation of problem:

Some of the data in the MySQL table “rv_list” – namely, the ‘status’ and the ‘condition’ fields (see attached screenshot to get a clearer idea), are currently being stored as 1-digit integers.

I thought that it would be very easy to (using php regex or something) later convert these numbers to strings, as they were on the input form. As it turns out, with the method I finally settled on outputting the data, I cannot find a way to convert them after the select statement is done.

Code:

<?php
//unfinished query - "condition" is the column in the db table that I'd like to change, "status" will also need to be changed in a similar way for the outward-facing public-viewed list
$query = 'select * from rv_list where status="1" or status="2" order by modified desc';
$rvfieldquery = 'show columns from rv_list';
$result = $conn->query($query);

//check on the status of our query
if ($result)
{
//begin output of html table, followed by a loop for rows, and within, a nested loop for the datacells.
//based on function 3: http://www.barattalo.it/2010/01/29/10-php-usefull-functions-for-mysqli-improved-stuff/
    echo '<table>';
    echo '<th>Edit Status</th>';
    while ($field = $result->fetch_field())
    {
        echo '<th class="columntitle">'.$field->name.'</th>';
    }
    echo '<th>DELETE</th>';
    $shadecounter = 0;
    while ($row = $result->fetch_assoc())
    {
        //shade every other row for usability       
        $shadecounter++;
        if (is_float($shadecounter/2)) $shade = "lightgray"; 
        else $shade = "white";      
        echo '<tr style="background:'.$shade.';">';
        //Get rv_id key, attach to name of edit and delete buttons
        echo '<td><input type="submit" name="edit '.$row['rv_id'].'" value="Edit"></input></td>';
        //Insert row data
        foreach ($row as $td)
        {
        //PROBLEM AREA HERE! - can I do an if statement or something here to check what column $td comes from?  Confused.
        echo '<td class="data">'.$td.'</td>';
        }
        //for delete record button, off-screen on right side of each record
        echo '<td><input style="background:red;" type="submit" name="del '.$row['rv_id'].'" value="DELETE"></input></td>';
        echo '</tr>';
    }
    echo '</table>';
}
else
{
exit;
}

Output Screenshot (check highlights):

https://i.stack.imgur.com/N8P8r.jpg

Extra Information:

Key to the status integer list (rather, what I would like it to display):

  1. Available
  2. On Hold
  3. Sold / Deactivated

Key to the condition integer list:

  1. New
  2. Used – Excellent
  3. Used – Good
  4. Used – Fair
  5. Used – Poor

Please let me know if I have forgotten anything crucial in describing this problem.

Last but not least, thank you very much for your time spent reading this question!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:50:34+00:00Added an answer on May 22, 2026 at 12:50 pm
    $status_map = array(1 => 'Available', 2 => 'On Hold', 3 => 'Sold / Deactivated');
    $condition_map = array(1 => 'New', 2 => 'Used - Excellent', 3 => 'Used - Good', 4 => 'Used - Fair', 5 => 'Used - Poor');
    
    foreach ($row as $colname => $value)
    {
        if($colname == 'status')
            $value = $status_map[$value];
    
        if($colname == 'condition')
            $value = $condition_map[$value];
    
        echo '<td class="data">'.$value.'</td>';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings to all! This is my first question here on stackoverflow. I have a
Greetings everyone. This is my first question here at stackoverflow so please bear with
Greetings, this is my very first question and I just do programming as a
Greetings all, This has confused me ever since I first started coding in C#.
Greetings Guru's, This is a little hard to explain, but I'll give it a
Greetings everybody. I am sorry, if this was already asked before (searched in vain)
Greetings, I've got a query that I'm struggling with, this is the first time
Greetings, I have the following question. I did not find the exact answer for
Greetings all, I realize this issue has been posed before in other forms, and
Greetings I'm trying to find a way using Linq-to-SQL to get the first 15

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.