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

320 Like 27 Dislike
Previous php-forum Next php-forum
Other php-forum

Is this Safe or Unsafe?
Hi i made a few pages with lots of peoples help now i just want to know if they are safe or not can

upload form file types....
Hey all, I am learning PHP and I am writing a script from the W3C Schools tutorials for uploading fi

Why does my php page download images over and over
Can anybody please explain to me why my php page keeps downloading the images and other items every

Replacing a string on click of a button
Hi! Is there a way to replace a string on a click of a text link?

This is what I've come up w

PHP, Arrays & A Lot Of Confusion
I've been doing basic PHP work on sites for a few years now, but I've never been tempted to learn ho

Sharing PHP Sessions Across Domains
I am in the process of writing a script to share a php session across various domains I have.
The

Insert data in Mysql and move to another page
I'm stuck with this simple problem. I need to insert data in Mysql and then hit submit and move to a

Sub-domains & calling unique content
Hello,

Is there a way use something similar to the $_GET function for a sub-domain? I to be a

i need help with php header and footer
I have designed a header and footer for my site and they seem to be ok when they are running individ

PHP File Upload Problem
Hi, I have written a very simple file upload script but it fails for reasons I can't explain. Hope

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash