Bazzaah 0 Light Poster

I found a solution and it is this

html { min-height:100%; margin-bottom:1px; }

detailed here

http://css-tricks.com/349-eliminate-jumps-in-horizontal-centering-by-forcing-a-scroll-bar/

Bazzaah 0 Light Poster

Hi

I'm just finishing up a stylesheet.

I've noticed a small problem

The footer and boxes (innerbox and outerbox in sheet below) resize slightly when the content is more than a screen long.

Is there a way to fix that?

Thanks in advance for any help.

here's my stylesheet

/* global properties */

html, body {
	background: #2c539e;
	font-size: 100%;
	margin:0;
	padding:0;
	border:0;		
	width:100%;
	min-width:950px; 
	font-family: "Helvetica Neue",
               Arial,
               Helvetica,
               sans-serif;

	}
	
/* navigation menu HEADER */

#navhead {
	height:70px;   
   float:left;
   width:100%;
   background: #d0ff51;
   border-top: 5px solid #fff900;
   overflow:hidden;
   position:relative;
	font-size: 1.4em;

}
#navhead ul {
   clear:left;
   float:left;
   list-style:none;
   margin:0;
   padding:0;
   position:relative;
   left:50%;
   text-align:center;
}
#navhead ul li {
   display:block;
   float:left;
   list-style:none;
   margin:0;
   padding:0;
   position:relative;
   right:50%;
   }
#navhead ul li a {
   display:block;
   margin:0px 10px 0px 1px;
   padding:10px 10px;
      color: #2c539e;
   text-decoration:none;
   line-height:1.3em;
   height:50px; 
   font-size: 1em;
   -moz-border-radius: 15px;
   border-radius: 15px;

}
#navhead ul li a:hover {
 
   color:#000;
   height: 70px;
 
	}
#navhead ul li a.active,
#navhead ul li a.active:hover {
   color:#fff;
   background:#000;
   font-weight:bold;
   height: 70px;
}

/* active tab header*/

body#home a#home,
body#login a#login,
body#register a#register,
body#members a#members,
body#articles a#articles,
body#search2 a#search2,
body#download a#download

{
background-color: #2c539e;
color: #fff;
height:60px;   
padding-left: 5px;
padding-right: 5px;
padding-top: 25px;
font-size: 1.6em;
} 

/* active tab footer */


body#privacy a#privacy,
body#about a#about,
body#contact a#contact,
body#password a#password,
body#questions a#questions,
body#download a#download
{
background-color: #9abdde;
color: #fff;
height:60px;   

} 

/* navigation menu FOOTER */

#navfoot {
	height:70px;   
   float:left;
   width:100%;
   background: #2c539e;
   border-top: 5px solid #fff900;
   overflow:hidden;
   position:relative;
	font-size: 1.4em;
  
} …
Bazzaah 0 Light Poster
Bazzaah 0 Light Poster

don't worry - silly question.

Thanks again!

Bazzaah 0 Light Poster

how do I do that?

Bazzaah 0 Light Poster

ddymacek - thanks a lot, really appreciate your help!

This sorted it (your code but there was a missing double quotes).

$query = "SELECT * FROM pro_words WHERE word ='".$_GET['w']."'";

Thanks again - this has been bugging me for a while.

Bazzaah 0 Light Poster

Thanks - I'll try that. 'example' above is just a row on the db.

The column is called word because that column contains a word in a dictionary.

(Yes, it would be a string as entries in column 'word' would all be literal constants).

Bazzaah 0 Light Poster

Thanks for the reply.

Sorry, should have made it clearer that the code I am using is now this - the $query you reference would be incorrect.

$query = "SELECT * FROM pro_words WHERE word = " . $_GET['w'];
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){

echo $row['word'];
echo "<br />";

}
Bazzaah 0 Light Poster

Ironed out the problem with $_GET that produced the SQL error (my mistake with a misnamed variable).

The original solution now produces this error

Unknown column 'example' in 'where clause'

Any tips on ironing this out? Doesn't seem as if it should be too far off now?

Thanks in advance for any help.

Bazzaah 0 Light Poster

There's something wrong with the $_GET since it won't echo (and it does on an earlier iteration) - I'll try and get that sorted and hopefully that will sort it out.

Thanks in the meantime.

Bazzaah 0 Light Poster

Thanks for that.

I get an SQL syntax error around WHERE - any idea what might cause that?

Bazzaah 0 Light Poster

Hey there

I'd appreciate some help with variables please.

I have a search function on a site I'm building and would like to have it so that a user can click on a search result to see more columns from that row on the db, if you see what I mean. The best way seems to be to open a new page on which to display more detail on the chosen search result.

I express it like this

echo '<a href="newpage.php?w=' . $row['value'] . '">' . $r['value'] . '</a>';

That part works fine.

