Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-01-2012, 05:10 PM   PM User | #16
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
You need to shore up your HTML a bit... you're using an article2 tag, which isn't actually standard tag, which means browsers won't know what to do with it, and though there is an article tag in HTML5, you have your page defined as HTML4, so definitely needs to go.

As for the bug, if you replace the include with "echo 1;", does it work? It sounds like your PHP isn't running... does other PHP code work on that page?
Keleth is offline   Reply With Quote
Users who have thanked Keleth for this post:
red71chevelle (03-02-2012)
Old 03-02-2012, 12:51 AM   PM User | #17
red71chevelle
New Coder

 
Join Date: Aug 2011
Posts: 80
Thanks: 19
Thanked 0 Times in 0 Posts
red71chevelle is an unknown quantity at this point
Nope that didn't change anything. This is the only php on the page. and I fixed the HTMl Document type with HTML5 all you need is
Code:
<!DOCTYPE HTML>
Thank you for catching that for me. That fixed the formatting issues I had in different browsers.

The article tag I created so I could have 2 different tags with different formatting in them. if there is another way I do't know it. But then again I dont know much lol

Ok so for the main page code the below is what I have... I know there are some issues in there I am still going to use the checker tool to get that worked out.

Code:
<!DOCTYPE HTML>
<head>
<meta charset="UTF-8">
<title>Murfreesboro's Top Ten Bars | TennBars.com</title>

<!--[if lt IE 9]>
 <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->
<style type="text/css">
<!--
body {
	margin-top: 0px;
	background-image: url(images/bg.jpg);
	background-repeat: repeat-x;
	background-position: top;
	background-color: #E7E7E7;
}
-->
</style>
<style type="text/css">
.style4 {
	font-family: "BankGothic Md BT";
}
.style5 {
	font-family: "BankGothic Md BT";
	text-align: center;
}
.style6 {
	text-align: center;
        }
</style>
<link href="css/xom.css" rel="stylesheet" type="text/css">

<script src="free_validation.js"></script>
<script>
	required.add('Full_Name','NOT_EMPTY','Full Name');
	required.add('Email_Address','EMAIL','Email Address');
	required.add('Your_Message','NOT_EMPTY','Your Message')
	</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
<!--
a:link {
	color: #D2D2D2;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #FCFCFC;
}
a:hover {
	text-decoration: underline;
}
a:active {
	text-decoration: none;
	color: #E9E9E9;
}
-->
</style>
</head>
<body>

<!--Start wrapper -->
<div class="containerWrap">
 <!--start header -->
  <div class="header">
      <!--start logo -->
      <div class="logo">
        <h1>★TennBars.com</h1>
    </div><!--end logo -->
    <!--start navigation -->
    <div id="nav">  <li class="current"><a href="http://www.tnbarfinder.com">Home</a></li>
      <li><a href="#">About Us</a>
          <ul>
            <li><a href="#">Training</a>
                <ul>
                  <li><a href="#">The Pool</a></li>
                  <li><a href="#">Spire Parts</a></li>
                  <li><a href="#">Wallpapers</a></li>
                  <li><a href="#">Standards to be met</a></li>
                </ul>
            </li>
            <li><a href="#">The rates for school</a>
                <ul>
                  <li><a href="#">Video Tutorials</a></li>
                </ul>
            </li>
            <li><a href="#">Forum</a></li>
            <li><a href="#">Best Web Gallery</a></li>
          </ul>
      </li>
      <li><a href="#">Forum</a>
          <ul>
            <li><a href="#">Our Team</a>
                <ul>
                  <li><a href="#">Sub-Level Item</a></li>
                  <li><a href="#">Sub-Level Item</a>
                      <ul>

                        <li><a href="#">Level Item</a></li>
                        <li><a href="#">Level Item</a></li>
                        <li><a href="#">Level Item</a></li>
                      </ul>
                  </li>
                  <li><a href="#">Level Item</a></li>
                </ul>

            </li>
            <li><a href="#">Shop</a></li>
            <li><a href="#">Link Friends</a></li>
            <li><a href="#">Ou Side</a>
                <ul>
                  <li><a href="#">Sub-Level Item</a></li>
                  <li><a href="#">Sub-Level Item</a></li>

                  <li><a href="#">Sub-Level Item</a></li>
                </ul>
            </li>
          </ul>
      </li>
      <li><a href="#">Pics</a></li>
        <li><a href="#">Contact Us</a></li></div>
<!--end navigation -->
    <div class="content" id="wrapper">
      <br/>
	<article2>          
         <h1 align="center">Murfreesboro's Top Ten Bars</h1>
          <h2 align="center">Dont forget to rate your favorite!</h2>
          <br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>

      </article2>
</div>
</div>

<?PHP echo 1;('getdata.php'); ?>

 <!--start footer -->  
  <footer>
  <div class="top"> 
 <!--end footer -->
 </div>
  <div class="footerWrapper" id="footercontent">
    <li><a href="#">Home Page</a></li> 
 <li><a href="#">About Us</a></li> 
 <li><a href="#">Forum</a></li> 
 <li><a href="#">Pics</a></li>
 <li><a href="#">Contact Us</a></li> 
 <p><li>&copy; copyright - TennBars.com</li></p>
 </div> 
</footer> 
</div>
<!--end wrapper -->
</body>
</html>
and the getdata.php page is working as you can see by going to www.tnbarfinder.com/getdata.php
that code is here

Code:
<?php

// set up strings needed to connect to the DB
$DBhost = "*****";
$username="*****";
$password="*****";
$database="*****"; 

// Connect to mysql here or die
$connect = mysql_connect($DBhost,$username,$password) or die("Unable to connect to host");

// Connect to the database you want here or die
mysql_select_db($database) or die( "Unable to connect database");


$sql = "SELECT * FROM barlist WHERE bar_city like '%Murfreesboro%' ";

//echo "<hr/>DEBUG SQL: " . $sql . "<hr/>\n";

$result = mysql_query( $sql ) or die( mysql_error() );

