Jump to content

help


dean012
Go to solution Solved by dean012,

Recommended Posts

ok i done evrything i could but it came out

= 1) { echo 'There are no entries inside the database'; } while($row = mysql_fetch_array($result)) { echo ''; echo ''; echo ''; echo ''; } echo '

ID Destination Difficulty '. $row['ID'].' '. $row['Destination'].' '. $row['Difficulty'].'

'; ?>

<?php
	
/* This code establishes a connection with the database on the server. 
The mysql_connect accepts three parameters. The mysql_select_db attempts to select the database that data will be retrived from. 
It accepts two parameters, one is the name of the database and the other is the connection variable.*/
   
   $connect=mysql_connect("localhost","root","");
    $db_selected = mysql_select_db("assesment", $connect);
    $query = "SELECT bay of plenty.ID,bay of plenty. Destinations, bay of plenty. Difficulty";
    $result = mysql_query($query) or die(mysql_error());
    if(!mysql_affected_rows() >= 1)
    {
    echo 'There are no entries inside the database';
    }
    while($row = mysql_fetch_array($result))
    {
    echo '<tr>';
    echo '<td>'. $row['ID'].'</td>';
    echo '<td>'. $row['Destination'].'</td>';
   echo '<td>'. $row['Difficulty'].'</td>';
    }
    echo '</table>';
?>
Edited by dean012
Link to comment
Share on other sites

the complete code is

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--


-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Yakity Yak</title>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Abel|Satisfy' rel='stylesheet' type='text/css'>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
  <p><!-- end #header --></p>
  <div id="header" class="container">
    <div id="logo">
      <h1><a href="#">Yakity Yak</a></h1>
    </div>
    <div id="menu">
      <ul>
        <li class="current_page_item"><a href="file:///D:/blackpolish/homepage.php">Homepage</a></li>
        <li><a href="file:///D:/blackpolish/trip.php">Destinations</a></li>
        <li><a href="#">contact </a></li>
        <li><a href="#">Login</a></li>
        <li></li>
        <li></li>
      </ul>
    </div>
  </div>
  <blockquote>
    <blockquote>
      <p> <center><img src="../../Documents/Unnamed Site 2/IMG_1913.jpg" width="999" height="388"  alt=""/></center>  </p>
    </blockquote>
  </blockquote>
  <div id="page">
    <div class="post">
      <h2 class="title"><a href="#">Welcome to Yakity yak club</a></h2>
			<div class="entry">
				<table border='1'>
    <tr>
    <th>ID</th>
    <th>Destination</th>
	<th>Difficulty</th>
    </div>
  <?php
	
/* This code establishes a connection with the database on the server. 
The mysql_connect accepts three parameters. The mysql_select_db attempts to select the database that data will be retrived from. 
It accepts two parameters, one is the name of the database and the other is the connection variable.*/
   
   $connect=mysql_connect("localhost","root","");
    $db_selected = mysql_select_db("assesment", $connect);
    $query = "SELECT bay of plenty.ID,bay of plenty. Destinations, bay of plenty. Difficulty";
	From ID, Destinations, Difficulty
    $result = mysql_query($query) or die(mysql_error());
    if(!mysql_affected_rows() >= 1)
    {
    echo 'There are no entries inside the database';
    }
    while($row = mysql_fetch_array($result))
    {
    echo '<tr>';
    echo '<td>'. $row['ID'].'</td>';
    echo '<td>'. $row['Destination'].'</td>';
   echo '<td>'. $row['Difficulty'].'</td>';
    }
    echo '</table>';
?>
 
</body>
</html>

Link to comment
Share on other sites

actually i did this last year but because my xampp is not working and i have to redo this. i cant really remember what i did last year but this is the complete working code

     <!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 name = "description" content = "Wellington Real Estate"/>
<meta name = "keywords" content = "home, housing, Karori, Mirimar, Te Aro, Thorndon, Farcourts, Jonnys, Relax"/> 
<title> Agents </title>
<link rel = "stylesheet" type = "text/css" href = "assessment.css"/>
</head>

<body>
<div id = "wrapper">
<div id = "container">
<div id = "banner">
<h1>The Wellington Real Estate Company</h1>
</div>
<div id = "left">
<a href = "Index.php">Home</a>
<a href = "Agents.php">Agents</a>
<a href = "Suburbs.php">Suburbs</a>

</div>
<div id = "right">
<br/>
<h2>Listing of Houses by Agent</h2>
<p>All our agents are currently listing a range of properties. Please click on one of the links to see that agent's listings: </p><br/>
<h1> Farcouts </h1>
    <table border='1'>
    <tr>
    <th>Address</th>
	<th>Bedrooms</th>
	<th>Bathrooms</th>
	<th>Price</th>
	<th>Suburb</th>
    <?php
	
