<?php
$query = "SELECT text FROM config WHERE name = 'ticker'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
echo $row['text'];
}
?>
Do i need to use a while loop if i'm not exactly running through lots of rows? In this case 'ticker' is just specific one line of text being returned from the database.
Also, what if i wanted to grab the text from 'page_title' and 'footer'
Do i need to use that same code at each point in the page, in this case it would be at 3 locations, the the title, the ticker and the footer.
$query = "SELECT text FROM config WHERE name = 'page_title'";
$query = "SELECT text FROM config WHERE name = 'footer'";
Can it not be made into 1 query at the top of the page then just call everything as and when it's needed? Surely i don't need 3 queries for 3 lines of text.
Question
game_over
<?php $query = "SELECT text FROM config WHERE name = 'ticker'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo $row['text']; } ?>Do i need to use a while loop if i'm not exactly running through lots of rows? In this case 'ticker' is just specific one line of text being returned from the database.
Also, what if i wanted to grab the text from 'page_title' and 'footer'
Do i need to use that same code at each point in the page, in this case it would be at 3 locations, the the title, the ticker and the footer.
$query = "SELECT text FROM config WHERE name = 'page_title'";
$query = "SELECT text FROM config WHERE name = 'footer'";
Can it not be made into 1 query at the top of the page then just call everything as and when it's needed? Surely i don't need 3 queries for 3 lines of text.
Still learning :)
Link to comment
Share on other sites
2 answers to this question
Recommended Posts