简体   繁体   中英

php , mysqli fetch data from table using button

I stuck at point... How to fetch a data from single row diplayed in table format?

Here is my code:

$raw = mysql_query("SELECT * FROM tbl");
$allresults = mysql_fetch_array($raw);

while($raw  = mysql_fetch_assoc($allresults)){
     echo $row['your field name here'];
     echo "input type="submit" value="view"";
}

I have to fetch data of particular field using button provided next to row variable.

$mysql = new mysqli("host", "user", "password", "DatabaseName");
$raw = $mysql->query("SELECT * FROM tbl");
while($someVariable = $raw->fetch_assoc()) {
 echo "$someVariable[field]";
}

You don't need to call both mysql_fetch_array() and mysql_fetch_assoc() functions.

Try something like this:

$allResults = mysql_query("SELECT * FROM tbl");
while($row  = mysql_fetch_assoc($allResults)){
     echo $row['your field name here'];
}

This should work!

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