Hi guys
I'm fairly new to php but learning fast. Here's my problem. I have the code below in a website I made for my local pub, it works fine, but is ther a way to dynamically add another row to the table when the number of records displayed is more than 4. The thing is, anyone can add cards using another page so the way it works now, I have to keep looking at the db, and adding another query with higher 'LIMIT'. Can thi be done more simply?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta name="DESCRIPTION" content= "The Wembley Pub....Friendliest place in Limassol.">
<meta name="KEYWORDS" content= "The Wembley Pub, wembley pub, wembley bar, bars in limassol, limassol pubs, limassol entertainment, cyprus pub, limassol car hire, cyprus excursions, limassol bookshops, leauge football,cricket,televised sports">
<meta name="copyright" content="CoreMenu">
<meta name="distribution" content="Global">
<meta name="doc-class" content="Completed">
<meta name="doc-rights" content="Public">
<meta name="doc-type" content="Web Page">
<meta name="language" content="English">
<meta name="rating" content="Safe For Kids">
<link rel="stylesheet" type="text/css" href="styles.css">
<script language="JavaScript">
var goPopX = (screen.width/2)+50;
var goPopY = (screen.height/2)+50;
varloc = "left="+goPopX+"top="+goPopY;
function goPop(){
goPopWindow = window.open("adcompose.php","ads","width=625,height=550,scrollbars=no,location=1,toolbar=0,status=0");
}
function goPop2(){
goPopWindow = window.open("srvcompose.php","ads","width=625,height=330,scrollbars=no,location=1,toolbar=0,status=0");
}
</script>
</head>
<body class="background">
<div class="wrapper_top">
<br><br> </div>
<div class="wrapper" align="center">
<table width="990" border="1" bgcolor="#dcdcdc">
<tr>
<td height="120" topmargin="0" align="middle">
<img src="images/banner.jpg"width="990" height="120"></td>
</tr>
<tr>
<td valign="top" colspan="2">
<embed src="images/navbar9.swf" width="990" height="46"></td>
</tr>
</table>
<table border="0" width="990" height="100" background="images/fullback.jpg" align="center">
<tr>
<td class="head" align="center" colspan="8">Free Classified Ads Pages<hr width="80%" color="#000000"</hr></td>
</tr>
<tr>
<td class="text" align="center" colspan="8"> The page where you can place your ads for <u>FREE</u>, Articles for sale, Pets, Services, Etc; Click the 'ADD Advert' link button, fill in a simple registration form, and then start to advertise!<br /><br /></td>
</tr>
<tr>
<td align="center" colspan="8"> <form name="add" ><input type="submit" name="freeads" Value="Free Ads" onClick="goPop()"style="height: 25px; width: 100px"><input type="submit" name="services" value="Services" onClick="goPop2()" style="height: 25px; width: 100px"></form></td>
</tr>
<tr>
<td class="message"align="center" colspan="8"><a href="#services">Services</a> <a href="#sale">Articles for Sale</a> <a href="#wanted">Articles Wanted</a></td>
</tr>
<tr>
<td class="message" align="center" colspan="8"><a name="services">Services</a></td>
</tr>
</table>
<table border="0" width="990" align="center" background="images/fullback.jpg">
<tr>
<td width="990" align="left">
<?php
require_once ('config.php');
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password") or DIE(
"cannot connect");
mysql_select_db("$db_name") or DIE("cannot select DB");
echo "<table >";
echo "<tr>";
// First row query
$sql = "SELECT * FROM card LIMIT 4";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo "<td class ='advert' width='240' height='160' align='center' > ";
echo "<b>".$row['name']."</b>";
echo "<br>";
echo $row['busn'];
echo "<br>";
echo $row['code'];
echo "<br>";
echo $row['code2'];
echo "<br>";
echo $row['job'];
echo "<br>";
echo $row['job2'];
echo "<br>";
echo "</td>";
}
echo "</tr>";
//second row query
echo "<tr>";
$sql = "SELECT * FROM card LIMIT 4,4";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo "<td class ='advert' width='240' height='160' align='center' > ";
echo "<b>".$row['name']."</b>";
echo "<br>";
echo $row['busn'];
echo "<br>";
echo $row['code'];
echo "<br>";
echo $row['code2'];
echo "<br>";
echo $row['job'];
echo "<br>";
echo $row['job2'];
echo "<br>";
echo "</td>";
}
echo "</tr>";
//third row query
echo "<tr>";
$sql = "SELECT * FROM card LIMIT 8,4";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo "<td class ='advert' width='240' height='160' align='center' > ";
echo "<b>".$row['name']."</b>";
echo "<br>";
echo $row['busn'];
echo "<br>";
echo $row['code'];
echo "<br>";
echo $row['code2'];
echo "<br>";
echo $row['job'];
echo "<br>";
echo $row['job2'];
echo "<br>";
echo "</td>";
}
echo "</tr>";
//fourth row query
echo "<tr>";
$sql = "SELECT * FROM card LIMIT 12,4";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo "<td class ='advert' width='240' height='160' align='center' > ";
echo "<b>".$row['name']."</b>";
echo "<br>";
echo $row['busn'];
echo "<br>";
echo $row['code'];
echo "<br>";
echo $row['code2'];
echo "<br>";
echo $row['job'];
echo "<br>";
echo $row['job2'];
echo "<br>";
// echo $row['id'];
echo "</td>";
}
echo "</tr>";
echo "</table>";
mysql_close();
?>
</td>
</tr>
</table>
<table border="0" width="990" height="100" align="center" background="images/fullback.jpg">
<tr>
<td colspan="2" align="middle">
<hr color="black" width="80%">
<div class="footer"> Designed and Produced by TonyG Cyprus © 2009 E-mail <a href="mailto:tonygcyprus@gmail.com">tonygcyprus@gmail.com</a>
</div>
<hr color="black" width="80%"></td>
</tr>
</table>
</div>
<div class="wrapper_bottom">
<br><br>
</div>
</body>
</html>