简体   繁体   中英

Rename returned ID's from the database PHP

I'm wondering if there's a way to define ID's returned from the database.I have a table called vehicles where it stores vehicle model ID.I return that id thgrough a loop because that table is connected to a user.The user car have more than one vehicle to his name.So I show that user his car's in the UCP.But what it show's me is the vModel ID.Is there any possible way of changing those ID's that come from the database to, let's say vModel ID=100 and in the UCP the script show's to that user not the ID, but a defined value...let's say Lorem Ipsum...

Now it's like this:

Your vehicles - 142 , 162 , 155 etc.

And what I need without changing the database structure:

Your vehicles - Ford , Bmw etc.

UPDATE

These commands may be old and outdated but I'm just learning and doing this for my own usage. My query:

$autoget = mysql_query("SELECT vModel FROM vehicles WHERE vOwner='$usernameshow' ");
echo'<li>Your vehicles:&nbsp';
while($autoshow = mysql_fetch_assoc($autoget))
{
echo'<div class="raudona-box">'.$autoshow['vModel'].'</div>&nbsp ';
}

My database structure: http://i.imgur.com/lNX5Q7d.png -- cant post images :(

Now that you have a table with the models:

SELECT m.model FROM vehicles v LEFT JOIN vmodel m ON v.vModel = m.ID WHERE vOwner='$usernameshow'

The column names would change based on your own database structure

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM