listing help
Posted on
16th Feb 2014 07:03 pm by
admin
Hi,
at first, great new design!!! I like it,
i got a problem,
I want to list some tekst, but there is a users, users can list they own texts, and all teksts, and find words in all texts and in own texts
somethings is weong in my php code because ist dont work
At first here is the form file:
Code: <div>
<form name="TextSearchForm" action="<?php print "list_txt_search.php";?>" method="post" target="main">
<div><select name="sn_text_year" style="text-align: center;">
<option selected="selected"> Year </option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
</select>
</div>
<div><select name="sn_text_author" style="text-align: center;">
<option selected="selected"> choose </option>
<option value=""> all txt </option>
<option value="<?php print $UsrNrID;?>"> my txt </option>
</select>
</div>
<div><input type="text" name="TextSearch" size="30" /></div>
<div><input type="submit" name="SubmitTxtSerch" value="LIST" class="Button" /></div>
</form>
</div>
3 selection is there:
"sn_text_year" (which year is text wroten)
"sn_text_author" (who is the author of the text - this is a cookie whith name of the user)
"TextSearch" (if the user want to find some word in database)
Code: <?php
$TextSearch = $_POST['TextSearch'];
?>
<?php
// UsrIdentify
$query_user = mysql_query("SELECT * FROM `sn_users` WHERE `sn_users_username` = '".$_COOKIE['loggedin']."'");
if(!$query_user){
print mysql_error();
exit;
}
$RequestUsrID = mysql_fetch_array($query_user);
$UsrID = $RequestUsrID['sn_users_id']; // HERE I CAN TAKE THE USERS ID
?>
<?php
if ( $TextSearch == '' && $UsrID ) {
$QeryUsr = "SELECT * FROM `sn_text` WHERE `sn_text_godina` = '" . $_POST['sn_text_year'] . "' AND `sn_text_author` = '" . $UsrID . "' ORDER BY `sn_text_id` DESC";
}
if ( $TextSearch == '' && $UsrID == '' ) {
$QeryUsr = "SELECT * FROM `sn_text` WHERE `sn_text_year` = '".$_POST['sn_text_year']."' ORDER BY `sn_text_id` DESC";
}
if ( $TextSearch && $UsrID == '' ) {
$QeryUsr = "SELECT * FROM `sn_text` WHERE ucase(`area1`) LIKE '%".$TextSearch."%' OR lcase(`area1`) LIKE '%".$TextSearch."%' AND `sn_text_year` = '".$_POST['sn_text_year']."' ORDER BY `sn_text_id` DESC";
}
if ( $TextSearch && $UsrID ) {
$QeryUsr = "SELECT * FROM `sn_text` WHERE ucase(`area1`) LIKE '%".$TextSearch."%' OR lcase(`area1`) LIKE '%".$TextSearch."%' AND `sn_text_year` = '".$_POST['sn_text_year']."' AND `sn_text_author` = '" . $UsrID . "' ORDER BY `sn_text_id` DESC";
// Admin capacityes
$query_user = mysql_query( $QeryUsr );
if(!$query_user){
print mysql_error();
exit;
}
while($request = mysql_fetch_array($query_user)) {
// list
}
?>
As You see You can choose:
1. Only year of text wroten
2. No text search, but identify User
3. No text search, no User identification - mean ilst all text
4. Search text, and identify User (mean searching word only in Users texts)
So, something is wrong, because:
1. when I choose Year, and list all text - list only my texts
2 when I choose Year, and list my texts - list only my texts
3. when I choose Year, and list my texts, with searching text - list only my text without choose
4. when I choos Year, and list all text, with serching text - its work fine
I see its a complicated, I hope, that You can give mi a solution
thanx
No comments posted yet
Your Answer:
Login to answer
320 27
Other forums
WHYISNT THIS MYSQL STATEMNT NOT WORKING? (php)
caps because its absolutely rediculous.
i dontunderstand why its not working. there is a column c
help me, how to find text on an external html site using PHP
Would anyone know how to search an external html file for a work or phrase ?
I was thinking s
Fatal error: Call to a member function fetchrow() on a non-object in C:xamppht
okay i have this query and everytime i add `item_id`=? to it... it gives me the error in the title..
Problem in back link
I have page where i have given javascript back link but when i click on it browser give a message
Help with form post data and arrays
Hi all,
I am new to this forum... It has been awhile since i have worked with arrays, and i a
How to make a mail Form secure?
I want to create an email Form on my web site. How can I make the Form secure so the submitted info
Adding Outlook 2007 items via file upload
I am looking for a way to be able to attach an Outlook item (an email message) in an ASP.NET 3.5 app
Pagination won't carry results past page 2.
Hi all,
I've worked out my pagination script and its paginating fine until I click next from
Code clarification
Hi
In the following code what could be the "search_print()" and where it could be
downloading a file as HTML
Hi.
I'm rather confused with forcing a download. I just want to save dynamic content (from $_SESS