php - Only displays one item from array -


i trying echo list of items gather array displays 1 item when use code

$sqli = mysqli_query($db_conx, "select url_name provtour order created desc limit 10"); while($row = mysqli_fetch_array($sqli)) { $urlname = $row['url_name'];  } <div><center><?php echo '<a href="etournament.php?n=' . $urlname . '">' . $urlname . '</a>'; ?></center></div>  ?> 

i know <center> should in css using here test purposes before move echoed array main style of website. above code echos out 1 input when there 7 inside database.

$sqli = mysqli_query($db_conx, "select tourname , url_name provtour order created desc limit 10"); while($row = mysqli_fetch_array($sqli)) { $tourname = $row['tourname']; $urlname = $row['url_name'];  } <div><center><?php echo '<a href="etournament.php?n=' . $urlname . '">' . $tourname . '</a>'; ?></center></div> 

when use above code brings

notice: undefined index: url_name in notice: undefined index: tourname in 

for each row have 7 of each errors showing on page.

$sqli = mysqli_query($db_conx, "select * provtour order created desc limit 10"); while($row = mysqli_fetch_array($sqli)) { $tourname = $row['tourname']; $urlname = $row['url_name'];  } <div><center><?php echo '<a href="etournament.php?n=' . $urlname . '">' . $tourname . '</a>'; ?></center></div> 

when use above code echo's out 1 line again.

if point out going wring appreciate much.

ideally gather tourname url_name thank you.

put echo inside while:

echo '<div><center>'; $sqli = mysqli_query($db_conx, "select * provtour       order created desc limit 10"); while($row = mysqli_fetch_array($sqli)) {     echo '<a href="etournament.php?n=' . $row['url_name'] . '">' .           $row['url_name'] . '</a>'; } echo '</center></div>'; 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -