Hi,

I am very new to php still trying to find my way around it, i got this code which will pull everything off my database and display in one endless table across the page is there a way i can split it and display.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<p>

<table border="1" bordercolor="black" cellpadding="3">
  
<?php

$db_connect="localhost";
$db_username="xxxx";
$db_password="******";
$db_name="xxx****";

$link=mysql_connect($db_connect,$db_username,$db_password);

$db_select=mysql_select_db($db_name);

if ($db_select) {

print "database connected";

}else{

print "not connected";

}

//print "<table>";

$record_set=mysql_query("SELECT * FROM tableToDisplay");




for($c=0; $c<mysql_num_fields($record_set);$c++){
print"<th>".mysql_field_name($record_set,$c)."</th>";
}

while ($record=mysql_fetch_row($record_set)){
print"<tr>";

for($c=0; $c<mysql_num_fields($record_set);$c++){
print "<td>".$record[$c]."</td>";

}
print "</tr>";

}

//print"</table>";

mysql_close($link);

?>
</table>
</body>
</html>

How do you want to split it ?

I dont know since i am new to php..not sure what else it can do..can you suggest for me please of how i can show it.

Currently i have about 25 columns of results displaying.

I guess you want to display some (say 10) records at a time and a button, called next to display the next 10 records ? Search for pagination in google. You will find some examples.

I guess you want to display some (say 10) records at a time and a button, called next to display the next 10 records ? Search for pagination in google. You will find some examples.

Thanks a lot.

Hello Again,

I have another request, again i just need some direction and i can take it from there.

Have you been to monster.com there they ask you to add experiences...like you key in the first experience then if you have another you have to click a button to add more experience. the page then loads again with the first work experience that you entered with the new one with boxes for you to fill in, any idea how to do it or what it is called.

Thanks a lot for all the help.

Check this example to add html elements dynamically.
http://www.dustindiaz.com/add-and-remove-html-elements-dynamically-with-javascript/
When the page is reloaded on submit, you can have the previous value by assigning $_POST as value. For example, <input type="text" name="name" value="<?php echo $_POST['name']; ?>"> will retain the value entered in the textbox on submit.

Hi Again,

I have this html table with elements in it...i am not able to figure out how i can add another table like that by clicking on the add another reference button.

So sorry...i have tried so much but still not able to figure out how.
please help.

Thanks.

<table width="1000" border="0" align="center" cellpadding="3" cellspacing="0" style="border:1px solid #999999;" >
<div id="myDiv"></div>

<input type="hidden" value="0" id="theValue" />

  <tr>
    <th height="30" colspan="2" bgcolor="#ff9933" class="BodyTextHeaders" scope="col"><div align="left">* Referee 2</div></th>
  </tr>
  <tr>
    <th width="362" class="BodyTextHeaders" scope="col"><div align="left"><div class="BodyText">* Name of
    Referee : </div></div></th>
    <th width="624" class="BodyTextHeaders" scope="col"><div align="left"><span class="BodyText">
      <input name="t_ref_email5" type="text" class="BodyText"
		style="color: 000000 ; font-weight: bold; text-transform:mixedcase" value=" " size="50" maxlength="50">






    </span></div></th>
  </tr>
  <tr>
    <th class="BodyTextHeaders" scope="col"><div align="left"><span class="BodyText">* E-Mail Address
    : </span></div></th>
    <th class="BodyTextHeaders" scope="col"><div align="left"><span class="BodyText">
      <input name="t_ref_email6" type="text" class="BodyText"
					style="color: 000000 ; font-weight: bold; text-transform:mixedcase" value="

" size="50" maxlength="50">
    </span></div></th>
  </tr>
  <tr>
	
    <th height="50" colspan="2" class="BodyTextHeaders" scope="col"><a href="javascript:;"> <input type="button" class="BodyText" onclick="addEvent();" value="Add More Referee's"> </a></th>
  </tr>

</table>
<html>
<head>
<script type="text/javascript">
function addElement() {
  var ni = document.getElementById('myDiv');
  var numi = document.getElementById('theValue');
  var num = (document.getElementById('theValue').value -1)+ 2;
  numi.value = num;
  var newinput = document.createElement('input');
  var divIdName = 'my'+num+'input';
  newinput.setAttribute('id',divIdName);
  newinput.innerHTML = 'Element Number '+num+' has been added! <a href=\'#\' onclick=\'removeElement('+divIdName+')\'>Remove the div "'+divIdName+'"</a>';
  ni.appendChild(newinput);
}
</script>
</head>
<body>
<input type="hidden" value="0" id="theValue" />
<p><a href="javascript:;" onclick="addElement();">Add Some Elements</a></p>
<div id="myDiv"> </div>
</table>
</body>
</html>

To add another table, you need to modify the function.

This article has been dead for over six months. Start a new discussion instead.