Bazzaah
-
Posts
49 -
Joined
-
Last visited
Posts posted by Bazzaah
-
-
Thanks, all sorted - admirably clear blog too!
It all went a bit pear shaped when I positioned my header 'absolute' to stop it covering up a box.
Much appreciated.
-
Hi
I have a question, hope someone can help me please.
If have a header and container set up like this;
/* header */ #header { position: absolute; top:0; left:0; width:100%; } /* container */ #container{ position: absolute; margin-left: auto; margin-right: auto; width: 950px; margin-top: 120px; }
The header goes where it should be but the container is stuck on the left margin, but with the margin-left and margin-right set to auto, I thought the container should be centered. I'd like the centering to be automatic as I'm using a fixed width.
Any ideas on why that's not happening?
If you need further info to help then please say.
Thanks in advance for any help
-
Sorry to waste your time - I have it resolved.
I omitted the line of code from the search form that echoes either message.
D'oh.
-
Hey there
I've adapted the search code from the tutorial on this site here
http://www.phpfreaks.com/tutorial/simple-sql-search
for a project I've been working on but have an error.
The search works just fine but if either of the messages I've included are tripped (zero search characters or nothing found) then I get a blank screen and the error message is not echoed. (The vanilla code works fine - the error has arisen through the changes I needed to make).
I don't know why this is happening and would appreciate some help please.
Thanks in advance for any help.
session_start(); // check session variable if (isset($_SESSION['first_name'])) { include ('includes/header_loggedin.html'); //db connection info deleted $error = array(); //get search term, strip it 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. } //formulate query if (count($error) < 1) { $query = "SELECT * FROM table WHERE row LIKE '%{$searchTermDB}%'"; //make the query $result = mysql_query($query) or die(mysql_error()); //display the results if (mysql_num_rows($result) < 1) { $error[] = "Your search term yielded no results."; } else { while ($endresult = mysql_fetch_array($result)) { echo '<br />'; echo 'This is what we found'; echo '<br />'; echo '<a href="newpage.php?w=' . $endresult['row'] . '">' . $endresult['row'] . '</a>'; } } } } }
-
Thanks both of you.
I'll read through the pagination tutorial.
Re the code WebStyles, I've not made that work yet. Is there not just a way that I can use a WHERE clause in the SELECT?
-
I'd appreciate some help please.
I'm using $_SESSION to pass info from a MySQL search to a new page.
How do I include the $_SESSION in the SELECT? I've done loads of different combinations - none has worked and I've not found anything to help on Google.
In this case;
user searches a db table.
Results are returned.
User can click on result to be taken to a new page where columns from the row are displayed
Results are displayed on the new page like this;
$query = "SELECT * FROM table"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ echo $_SESSION[$column] ; }
That code returns the correct column BUT for as many rows there are in the table.
How can I set things up so that column entries are only echoed for the one row that's been selected by the user?
Sorry if unclear; happy to clarify if needed - any help would be really appreciated.
-
I ran that and no errors, it just returned this;
Array
(
[user_id] => 1
[first_name] => Myname
[user_level] => 0
[where_clause] => WHERE word LIKE '%e%'
)
which is what I'd expect; no errors though.
-
Yes the files have session start().
How do i debug the session variable? Sorry, I'm a bit of a noob with this...
-
Thanks again - it does work but only if there is one search result. If there are two results, it displays two results on word.php.
How do I get it so that, if there are multiple results displayed, then only the chosen entry is displayed on word.php?
-
Thanks for that.
I should have said that the facility can only be used by registered users - there's already a session variable in existence for the user; where does that leave the session variable you create?
I popped that code you kindly provide into the relevant files but doesn't seem to have an effect..I wonder if I'm missing something - is there any significance behind your calling 'where_clause'?
Thanks
-
Hi
Hope someone can help me please.
I have constructed an audio dictionary and have discovered an error now that I have added a few entries to the database.
A user can search the database and can click on a result to be taken to the content associated with the entry he chooses.
This is the search function;
$search=$_POST["search"]; //get the mysql and store them in $result $result = mysql_query("SELECT word 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> 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><h2>Success! Here's what we found:</h2><br>"; while ($r=mysql_fetch_array($result, MYSQLI_ASSOC)) echo '<h2><tr><td align="left"><a href="word.php?w=' . $r['word'] . '">' . $r['word'] . '</a></td></tr></h2>'; }
You will see that content is displayed in a new file called word.php.
This is relevant code from word.php
$query = "SELECT word,word_type1,sentence1,word_type2,sentence2,word_type3,sentence3 FROM pro_words"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo '<div class="colmask rightmenu">'; echo '<div class="colleft">'; echo '<div class="col1">'; echo '<p>Here are some example sentences that show how we use the word; </p>'; echo '<div id="small"><i> ' . $row['word_type1'] . '</i></div>'; echo '<p><div id="small">' . $row['sentence1'] . '</p></div>'; echo '<div id="small"><i> ' . $row['word_type2'] . '</i></div>'; echo '<p><div id="small">' . $row['sentence2'] . '</p></div>'; echo '<div id="small"><i> ' . $row['word_type3'] . '</i></div>'; echo '<p><div id="small">' . $row['sentence3'] . '</p></div>'; }
The problem is that every entry on the database is echoed in word.php whereas I would like only the entries for the word selected to appear.
Thanks in advance for any help; do say if you need more info.
-
I thought (or rather hoped) that it should be a simple solution and indeed it was - many thanks for that, much appreciated!
-
Hi
I hope someone can help me please.
I am using a media player to stream MP3s in an audio dictionary.
Words and sentences are generated through a MySQL search.
I would like the media player to appear alongside the search result
This is example code for echoing the search result
echo '<p><div id="small">' . $row['sentence1'] . '</p></div>';
This is the code for the media player
<object type="application/x-shockwave-flash" data="/player/dewplayer.swf" width="200" height="30" id="dewplayer" name="dewplayer"> <param name="movie" value="/player/dewplayer.swf" /> <param name="flashvars" value="mp3=' . $row['wordfile'] . '" /> <param name="wmode" value="transparent" /> </object>
So basically I'm looking for the results to echoed then the player to appear next to the search result.
Any help would be much appreciated
Thanks in advance
-
Is there a way to mark the thread as solved?
-
Thanks! I needed to use the first option but all is now well.
Really appreciated - thanks again!
-
Thanks for that - unfortunately the code generates a parse error i.e.
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
Any ideas?
-
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
<code>
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" value="mp3=file.mp3" />';
echo '<param name="wmode" value="transparent" />';
echo '</object>';
</code>
(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.
-
In principle. yes it does. Thank you.
-
Hi
I have a small problem and would be grateful for some help please.
I've been working on an audio dictionary.
The dictionary contains a search function;
$result = mysql_query("SELECT word,sentence1 FROM pro_words WHERE word LIKE '%$search%'");
The results from the search are displayed as links to a new file.
echo '<tr><td align="left"><a href="word.php?w=' . $r['word'] . '">' . $r['word'] . '</a></td></tr>';
Is there a way I can get the file word.php to include other information from the database entry, for example sentence1?
I've been puzzling over this and haven't found a way to make it work, even though it seems like it should be straightforward.
Hope the question is clear and thanks in advance for any help.
-
I actually thought it was a file that I need to put on the server but I opted to ask a stupid question instead!
I think I can figure the rest out now but thanks for your help, I really appreciate it.
How does one mark a thread as solved?
-
that's exactly what I meant, thanks!
I'll need to sort out the links as I get a 404 when I click on the search results, but it looks exactly right!
I have a question on the syntax - <a href="word.php?w=..." - I take it word.php is produced dynamically as a result of the query?.
Thanks for your help.
-
I'd appreciate some help please.
I am building an audio dictionary and have written a working search function.
I would like the search to return a link to the relevant audio file, so that if someone searches for a word in the database they can click on the link to stream that file via their browser.
I have set the database to link to files stored in the site's main folder.
So far drawn a blank with my various efforts.
This is what I have currently;
<?php $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 "<h2>Sorry, but your search did not yield any results.</h2>"; }else { echo '<table align="center" cellspacing="8" cellpadding="8" width="85%"><tr> <td align="left"><b>Word</b></td><td align="left"><b>Example of usage</b></td></tr> '; echo "<h3>This is what we found:</h3><br>"; while ($r=mysql_fetch_array($result, MYSQLI_ASSOC)) echo '<tr><td align="left">' . $r['word'] . '</td><td align="left">' . $r['sentence1'] . '</td></tr>'; } echo '</table>'; // Close the table. } ?>
It works fine as a search function and I have tried adding various iterations around <a href> where the code echoes the search output but without success.
Any help would be very much appreciated.
Thanks in advance
-
Hi
Gnone - Mint is way more complete than Ubuntu out of the box and the Mint guys spend a good while debugging Ubuntu.
KDE - Mandriva 2010 when that comes out in a couple of weeks (I use the RC2 at the moment and it works great).
Will you use onboard sound? If you think about buying a sound card, just check on ALSA support before you buy.
Quick Pagination query (I hope!)
in PHP Coding Help
Posted
Hi there
I adapted the pagination tutorial from here on PHP Freaks so that it can deal with a db query.
The pagination itself works just fine but I have a small issue, hopefully someone can help me please.
I have set up the query so that it won't allow blank searches. The script works perfectly well without the pagination.
With the pagination, the script now returns a few results as well as the 'you didn't enter a search-term' message - can someone help me tidy it up please? I'm guessing that I've put the search=$search term in too many places in the pagination script.
This is the query
This is the pagination
Thanks in advance for any help.