echo "<table border='1'>
<tr>
<th>Bar Name</th>
<th>Address</th>
<th>Open Time</th>
<th>Closing Time</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['bar_name'] . "</td>";
  echo "<td>" . $row['bar_city'] . "</td>";
  echo "<td>" . $row['bar_open'] . "</td>";
  echo "<td>" . $row['bar_close'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

?>
red71chevelle is offline   Reply With Quote
Old 03-02-2012, 02:25 PM   PM User | #18
red71chevelle
New Coder

 
Join Date: Aug 2011
Posts: 80
Thanks: 19
Thanked 0 Times in 0 Posts
red71chevelle is an unknown quantity at this point
Exclamation

Ok I figured it out... you were correct in saying that the page had to be a .php before it would work when I renamed the file to a .php it didnt work because when I went to save it I saved it as unicode instead of utf-8 encoding. Once I saved the file as utf-8 encoding and I changed the php line back to
Code:
<?PHP include "getdata.php"; ?>
it worked fine the table shows on the page like it should.. thank you guys for all of your help! I am sure I will be back with more questions later. Just glad I have a great place to get some help! Thanks again!
red71chevelle is offline   Reply With Quote
Old 03-02-2012, 03:37 PM   PM User | #19
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
As a note towards the article tag...

If you need 2 article tags (which plenty of people do, just look at a blog), you use unique identifiers.

<article> tells the browser the following is meant to be an article, so the browser developers have come up with CSS that would match that be default. It also makes it easier to read. <article2> tells YOU that this is a different article, but as far as the browser is concerned, there is no difference between two articles.... or headers or links, etc. If you need to distinguish between two tags, use the id attribute:

Code:
<article id="blogPost_1">Post 1!</article>
<article id="blogPost_2">Post 2!</article>
<article id="blogPost_45">Post 45!</article>
After all, you wouldn't make a <div>, <div2>, <div3>, right?

Valid code is VERY important, specially if you're going cross browser. Your code wouldn't appear correct at all in IE prior to 9, would fail in FF prior to 3 (I believe, maybe its 3.5, can't remember when they added the default tag css), etc. Validate, it'll save you time and hassle.
Keleth is offline   Reply With Quote
Old 03-02-2012, 05:14 PM   PM User | #20
red71chevelle
New Coder

 
Join Date: Aug 2011
Posts: 80
Thanks: 19
Thanked 0 Times in 0 Posts
red71chevelle is an unknown quantity at this point
Ok even though I define what the tags mean? I have my own css file this is what I have in it right now
Code:
article {
	float: left;
	width: 600px;
	padding: 1em;
}
article2 {
	float: center;
	width: 600px;
	padding: 1em;
}
How would I set the article and article2 tag to have "ID's" in the CSS the way you said is just on the .php page right?
red71chevelle is offline   Reply With Quote
Old 03-02-2012, 05:39 PM   PM User | #21
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
By giving them default CSS, newer browsers will understand what to do with them, but for example, HTML5 tags prior to IE9 won't know what to do with them, no matter how much css you apply (to make HTML5 tags work on older browsers, make use of a html5 shiv). Its a bad habit to make up your own tags. There is a reason there is a standard; it makes development easier, and avoids issues. Even if everything appears to be working fine, deviation from standards could be why something stops working. Besides, your current definition isn't sufficient. What is its display definition for example? There is never a reason to make up a tag when the standards give you an alternative.

It doesn't matter what file the CSS is in, as long as its applied. PHP is all backend... the user never sees any of it. Just the same, CSS is all frontend, the server couldn't care less about it. When you include a file within another file and serve it to the user, they only know they're getting one file. So even if you put each tag in a separate file, then included it all together, the user would think you sent them one file, with a bunch of tags on it, and any css that page references would apply. Its important to note what is processed on the back and the front.
Keleth is offline   Reply With Quote
Users who have thanked Keleth for this post:
red71chevelle (03-02-2012)
Old 03-02-2012, 05:53 PM   PM User | #22
red71chevelle
New Coder

 
Join Date: Aug 2011
Posts: 80
Thanks: 19
Thanked 0 Times in 0 Posts
red71chevelle is an unknown quantity at this point
Got ya. Thanks for taking your time to explain this stuff to me. I may actually learn something from this! Haha

So to get the article tag to have multiple setings like I have now I want them to be the same except for one to be centered on the page and the other allign left. How would you go about coding that?
red71chevelle is offline   Reply With Quote
Old 03-02-2012, 06:06 PM   PM User | #23
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
Give each a unique id (call them 'article1' and 'article2' if you want), then apply the CSS to each ID.

Code:
<style>
#article1 {
float: left;
}
#article2 {
float: right;
}

