listing help

Posted on 16th Feb 2014 07:03 pm by admin


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>

<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>

<div><input type="text" name="TextSearch" size="30" /></div>
<div><input type="submit" name="SubmitTxtSerch" value="LIST" class="Button" /></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'];

// UsrIdentify
$query_user = mysql_query("SELECT * FROM `sn_users` WHERE `sn_users_username` = '".$_COOKIE['loggedin']."'");

print mysql_error();

$RequestUsrID = mysql_fetch_array($query_user);

$UsrID = $RequestUsrID['sn_users_id']; // HERE I CAN TAKE THE USERS ID


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 );

print mysql_error();

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


No comments posted yet

Your Answer:

Login to answer
320 Like 27 Dislike
Previous forums Next forums
Other forums

php forms and database navigatio
I'm new to php and i'd like to post the following.
I have written code to get records f

download directory onto C drive
I am attempting (if this is possible) to write a routine to automatically dump the contents of a dir

PHP and MySQL Question/Help
I have a MySQL db with all my servers and all their details like server name, IP, OS, RAM etc etc 26

Query failed issue with php script but works fine in mssql manager!
hi i have the script below which copies data from one table to another but will only insert new data

SOAP Issue

I am facing some understanding problem with SOAP basic.kindly recommend some SOAP expert.

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