gpt4 book ai didi

php - 如何将百分号添加到从sql查询输出的字符串值

转载 作者:可可西里 更新时间:2023-10-31 23:07:12 29 4
gpt4 key购买 nike

这可能比我想象的要简单,但我真的很难理解这个问题。在中断 10 年后,我一直在努力学习如何编码,所以黑客和代码学院是我的老师。无论如何,...

我想做的只是简单地将一个 sql 条目中的整数变成一个百分比。

我有一个表单,在提交时输入一个用于输出 css 值的 sql 值整数。我只是想将宽度值从一个整数更改为一个百分比,以允许一些类似的响应效果。

这是 php 的预输出:

        <video id="vp2_html5_rightSidePlaylist_'.$row["id"].'" width="'.$row["playerWidth"].'%" height="'.$row["playerHeight"].'" '.$preload_aux.'><div class="xplaylist">'.$playlist_str.'</div></video>

输出如下:

        <video id="vp2_html5_rightSidePlaylist_1" width="100" height="297" preload="auto" src="http://localhost:888/test.mp4">

在此先感谢您的帮助!

最佳答案

如果您使用的是 mysql,则可以使用 CONCAT() function在特定字段的末尾添加一些字符。

CONCAT(str1,str2,...) - Returns the string that results from concatenating the arguments.

例如——

SELECT `id`,`title`,CONCAT(`percentage`,'%') as percentage FROM `items` LIMIT 100

现在,percentage 字段中存储的任何值都将在结果集中附加一个 % 字符。

关于php - 如何将百分号添加到从sql查询输出的字符串值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14176814/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com