Hello. I am new to php so you will have to forgive me if you find this easy, but please help. I have defined a function on line 231 called list_stock and I want to call it in my html on line 180 but it does not call it. I have tried wrappint the php signs around line 180 but to no avail. Please assist. Below is the code.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>DominicPhones - Register or Sign In</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
left:106px;
top:21px;
width:789px;
height:50px;
z-index:1;
}
#Layer2 {
position:absolute;
width:200px;
height:115px;
z-index:1;
}
#Layer3 {
position:absolute;
left:74px;
top:228px;
width:273px;
height:228px;
z-index:1;
}
#Layer4 {
position:absolute;
left:356px;
top:229px;
width:553px;
height:176px;
z-index:2;
}
#Layer5 {
position:absolute;
left:350px;
top:322px;
width:554px;
height:335px;
z-index:3;
}
#Layer6 {
position:absolute;
left:356px;
top:485px;
width:556px;
height:346px;
z-index:3;
}
#Layer7 {
position:absolute;
left:356px;
top:436px;
width:556px;
height:40px;
z-index:4;
}
.style10 {
color: #FFFFFF;
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
}
#Layer8 {
position:absolute;
left:73px;
top:491px;
width:272px;
height:122px;
z-index:5;
}
#Layer9 {
position:absolute;
left:73px;
top:620px;
width:228px;
height:213px;
z-index:6;
}
#Layer10 {
position:absolute;
left:112px;
top:561px;
width:766px;
height:34px;
z-index:7;
}
#Layer11 {
position:absolute;
left:113px;
top:601px;
width:752px;
height:39px;
z-index:8;
}
#Layer12 {
position:absolute;
left:90px;
top:212px;
width:787px;
height:43px;
z-index:1;
}
#Layer13 {
position:absolute;
left:115px;
top:291px;
width:752px;
height:263px;
z-index:2;
}
#Layer14 {
position:absolute;
left:115px;
top:256px;
width:749px;
height:26px;
z-index:3;
}
#Layer15 {
position:absolute;
left:115px;
top:286px;
width:282px;
height:180px;
z-index:4;
}
#Layer16 {
position:absolute;
left:115px;
top:215px;
width:748px;
height:40px;
z-index:5;
}
#Layer17 {
position:absolute;
left:112px;
top:185px;
width:755px;
height:24px;
z-index:6;
}
#Layer18 {
position:absolute;
left:114px;
top:15px;
width:751px;
height:164px;
z-index:7;
}
.style17 {font-family: Georgia, "Times New Roman", Times, serif}
.style18 {font-family: Geneva, Arial, Helvetica, sans-serif}
.style11 {color: #FFFFFF}
.style16 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; }
-->
</style>
<script type="text/javascript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body>
<form action="<?=$SERVER["PHP_SELF"]?>" method="post">
<div id="Layer13">
<table width="753" height="246" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><p> list_stock(); </p>
<p> Index Number:
<input type="text" name="itemindex"/>
<input type="submit" name="additem" value="Add"/>
<input type="submit" name="delitem" value="Remove"/>
</p></td>
</tr>
</table>
</div>
<div id="Layer14"><img src="register_banner.jpg" width="749" height="20" /></div>
<div id="Layer16">
<table width="661" height="27" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="account_banner.jpg" width="750" height="35" /></td>
</tr>
</table>
</div>
<div id="Layer17">
<table width="749" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="187" height="23" bgcolor="#69C7EB" class="style10"><div align="center"></div></td>
<td width="116" bgcolor="#69C7EB" class="style10"><div align="center"><a href="index.html">Home Page</a> </div></td>
<td width="103" bgcolor="#69C7EB"><div align="center"><span class="style10">Contact Us </span></div></td>
<td width="73" bgcolor="#69C7EB" class="style10"><div align="center">Admin</div></td>
<td width="106" bgcolor="#69C7EB" class="style10"><div align="center"><a href="login.php">My Account</a> </div></td>
<td width="157" bgcolor="#69C7EB" class="style10"><div align="center">Shopping Cart </div></td>
</tr>
</table>
</div>
<div id="Layer18"><img src="main_banner.jpg" width="750" height="170" /></div>
<p align="center"> </p>
<div id="Layer11">
<div align="center"><img src="payments.jpg" width="400" height="90" /></div>
</div>
<div id="Layer10">
<table width="761" height="25" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="154" bgcolor="#65BFE1" class="style11"><div align="center" class="style16"><a href="pda_smartphones.html">PDA/Smartphones</a></div></td>
<td width="145" bgcolor="#65BFE1" class="style11"><div align="center" class="style16"><a href="contract_phones.html">Contract Phones</a> </div></td>
<td width="146" bgcolor="#65BFE1" class="style11"><div align="center" class="style16">Sim Free Phones </div></td>
<td width="81" bgcolor="#65BFE1" class="style11"><div align="center" class="style16">SAT NAV </div></td>
<td width="103" bgcolor="#65BFE1" class="style11"><div align="center" class="style16">Accessories</div></td>
<td width="126" bgcolor="#65BFE1" class="style11"><div align="center" class="style16">Entertainment</div></td>
</tr>
</table>
</div>
<p align="center"> </p>
</body>
</html>
<?php
function list_stock()
{
//Display stock table
$conn=connect();
$res_table=mysql_query("SELECT * FROM Stocks");
if ($res_table)
{
print("<table border='1'><thead><th>Index</th><th>Make</th><th>Model</th><th>Price</th><th>Number</th></thead><tbody>");
while ($item_array=mysql_fetch_array($res_table))
{
extract($item_array);
print("<tr><td>$indx</td><td>$make</td><td>$model</td><td>$price</td><td>$number</td><tr>");
}
print("</tbody></table>");
}
disconnect($conn);
}
function update($index,$number)
{
//Update quantity of an item in stock
$conn=connect();
mysql_query("UPDATE Stock SET number='$number' WHERE indx='$index'");
disconnect($conn);
}
function connect()
{
//Connect to database
$connection=mysql_connect("server","username","pw");
mysql_select_db("ku12881",$connection);
return $connection;
}
function disconnect($connection)
{
//Disconnect from database
mysql_close($connection);
}
?>