The problem is this - when I click through to the new page, all rows on the db are shown i.e. the search is made, result x is returned, click on x and in newpage.php x y and z (i.e. all rows) are displayed.

How do I structure things so that only x (and any other columns from row x that I choose) are displayed?

I'm thinking that I should be able to limit what it displayed with the SELECT but can't seem to find the right syntax to finish it off properly. Currently I have this on newpage.php

$query = "SELECT * FROM pro_words".$_SESSION['where clause'];  
	 
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){

echo '<center>' . $_GET['w'] . '</center> ';	
echo $row['word'] ;

}

I have defined the $_SESSION on search.php as

$_SESSION['word'] = $row['word']

Is that on the right lines?

I know a little PHP, enough to know …

Bazzaah 0 Light Poster

Thanks again, your help's much appreciated.

This is what I want my search/display files to do;

- user makes a search of a table on a database
- one or more entries are returned
- the results link to a file word2.php
- if the user searches for the word 'example' s/he clicks on that result to be taken to word2.php. The table contains columns for the word ('word'), the type of word ('type') and a sentence showing its use ('sentence'). I would like word2.php to contain column entries for 'word' 'type' and 'sentence' that relate to the choice made by the user.

Hope that's clearer now.

From what you've said, I think SELECT in word2.php will need a WHERE clause.

Thanks again for your help.

Bazzaah 0 Light Poster

Thanks for the reply.

$_SESSION variables look like the way to go - almost there in fact.

There#s just one problem - I defined the variable like this in search.php

$_SESSION[$sentence1] = $row['sentence1'] ;

and echo it out in word2.php like this

echo $_SESSION[$sentence1] ;

It repeats x number of times, where x is the number of entries in the table.

Could you tell me how to limit that to one instance please?

Thanks

Bazzaah 0 Light Poster

Hi

In my site I have a search function but have hit on a problem that I can only partly solve.