<html>
<head></head>
<body>
<article id="article1">This is floated left</article>
<article id="article2">This is floated right</article>
</body>
</html>
Keleth is offline   Reply With Quote
Users who have thanked Keleth for this post:
red71chevelle (03-05-2012)
Old 03-02-2012, 06:15 PM   PM User | #24
red71chevelle
New Coder

 
Join Date: Aug 2011
Posts: 80
Thanks: 19
Thanked 0 Times in 0 Posts
red71chevelle is an unknown quantity at this point
Oh ok got ya so do it all on the main page not in the CSS I see what you are saying now. Define the style at the top of the page in the Head section then call it from the body down below right?
red71chevelle is offline   Reply With Quote
Old 03-02-2012, 06:41 PM   PM User | #25
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
You can put it in your CSS file... as long as the CSS is listed somewhere the page reads.
Keleth is offline   Reply With Quote
Users who have thanked Keleth for this post:
red71chevelle (03-05-2012)
Old 03-02-2012, 10:09 PM   PM User | #26
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
And if you want to have multiple "article1"s or "article2"s, just use a class, instead:
Code:
/* in file "demo.css" */
.article1 {
float: left;
}
.article2 {
float: right;
}
Code:
<html>
<head>
<link href="demo.css" rel="stylesheet" type="text/css" />
</head>
<body>
<article class="article1">This is floated left</article>
<article class="article2">This is floated right</article>
<article class="article1">Also floated left</article>
<article class="article2">Also floated right</article>
</body>
</html>
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
red71chevelle (03-05-2012)
Old 03-03-2012, 03:11 AM   PM User | #27
Offerscript
New to the CF scene

 
Join Date: Mar 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Offerscript is an unknown quantity at this point
Quote:
Originally Posted by red71chevelle View Post
Ok thanks for that. I got the getdata.php code working it pulls the bars with the word Murfreesboro in the bar_city field and it places them in the table like I am wanting if I browse to the getdata.php file manually it works but it is not displaying on my main page where I have the following code

Code:
<?PHP include("getdata.php"); ?>
Any ideas?

And I hate to ask too many questions do any of you have any idea why a web page will show fine in IE9 but not in chrome?
try using the format phtml instead of html as it will most likely not work trying to put php in a client side file format.
Offerscript is offline   Reply With Quote
Old 03-03-2012, 10:32 PM   PM User | #28
red71chevelle
New Coder

 
Join Date: Aug 2011
Posts: 80
Thanks: 19
Thanked 0 Times in 0 Posts
red71chevelle is an unknown quantity at this point
Quote:
Originally Posted by Offerscript View Post
try using the format phtml instead of html as it will most likely not work trying to put php in a client side file format.
I got it to work thank you though. I had to save the page a .php instead of html and when I do that the encoding needs to be set to utf-8
red71chevelle is offline   Reply With Quote
Old 03-05-2012, 05:10 PM   PM User | #29
red71chevelle
New Coder

 
Join Date: Aug 2011
Posts: 80
Thanks: 19
Thanked 0 Times in 0 Posts
red71chevelle is an unknown quantity at this point
Question

Ok I have another question some of you might be able to answer.

On the getdata.php page I have it draw a table with results and what I am wantng to do is round the corners of that table.

I know you have to draw the ronded coners then place them over the table edges and I have the top left one working but it seems to mess with the layout of the table and the top right image is not stretching over to the actual coner of the table.. this is the code I have right now to draw the table.
Code:
echo "<table allign='center' bgcolor='white' width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='100%'><img src='corner1.gif' width='14' 
height='14' border='0' alt='...' /></td>

<td width='100%'></td>

<td width='100%'><img src='corner2.gif' width='14'
height='14' border='0' alt='...' /></td>

<tr>
<th>Bar</th>
<th>Special</th>
<th>Day of Special</th>
<th>Address</th>
<th>Special Starts</th>
<th>Special Ends</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td align='center'>" . $row['bar_name'] . "</td>";
  echo "<td align='center'>" . $row['bar_special'] . "</td>";
  echo "<td align='center'>" . $row['special_day'] . "</td>";
  echo "<td align='center'>" . $row['bar_address'] . "</td>";
  echo "<td align='center'>" . $row['special_start'] . "</td>";
  echo "<td align='center'>" . $row['special_end'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

?>
and the results page is here http://www.tnbarfinder.com/city/days...oro/monday.php

Any ideas? Or should I post this in a differnt section on this forum?
red71chevelle is offline   Reply With Quote
Old 03-05-2012, 06:12 PM   PM User | #30
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
Yup, no longer anything to do with MySQL (though your first question was about PHP, not MySQL anyway), so yah, this needs to be moved to to HTML, where more people can see and help you.
Keleth is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:38 PM.


Advertisement
Log in to turn off these ads.