tomks77 Posted May 19, 2013 Share Posted May 19, 2013 First, we (beginners) are sorry that we cant answer other topics to help...we only make topics to ask for help.....who knows...maybe someday.. i have some textboxes where user can enter name, city, fone..and a button to save the informations to the database.. now there is a button 'Show', that shows all the records. Or one specific record in a html table in the same page of the textboxes, the problem, is that the table, with the records, is displayed in the top of the pageand the textboxes go down to the end of the page, so how can i keep the textboxes in the top of the page and print the table under it? Link to comment Share on other sites More sharing options...
niche Posted May 19, 2013 Share Posted May 19, 2013 (edited) There are many answers to your question. The general asnswer is positioning with CSS. Please post your current code for a more specific answer. EDIT: I'm unsure why you posted your topic in the php forum? Edited May 19, 2013 by niche Link to comment Share on other sites More sharing options...
jeffman Posted May 19, 2013 Share Posted May 19, 2013 Perhaps you are unaware that you can embed PHP tags anywhere inside a document? They don't have to be at the top. Also, there can be multiple PHP tags in a single document, and they all share the same global space. This means that you can execute code at the top of the document, and any variables declared there will be available in the middle of the document. So you can easily run some code at the top, then output a bunch of HTML, and then execute some more PHP and use it to output different HTML, and so on. I can't tell if that solves your problem. I just thought I'd throw something out there that sounded close. 1 Link to comment Share on other sites More sharing options...
tomks77 Posted May 19, 2013 Author Share Posted May 19, 2013 I have this code like this: <html><head><title> some thing </title> <?PHP $user="root";$password="";$server= "1.1.1.1."; $db_handle=mysql_connect($serve,$user,$password);$db_found=mysql_select_db($database,$db_handle); if ($db_found){ if(isset($_POST['sub_show'])){ $SQL2 = "SELECT * FROM costumers ";$result2 = mysql_query($SQL2); print "<table border='2' align ='center'><tr><th bgcolor=#808080><b>ID</b></th><th bgcolor=#808080>Name</th><th bgcolor=#808080>City</th><th bgcolor=#808080>Fone</th><th bgcolor=#808080>E-Mail</th><th bgcolor=#808080>Since</th></tr>"; while ( $db_field = mysql_fetch_assoc($result2) ) {print "<tr>"; print "<td bgcolor=#C0FFC0 >" ."<font color=#FF0000>"."<b>" . $db_field['ID'] . "</b>". "</font>" ."</td>"; print "<td bgcolor=#C0FFC0>" ."<b>". $db_field['name'] . "</b>"."</td>"; print "<td bgcolor=#C0FFC0>". "<b>". $db_field['city'] . "</b>"."</td>"; print "<td bgcolor=#C0FFC0>". "<b>". $db_field['fone'] ."</b>". "</td>"; print "<td bgcolor=#C0FFC0>"."<b>". $db_field['e_mail'] . "</b>"."</td>"; print "<td bgcolor=#C0FFC0>"."<b>". $db_field['date'] . "</b>"."</td>"; print "</tr>"; } print "</table>"; ?> </head><body> <form name=form1 method=POST action"page.php"> <input type="text" name="name" value=""><input type="text" name="city" value=""><input type="text" name="fone" value=""> <input type = "submit" name="sub_save" value="save"><input type = "submit" name="sub_show" value="show"></form</body></html> So the table in the PHP code is displayed on the top of the page and the textboxes and the butons goes down to the end of the page i want to display the table down..to the end, and my textboxes remain on top Link to comment Share on other sites More sharing options...
niche Posted May 19, 2013 Share Posted May 19, 2013 Where's your CSS? Link to comment Share on other sites More sharing options...
jeffman Posted May 19, 2013 Share Posted May 19, 2013 (edited) The easiest thing is to move all that PHP, with the opening and closing <?php ?>tags, after the closing </form> tag. An alternative is to save the table to a string variable instead of printing it right away. (That's better practice than a lot of print/echo statements anyway.) Use the concatenation operator to build the string one piece at a time: $myTableString = ""; // to initialize it$myTableString .= "Hello";$myTableString .= "next part";$myTableString .= "some more";$myTableString .= "bye." Then simply echo it where you want the table to be: </form><?php echo $myTableString ?></body> Edited May 19, 2013 by Deirdre's Dad Link to comment Share on other sites More sharing options...
tomks77 Posted May 20, 2013 Author Share Posted May 20, 2013 'Deirdre's Dad' The easiest thing is to move all that PHP, with the opening and closing <?php ?>tags, after the closing </form> tag. ---------------- well i moved the code and put it after the form tags..and it worked... now the elements stay up on the top of the page...and the table is printed under them.. thank you...for the help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now