简体   繁体   English

从数据库PHP重命名返回的ID

[英]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... 我不知道是否有一种方法来定义的ID从database.I返回有一个表叫vehicles ,其中存储有车辆模型ID.I返回ID thgrough一个循环,因为该表连接到user.The用户的车有更多的比一辆车给他name.So我表明用户自己的汽车公司在UCP.But它所展现的我是vModel ID.Is有改变这些ID的是来自于数据库中,让我们说的任何可能的方式vModel ID=100并且在UCP中,脚本向该用户显示的不是ID,而是给定的值...比方说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 :( 我的数据库结构: http : //i.imgur.com/lNX5Q7d.png-无法发布图片:(

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 列名称将根据您自己的数据库结构而变化

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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