A user makes a search - one or more results are returned. A user can click on an entry and view additional resources on a new page (word2.php) (that's the idea anyway!).

This is the search code;

// Set up our error check and result check array
$error = array();
$results = array();

// First check if a form was submitted. 
// Since this is a search we will use $_GET
if (isset($_GET['search'])) {
   $searchTerms = trim($_GET['search']);
   $searchTerms = strip_tags($searchTerms); // remove any html/javascript.
   
   if (strlen($searchTerms) < 1) {
      $error[] = "Search terms must be longer than 1 character.";
   }else {
      $searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection.
   }
   
   // If there are no errors, lets get the search going.
   if (count($error) < 1) {
      $searchSQL = "SELECT * FROM pro_words WHERE";
      
      // grab the search types.
      $types = array();
      
      if (count($types) < 1)
         $types[] = "`word` LIKE '%{$searchTermDB}%'"; 
      
          $andOr = isset($_GET['matchall'])?'AND':'OR';
      $searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `word`"; // order by word.

      $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}");
      
      if (mysql_num_rows($searchResult) < 1) {
         $error[] = "Your search yielded no results. Sorry.";
      }else {
         $results = array(); // the result array
         $i = 0;
         while ($row = mysql_fetch_assoc($searchResult)) {
            $results[] = "{$row['word']}<br />";
            echo '<h2><tr><td align="left"><a href="word2.php?w=' . $row['word'] . '">' . $row['word'] …
Bazzaah 0 Light Poster

I got the answer shortly after posting this.

echo '<param name="flashvars" value="mp3=' . $row['wordfile'] . '" />';
Bazzaah 0 Light Poster

Hi

I'm building a site that contains access to some mp3 files of people speaking English.

I would like a media player that is able to handle a variable that results from a database search.

I can use <a href etc> to link to the relevant file but would like to use a server-side player to stream the file, rather than the client's browser.

Something like Dewplayer would be perfect but it seems only to take a static file (maybe I'm wrong there).

The player appears within <object> tags, like this

echo '<object type="application/x-shockwave-flash" data="/player/dewplayer.swf" width="200" height="30" id="dewplayer" name="dewplayer">';
echo '<param name="movie" value="/player/dewplayer.swf" />';
echo '<param name="flashvars" [B]value="mp3=file.mp3[/B]" />';
echo '<param name="wmode" value="transparent" />';
echo '</object>';

(the code is freely downloadable so hope I'm not breaking any rules posting someone else's code here).

Is there a way I can specify a variable in value? If not, does anyone know of a player that I can use that does allow that?

Grateful for any help.

Thanks in advance.

Bazzaah 0 Light Poster

Sorted - many thanks for the link!

Bazzaah 0 Light Poster

Thanks, I'll have a look at that.

Bazzaah 0 Light Poster

Hello

After some help please

I have a website which links to a database.

I would like to be able to echo the contents of the database onto a new page.

The new page is generated with the following code;

echo '<tr><td align="left"><a href="word.php?w=' . $r['word'] . '">' . $r['word'] . '</a></td></tr>';

Is there a way that I can display rows of the database in the document word.php?

I thought if I did this it might work but it doesn't

$link = mysql_connect('host', 'db', 'pass');
if (!$link) {
    die('Not connected : ' . mysql_error());
}

// access the required db

$db_selected = mysql_select_db('db', $link);
if (!$db_selected) {
    die ('Can\'t use guide : ' . mysql_error());
}

echo '<td>' . $row['sentence1'] . '</td>';

Any ideas/pointers would be really appreciated.

Sorry if not clear - please say if not.

Bazzaah 0 Light Poster

OK I see what you're saying.

I still get the white screen so I'm thinking I need to restructure the search along the lines outlined in example #2 here

http://php.net/manual/en/function.mysql-query.php

Would that be a better approach?

Bazzaah 0 Light Poster

I'll look into this and see how I could improve it.

The search function was slightly adapted from a book I have, but was maybe not designed for the purpose I have been trying to use it.

Bazzaah 0 Light Poster

here it is;

<?php
  session_start();
    // check session variable

  if (isset($_SESSION['first_name']))
  {
include ('includes/header_loggedin.html');
  
  //connect to mysql
$link = mysql_connect('localhost', 'zzz', 'xxx');
if (!$link) {
    die('Not connected : ' . mysql_error());
}

// access the required db

$db_selected = mysql_select_db('proguide', $link);
if (!$db_selected) {
    die ('Can\'t use proguide : ' . mysql_error());
}

//specify type of search

$search=$_POST["search"];

//get the mysql and store them in $result

$result = mysql_query("SELECT word,sentence1 FROM pro_words WHERE word = '$word' LIKE '%$search%'");
			        
//get the db content that is specified above

if (mysql_num_rows($result) < 1) {

echo "<br><br><h2>Oh dear. We didn't find anything. Sorry - we did look though.</h2>";

}else {
         
echo '<table align="center" cellspacing="8" cellpadding="8" width="85%"><tr><td align="left"><b>Word</b></td></tr>';

echo "<br><br><h3>This is what we found:</h3><br>";

while ($r=mysql_fetch_array($result, MYSQL_ASSOC))

echo '<tr><td align="left"><a href="word.php?w=' . $r['word'] . '">' . $r['word'] . '</a></td></tr>';

}

#$_GET["word"]=$r['word'];
#$_GET["sentence1"]=$r['sentence1'];

echo "Click on any word to use it.";

echo '</table>'; // Close the table.      

   }

	else
 
   {
    echo '<h1><p>You are not logged in.</p></h1>';
    echo '<h2><p>If you want to see this page, please register or log-in.</p></h2>';
    echo '<a href="index.php">Take Me Back</a><br>';
    echo '<a href="register.php">Register</a><br>';
   }
  
 
    echo '<br><a href="search.php">Search again?</a><br>';
    
?>
Bazzaah 0 Light Poster

here it is:

<?php

session_start();

if(isset($_SESSION['first_name']))

  {

include ('includes/header_loggedin.html');

echo '<br><br><h3>You have chosen the word </h3><br>';

//insert word

echo $_GET['w'];

#print_r($_GET);

echo '<h3>Here are some examples of its modern use </h3>';

if (isset($_GET['w'])){ //show the next div only if there\'s GET parameter
echo '<div id="sentence1">This is the sentence : . $row['sentence1'] .</div>';
}
else
{
echo 'Content coming soon!';
}

echo '<h3>Use the player to listen and practice </h3>';


echo '<h3>Click on a sentence to listen to it. </h3>';

//insert player

echo '<h3>Listen to the instructions to get the most out of our player! </h3>';

//insert player with instructions

echo '<br><h2><a href="search.php">Back To Search</a><br></h2>';

// Check for an image name in the URL:

}else{

include ('includes/header.html');

       echo '<h2><p>If you want to access this site, please register or log-in.</p></h2>';

   }

?>
Bazzaah 0 Light Poster

So it's probably not the query then.

Error reporting is on in php.ini so am a bit baffled by this white page.

Bazzaah 0 Light Poster

Thanks.

This is what I currently use - is this query flawed for its purpose?

$result = mysql_query("SELECT word,sentence1 FROM pro_words WHERE word LIKE '%$search%'");

Perhaps I'm not getting quite the right answer as I'm not asking quite the right question.

I'll try what you suggest - I appreciate your help.

Bazzaah 0 Light Poster

After.

print_r($_GET);

returns 'word' but not 'sentence'. I wonder if everything is being fetched from the db?

Bazzaah 0 Light Poster

Thanks for that, much appreciated! That's just the kind of thing I'm after.

Something needs a little finessing though (elsewhere in the site) as it returns a white page, even with error reporting on.

Any ideas?

Bazzaah 0 Light Poster

Hi

I am writing a site that will include an audio dictionary.

The dictionary will have a working search function.

This is what I have so far:

When a search is made, one or more results is returned.

The user can click on each result to get taken to a unique record page for the search result he clicked on.

This will include some sentences where he can hear the word being used in context.

Currently I have got to the stage where the word can be clicked on to open its unique page;

if (mysql_num_rows($result) < 1) {

echo "<br><br><h2>Oh dear. We didn't find anything. Sorry, we did look though.</h2>";

}else {
         
echo '<table align="center" cellspacing="8" cellpadding="8" width="85%"><tr><td align="left"><b>Word</b></td></tr>';

echo "<br><br><h3>This is what we found:</h3><br>";

while ($r=mysql_fetch_array($result, MYSQLI_ASSOC))

echo '<tr><td align="left"><a href="word.php?w=' . $r['word'] . '">' . $r['word'] . '</a></td></tr>';

}

It's OK to print out the word too in the word.php;

echo $_GET['w'];

This is the problem;

What has so for eluded me is getting the sentence to appear on the unique word page.

I'm hoping I've been missing something reasonably straight forward.

Could someone help me with that please?

Thanks in advance - do please say if what I've written is unclear.

Bazzaah 0 Light Poster

Yep, that does work and thanks.

The only problem I have is that there are other entries from the database that I would like to include in word.php, up to 3 sentences and all of which link to audio material as well.

I was hoping there was an effective way to pull all those entries into word.php via searchdb.php. Can I put more than one array into the url constructed in searchdb.php?

Thanks in advance, I appreciate your help.

Bazzaah 0 Light Poster

Pass the data as a query string.
for example: http://www.google.com/?shiv=10
like that.

Thanks - could you check the link please as I get a 404?

Bazzaah 0 Light Poster

Thanks for the reply

This is the search script

<?php
  session_start();
    // check session variable

  if (isset($_SESSION['first_name']))
  {
include ('includes/header_loggedin.html');
  
  //connect to mysql
$link = mysql_connect('xxxx', 'yyyyy', 'zzzzzz');
if (!$link) {
    die('Not connected : ' . mysql_error());
}

// access the required db

$db_selected = mysql_select_db('proguide', $link);
if (!$db_selected) {
    die ('Can\'t use proguide : ' . mysql_error());
}

//specify type of search

$search=$_POST["search"];

//get the mysql and store them in $result

$result = mysql_query("SELECT word,sentence1 FROM pro_words WHERE word LIKE '%$search%'");
			        
//get the db content that is specified above

if (mysql_num_rows($result) < 1) {

echo "<br><br><h2>Oh dear. We didn't find anything. Sorry - we did look though.</h2>";

}else {
         
echo '<table align="center" cellspacing="8" cellpadding="8" width="85%"><tr><td align="left"><b>Word</b></td></tr>';

echo "<br><br><h3>This is what we found:</h3><br>";

while ($r=mysql_fetch_array($result, MYSQLI_ASSOC))

echo '<tr><td align="left"><a href="word.php?w=' . $r['word'] . '">' . $r['word'] . '</a></td></tr>';

}

// session variable for word.php
$_SESSION["word"]=$r['word'];

echo "Click on any word to use it.";

echo '</table>'; // Close the table.      

   }

	else
 
   {
    echo '<h1><p>You are not logged in.</p></h1>';
    echo '<h2><p>If you want to see this page, please register or log-in.</p></h2>';
    echo '<a href="index.php">Take Me Back</a><br>';
    echo '<a href="register.php">Register</a><br>';
   }
  
 
    echo '<br><a href="search.php">Search again?</a><br>';
    
?>

So,

- the search is made
- any results are returned
- each result is displayed as a link to a new page that displays further information on the chosen search result. The bit in bold is what I can't get working

e.g. you might search on the word 'able' and …

Bazzaah 0 Light Poster

Hi everyone,

I'd be grateful for some help please.

My problem is this - I am trying to find a way to pass the content of a db search from one page to another page, if that's clear.

Each file opens with

session_start();

This is the database search:

$result = mysql_query("SELECT word,sentence1 FROM pro_words WHERE word LIKE '%$search%'");

Any of the results of the db search can be accessed in more detail via a new page;

while ($r=mysql_fetch_array($result, MYSQLI_ASSOC))

echo '<tr><td align="left"><a href="word.php?w=' . $r['word'] . '">' . $r['word'] . '</a></td></tr>';

In essence, I'm looking to reproduce 'word' and 'sentence1' in the word.php file.

I have tried variations around $_SESSION, $_POST and $_GET without success - neither of my reference books provide guidance.

I'd be really grateful if someone could help me with a solution please. Something is eluding me, perhaps the problem is more complex than I think?

If you need any further info then do please say, but in meantime thanks in advance for any help.