ValdouaD Posted June 8, 2006 Share Posted June 8, 2006 I have a store locatior on my website. I want to have it all centered on the page buit I cant figure out how.Below is my input area where the customer would either put in theor zip code or state.[code] <?// Page 1, the formecho "<div style=\"margin-left: 15pt;\"><form name=\"search\" action=\"spage2.php\" method=\"post\">Search by Zip: <input type=\"text\" name=\"zipCode\"> (example: 01922)<br>Search by State: <input type=\"text\" name=\"state\"> <input type=\"submit\"> (example: NY for New York)<br></form></div>";?>[/code]Here is the results area...which is on a differnt page. Here I have the same problem everything is flsuh left and I want it to be centered on the page like it was in its own table. Code is below:[code]<?// Page two, search and display$connect = mysql_connect("localhost", "XXXXX", "XXXXX");$db = mysql_select_db("schylling_storelist", $connect);$sql = "SELECT *FROM STOREDATAWHERE State = '".$_POST['state']."'OR ZIP_Code = '".$_POST['zipCode']."'";$result = mysql_query($sql);$rows = mysql_num_rows($result);if($rows > 0) {echo "<table border=\"1\"><th align=\"center\newstyle\">Name</th><th align=\"center\">City</th><th align=\"center\">State</th><th align=\"center\">Sales Phone</th>";while($row=mysql_fetch_array($result)) {echo "<tr><td align=\"center\" class=\"newstyle\">".$row['Name']."</td><td align=\"center\" class=\"newstyle\">".$row['City']."</td><td align=\"center\" class=\"newstyle\">".$row['State']."</td><td align=\"center\" class=\"newstyle\">".$row['Sales_Phone']."</td></tr>";}}else {echo "No results found";} [/code]Is there an easy way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/11503-centering-forms-on-page/ Share on other sites More sharing options...
trq Posted June 8, 2006 Share Posted June 8, 2006 Firstly... multiposting is a big no no. Secondly, your question has nothing to do with php. Its a html problem.[a href=\"http://www.w3schools.com\" target=\"_blank\"]Here[/a] is a nice html tutorial. Quote Link to comment https://forums.phpfreaks.com/topic/11503-centering-forms-on-page/#findComment-43281 Share on other sites More sharing options...
kenrbnsn Posted June 8, 2006 Share Posted June 8, 2006 Actually, it can be done quite easily using CSS. It has nothing to do with PHP.Ken Quote Link to comment https://forums.phpfreaks.com/topic/11503-centering-forms-on-page/#findComment-43283 Share on other sites More sharing options...
ValdouaD Posted June 8, 2006 Author Share Posted June 8, 2006 Sorry about the double posting....my bad!I was under the assumtion that if I used an html table and put all thatcode in the table it wouldnt work.I have tried this and have gotten a lot of parser errors which I assumed was from the PHP code? Quote Link to comment https://forums.phpfreaks.com/topic/11503-centering-forms-on-page/#findComment-43303 Share on other sites More sharing options...
.josh Posted June 8, 2006 Share Posted June 8, 2006 i see no immediate parse errors in that block of code you provided (although, i wouldn't really recommend the style you used for echoing..it's technically correct). can you post the actual error and line number, and the code around the line number? Quote Link to comment https://forums.phpfreaks.com/topic/11503-centering-forms-on-page/#findComment-43308 Share on other sites More sharing options...
ValdouaD Posted June 8, 2006 Author Share Posted June 8, 2006 Here is the error I get when I place this into a table:Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /var/www/html/store_finder.php on line 247Here is the code view [code]<div align="center"> <center> <table border="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1"> <tr> <td width="100%"><?// Page 1, the formecho "<div style=\"margin-left: 15pt;\"><form name=\"search\" action=\"spage2.php\" method=\"post\"><p style="margin-left: 200">Search by Zip: <input type=\"text\" name=\"zipCode\" size="20"> (example: 01922)<br>Search by State: <input type=\"text\" name=\"state\" size="20"> <input type=\"submit\" size="20"> (example: NY for New York)<br></p></form></div>";?></td> </tr> </table> </center></div>[/code]{ Quote Link to comment https://forums.phpfreaks.com/topic/11503-centering-forms-on-page/#findComment-43317 Share on other sites More sharing options...
.josh Posted June 8, 2006 Share Posted June 8, 2006 <div align="center"> <center> <table border="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1"> <tr> <td width="100%"><?// Page 1, the formecho "<div style=\"margin-left: 15pt;\"><form name=\"search\" action=\"spage2.php\" method=\"post\"><p style=[b][!--coloro:red--][span style=\"color:red\"][!--/coloro--]\[!--colorc--][/span][!--/colorc--][/b]"margin-left: 200[b][!--coloro:red--][span style=\"color:red\"][!--/coloro--]\[!--colorc--][/span][!--/colorc--][/b]">Search by Zip:<input type=\"text\" name=\"zipCode\" size=[b][!--coloro:red--][span style=\"color:red\"][!--/coloro--]\[!--colorc--][/span][!--/colorc--][/b]"20[b][!--coloro:red--][span style=\"color:red\"][!--/coloro--]\[!--colorc--][/span][!--/colorc--][/b]"> (example: 01922)<br>Search by State: <input type=\"text\" name=\"state\" size=[b][!--coloro:red--][span style=\"color:red\"][!--/coloro--]\[!--colorc--][/span][!--/colorc--][/b]"20[b][!--coloro:red--][span style=\"color:red\"][!--/coloro--]\[!--colorc--][/span][!--/colorc--][/b]"><input type=\"submit\" size="20"> (example: NY for New York)<br></p></form></div>";?></td> </tr> </table> </center></div> Quote Link to comment https://forums.phpfreaks.com/topic/11503-centering-forms-on-page/#findComment-43322 Share on other sites More sharing options...
ValdouaD Posted June 8, 2006 Author Share Posted June 8, 2006 Now I have this error:Parse error: parse error, unexpected T_LNUMBER, expecting ',' or ';' in /var/www/html/store_finder.php on line 252 Quote Link to comment https://forums.phpfreaks.com/topic/11503-centering-forms-on-page/#findComment-43325 Share on other sites More sharing options...
kenrbnsn Posted June 8, 2006 Share Posted June 8, 2006 Why are you using PHP to echo that part of the table? It's all HTML. I don't see any PHP variables in that string at all.Try:[code]<div align="center"><center><table border="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1"><tr><td width="100%"><div style="margin-left: 15pt;"><form name="search" action="spage2.php" method="post"><p style="margin-left: 200">Search by Zip:<input type="text" name="zipCode" size="20"> (example: 01922)<br>Search by State: <input type="text" name="state" size="20"><input type="submit" size="20"> (example: NY for New York)<br></p></form></div></td></tr></table></center></div>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/11503-centering-forms-on-page/#findComment-43331 Share on other sites More sharing options...
ValdouaD Posted June 8, 2006 Author Share Posted June 8, 2006 Somebody wrote this code for me like 3 years ago and I have nver chagned it.PHP is not my strong suit as you can see.But thank to all of you I am happy with the way it works now.Thanks so much! You guys and gals are great! Quote Link to comment https://forums.phpfreaks.com/topic/11503-centering-forms-on-page/#findComment-43342 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.