function showdata () {
Posted: Sun Oct 24, 2004 2:17 am
I dont even know if I can use the function () to do what I want .. At the moment I have say 20 pages .. the only thing that changes is the query .. I want to beable to create a page as shown below .. adding all 20 querys to the one page .. So its easy to maintain and obviously dont have 20+ pages to deal with.. Then call back any query by just using a link ie: http://www.blabla.com/products.php?action=lawnmower
Am I on the right track .. can function () acheive this?
When I goto url http://www.blabla.com/products.php?action=lawnmower .. I get no errors .. and a blank page .. when using the entire code in one page .. with out using funtion () it works fine.
Can anyone help push me in the right direction to acheive this?
Cheers
Am I on the right track .. can function () acheive this?
Code: Select all
<?php
function showdata (){
echo "<br><center><font face="verdana" size="1" color="black">$totalEntries Products Listed</center></font><br>";
if($row["links"]!=NULL){
$url_display="<img src=".$row["links"].">";
}else{
$url_display="No Preview";
}
echo "<table width="90%" height="146" border="1" align="center" cellpadding="5" cellspacing="1" bordercolor="000000">
<tr>
<td height="18" colspan="4" valign="middle" bgcolor="#0099CC">
<div align="left"><color="FFFFFF"><strong>$row[product]</strong></div></td>
</tr>
<tr>
<td width="20%" rowspan="4"><div align="center">$url_display</td>
<td width="80%" height="89" colspan="3" valign="top" background="../square.bmp">$row[desc]</td>
</tr>
<tr>
<td width="147" nowrap background="../square.bmp" div align="center"><font face="verdana" size="1">PART No: $row[name]</font></div></td>
<td width="151" height="10" nowrap background="../square.bmp" div align="center"><font face="verdana" size="2" color="FF0000">$$row[price]</font></div></td>
<td width="147" nowrap background="../square.bmp" div align="center"><font face="verdana" size="1"><a href="http://www.blabla.com/cart.php?action=add_item&id=$row[itemId]&qty=1">ADD
ITEM</a> - <a href="http://www.blabla.com/cart.php">VIEW CART</a></font></div></td>
</tr>
</table><br>";
}
// --------------------------------------------------------------------------------- lawnmower
function lawnmower (){
include("db.php");
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("select * from items where filter='lawnmower'");
$totalEntries = mysql_num_rows($result);
while($row = mysql_fetch_array($result)) {
showdata ();
}
}
// --------------------------------------------------------------------------------- weedeater
function weedeater (){
include("db.php");
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("select * from items where filter='weedeater'");
$totalEntries = mysql_num_rows($result);
while($row = mysql_fetch_array($result)) {
showdata ();
}
}
?>Can anyone help push me in the right direction to acheive this?
Cheers