简体   繁体   中英

get a single row from mysql in php

I have a mysql database with the data setup in categories, each category has a number of rows in it. What I need to do is get each row one at a time within a category. here is the setup: col 1 col 2 col3... cat1 number title... cat1 number title... cat1 number title... cat1 number title... cat2 number title... cat2 number title...

Number and title are key fields I want to display the rows in each category ordered by title. My initial query looks like

$query1 = "SELECT * from art where category = 'Florals'"; 
$result1 = mysqli_query($connect1,$query1) or die("mysqli_error());
$row1 = mysqli_fetch_assoc($result1);

I use the info captured in $row1. I have been unable to display the records in order. Can anyone help?

Doesn't this work for you?

while( $row = mysqli_fetch_assoc($result1) )
{
    print_r($row);
}

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