/* This code establishes a connection with the database on the server. 
The mysql_connect accepts three parameters. The mysql_select_db attempts to select the database that data will be retrived from. 
It accepts two parameters, one is the name of the database and the other is the connection variable.*/
   
   $connect=mysql_connect("localhost","root","");
   $db_selected = mysql_select_db("ong_assessment", $connect);
   $query = "SELECT houses.Address, houses.Bedrooms, houses.Bathrooms, houses.Price, agents.Agent, suburb.Suburb
	FROM houses, suburb, agents
	WHERE houses.Suburb_ID = suburb.Suburb_ID
	AND agents.Agent_ID = houses.Agent_ID
	AND agents.Agent = 'Farcourts'
	ORDER BY `houses`.`Price` DESC , `houses`.`Suburb` ASC
	";
    $result = mysql_query($query) or die(mysql_error());
    if(!mysql_affected_rows() >= 1)
    {
    echo 'There are no entries inside the database';
    }
    while($row = mysql_fetch_array($result))
    {
    echo '<tr>';
	
	
   echo '<tr>';
	echo '<td>'. $row['Address'].'</td>';
	echo '<td>'. $row['Bedrooms'].'</td>';
	echo '<td>'. $row['Bathrooms'].'</td>';
	echo '<td> $'. $row['Price'].'</td>';
	echo '<td>'. $row['Suburb'].'</td>';
}
    echo '</table>';
 ?>
    
</div>
</div>
</div>
</body>
</html>
Link to comment
Share on other sites

Sorry to say this but you clearly have no idea what you're doing. You're missing " " around your query. That to any basic php programmer would be obvious. I'd suggest you take the time to learn PHP before asking for help.

Link to comment
Share on other sites

 

 

file:///C:/Users/User/Desktop/htdocs/trip1.php

That is why. You cannot fun PHP code directly in a web browser.

 

You need to have a server installed that is configured with PHP. You access the server via its url followed by your php file, for example http://server-address/file.php

 

 

 

actually i did this last year but because my xampp is not working

Make sure you still have xampp installed? Run xampp and put into your web directory (I think its C:\xampp\htdocs) and then go to http://localhost/ to run your PHP code.

Edited by Ch0cu3r
Link to comment
Share on other sites

when i mean not workingi  mean its courrupted.

and i tried localhost/trip1.php it came out Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\Users\User\Desktop\Desktop\htdocs\trip1.php on line 6

Link to comment
Share on other sites

 

 

when i mean not workingi  mean its courrupted.

What do you mean by that? What is corrupted, xampp comes with many components, such as apache, PHP, MySQL, phpMyadmin etc. Which of these are you saying is corrupted?

 

 

 

and i tried localhost/trip1.php it came out Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) inC:\Users\User\Desktop\Desktop\htdocs\trip1.php on line 6

There is an error on line 6 of trip.php. PHP cannot continue, unless you fix that error. What is trip.php?

Edited by Ch0cu3r
Link to comment
Share on other sites

  • Solution

I SOLVED IT WOOHOO...this is the working code thx guys

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--


-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Yakity Yak</title>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Abel|Satisfy' rel='stylesheet' type='text/css'>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
  <p><!-- end #header --></p>
  <div id="header" class="container">
    <div id="logo">
      <h1><a href="#">Yakity Yak</a></h1>
    </div>
    <div id="menu">
      <ul>
        <li class="current_page_item"><a href="file:///D:/blackpolish/homepage.php">Homepage</a></li>
        <li><a href="file:///D:/blackpolish/trip.php">Destinations</a></li>
        <li><a href="#">contact </a></li>
        <li><a href="#">Login</a></li>
        <li></li>
        <li></li>
      </ul>
    </div>
  </div>
  <blockquote>
    <blockquote>
      <p> <center><img src="../../Documents/Unnamed Site 2/IMG_1913.jpg" width="999" height="388"  alt=""/></center>  </p>
    </blockquote>
  </blockquote>
  <div id="page">
    <div class="post">
      <h2 class="title"><a href="#">Taranaki</a></h2>
			<div class="entry">
				<table border='1'>
    
    </div>

	


 
</body>
</html>
<?php
/* This code establishes a connection with the database on the server. 
The mysql_connect accepts three parameters. The mysql_select_db attempts to select the database that data will be retrived from. 
It accepts two parameters, one is the name of the database and the other is the connection variable.*/
   
$con=mysqli_connect("localhost","root","","assesment");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$result = mysqli_query($con,"SELECT * FROM taranaki");

echo "<table border='1'>
<tr>
<th>ID</th>
<th>Destination</th>
<th>Difficulty</th>
</tr>";

while($row = mysqli_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['ID'] . "</td>";
  echo "<td>" . $row['Destination'] . "</td>";
  echo "<td>" . $row['Difficulty'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysqli_close($con);
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.