I am graduating this June, so before that I want to prepare myself for working in the industry :)
My Question:
For example I want to list all the songs in the table using a list box and this is how I implemented it:
playlist.php
<tr id='' >
<td width="" class=""> <font color=#00000 />Select Songs</td>
<td width="" colspan="">
<select size='25'multiple='multiple' id="select_songs" name="playlist_songs[]">
<?php
display_songs_list();
?>
</select></td>
</tr>
and I have a seperate php_functions.php file where I have implemented all the php functions
function display_songs_list(){
$query = "select * from songs order by ID asc";
$result = mysql_query($query);
if(!$result)
echo "<script language = 'javascript'>alert('$result Sorry couldn't connect to the database...');</script>";
else{
$num_rows = mysql_num_rows($result);
if($num_rows > 0){
while($row = mysql_fetch_array($result)){
$ID = $row['ID'];
$title = $row['title'];
$value = $ID.'_'.$title;
echo "<option id=\"$ID\" value=\"$value\">$ID : $title</option>";
}
}
}
}
Is this way of implementation recommended. What else I can do to increace the scalability/maintainability/re-usability. please guide me on this. Is it recommended to follow any industry coding standards, if so what you perfer. Thank you.
color=#00000) are deprecated and kill kittens. Learn about CSS. is not desirable either if it doesn't add any meaning, learn to add spacing using CSS.echoing either HTML or Javascript from the same function is bad. The Javascript alert will cause invalid HTML syntax at the point you're calling the function.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With