简体   繁体   English

如何使用Node.js和ExpressJS在mysql上显示数据

[英]How can I show data on mysql with nodejs and expressjs

app.js app.js

function showConnect(req, res){

    mysql_crawl.query('SELECT full_price, discount_price, quantity, prod_link, images, prod_desc, status FROM `catalogsearch_fulltext` WHERE MATCH(data_index) AGAINST("ครีม") LIMIT 0 , 10', function(error, rows){
    res.render('product.html',{related: rows})

    })

product.html product.html

<%
for (var i of related){
%>
<%= i %>
<%
    }
%>

result on product.html product.html上的结果

[object Object] [object Object]

How can i show all of each data in product.html (full_price, discount_price, quantity, prod_link, images, prod_desc) 如何显示product.html中的所有每个数据(完整价格,折扣价格,数量,产品链接,图像,产品说明)

[object Object] is the default toString result. [object Object]是默认的toString结果。 What you can do is use JSON.stringify() or explicitly state what you want to display, like i.quantity, i.image etc. 您可以使用JSON.stringify()或明确声明要显示的内容,例如i.quantity,i.image等。

<table>
<% for(var i=0; i < related.length; i++) { %>
   <tr>
     <td><%= related[i].full_price %></td>
     <td><%= related[i].discount_price%></td>
   </tr>
<% } %>
</table>

暂无
暂无

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

相关问题 如何在NodeJS / ExpressJS / Passport中显示登录的用户名? - How to show logged on username in NodeJS/ExpressJS/Passport? 如何在 NodeJS (expressJS) 中暂停 MySQL 数据库事务? - How to pause a MySQL database transaction in NodeJS (expressJS)? 如何在expressjs /会话NodeJS中保存数据 - How to save data in expressjs/session NodeJS 如何使用 REACTJS、NODEJS、EXPRESSJS 和 MONGODB 中的 API 进行 POST 数据? - How can do POST data using API from REACTJS ,NODEJS,EXPRESSJS AND MONGODB? 通过NodeJS获取JSON数据时,如何通过ExpressJS更新我的EJS模板? - When getting JSON data via NodeJS, how would I update my EJS template via ExpressJS? 均值堆栈:如何使用nodejs expressjs和angular 6在mongodb中存储图像? - Mean Stack: How can I store image in mongodb with nodejs expressjs and angular 6? 如何获得Codeship通过Heroku上的nodejs expressjs部署的check_url阶段? - How can I get Codeship to pass the check_url phase of a nodejs expressjs deployment on Heroku? 我如何使用 mongoose 聚合找到最常出现的用户 ID,它位于 [] 内? Nodejs,Expressjs - How can i find most occuring userId, which lies inside [] using mongoose aggregation ?? Nodejs, Expressjs 如何使用expressjs将数据从一个路由传递到另一个nodejs - How to pass data from one route to another nodejs with expressjs 如何使用Node.js,Express.js从MongoDB中获取数据 - How to fetch data from mongodb using nodejs, expressjs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM