Jump to content

sniperscope

Members
  • Posts

    280
  • Joined

  • Last visited

Posts posted by sniperscope

  1. Hello

    I am facing this kind of problem first time in my life. After a search in google, i found that many people have same problem.

     

    My sql query works at a.php but fail at b.php

    I run same query in phpmyadmin gives me correct result.

     

    a.php and b.php connecting database by using same include file.

     

    cn.php

    $cn	= mysql_connect("localhost", "username", "pass");
    mysql_select_db("sdb", $cn);	
    mysql_set_charset('utf8',$cn);

     

    Here is my sql query:

     

    include('inc/cn.php');
    $sql = "SELECT COUNT(" .date("D"). ") AS total_user FROM staff WHERE " .date("D"). " != '~'";

  2. Here is table structure I got it from export menu.

     

    CREATE TABLE shukkin_master (

      shukin_id int(13) unsigned NOT NULL AUTO_INCREMENT,

      shop_id int(5) NOT NULL,

      User_master_id int(10) DEFAULT NULL,

      User_start varchar(5) NOT NULL COMMENT '00:00',

      User_end varchar(5) NOT NULL COMMENT '00:00',

      User_date int(10) NOT NULL,

      PRIMARY KEY (shukin_id)

    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

  3. Hi.

    I have a user forum which user can enter calendar. Unfortunately, my code is not update/insert more than 10 users.

     

    Here is my code for database query

     

    Thanks for any help

     

    <?php
    session_start();
    ini_set("post_max_size", "30M");
    
    echo (int) $_SERVER['CONTENT_LENGTH'];	// Output is 24525
    
    //$fp = fopen("sql.txt", 'a');
    if(isset($_POST['UserData'][0]))
    {
    	for($i=0; $i<count($_POST['UserData']); $i++)
    	{
    		$UserData	= explode("_", $_POST['UserData'][$i]);
    		$User_id	= $UserData[0];					//	User ID
    		$User_day	= $days_no_kanji[$UserData[1]];	/*	Weekdays
    														0 = Mon 
    														1 = Tue .. etc */
    		$User_work	= $UserData[2];					//	0 = INSERT  1 = UPDATE
    		$User_start	= $_POST[$_POST['UserData'][$i] ."_start"];
    		$User_end	= $_POST[$_POST['UserData'][$i] ."_end"];
    
    		if($User_start != $User_end)
    		{
    			if($User_work == 0)
    				$sql =  "INSERT INTO shukkin_master(shop_id, User_master_id, User_start, User_end, User_date) VALUES('" .$_SESSION['id']. "', '" .$User_id. "', '" .$User_start. "', '" .$User_end. "', '" .$User_day. "')";
    			else
    				$sql = "UPDATE shukkin_master SET User_start = '" .$User_start. "', User_end  = '" .$User_end. "' WHERE User_master_id = '" .$User_id. "' AND User_date = '" .$User_day. "'";
    		}
    		else
    			$sql = "DELETE FROM shukkin_master WHERE User_master_id = '" .$User_id. "' AND User_date = '" .$User_day. "' LIMIT 1";
    		//fwrite($fp, $sql."\n");
    		mysql_query($sql);
    	}
    
    	header('location: index.php?e=0');
    }
    //fclose($fp);
    ?>

  4. Hello

    I have two type of records in my MySQL database gradeA and gradeB

     

    How can i display gradeB records at very last page of pagination.

     

    Let me make myself clear with an example:

     

    Let's say i have 20 records 12 of them is gradeA and 8 of them is gradeB

    I want to display 5 records each page so,

     

    Page #1 Page #2 Page #3 Page #4 Page #5

    gradeA gradeA gradeA gradeB gradeB

    gradeA gradeA gradeA gradeB gradeB

    gradeA gradeA gradeB gradeB gradeB

    gradeA gradeA gradeB gradeB gradeB

    gradeA gradeA gradeB gradeB gradeB

     

    I am using following mysql query but it brings me wrong order.

     

    $trm = EscapeStr($_GET['shopWord']);
    $sql = "SELECT s.id, s.s_name, s.s_type, s.s_area, s.d_area, s.grade, e.news_title, e.news, e.news_icon, cp.c_date 
    	FROM (SELECT id, s_name, s_type, s_area, d_area, grade FROM s_master WHERE s_area LIKE '%kansai%' AND is_active = 'yes') AS s 
    	LEFT JOIN (SELECT s_id, news_id, news_title, MAX(news_date) AS news, news_icon FROM news_event GROUP BY s_id ORDER BY news_id DESC) e ON s.id = e.shop_id 
    	LEFT JOIN coupon cp ON s.id = cp.s_id 
    	WHERE s.s_name LIKE'%" .$trm. "%'
    	GROUP BY s.id 
    	ORDER BY e.news DESC, s.grade ASC";
    $sql_actual	= mysql_query($sql);
    

     

    Above query gives me

     

    Page #1 Page #2 Page #3 Page #4 Page #5

    gradeA gradeA gradeA gradeA gradeB

    gradeA gradeA gradeA gradeA gradeB

    gradeA gradeA gradeA gradeA gradeB

    gradeB gradeB gradeB gradeB gradeB

    gradeB gradeB gradeB gradeB gradeB

  5. Okay, i create some thing for my self however, my javascript/jquery code use up to 300mb for firefox when page executed.

     

    Here is what i wrote:

    <script type="text/javascript" src="../js/jquery.1.5.2.min.js"></script>
    <script type="text/javascript" src="../js/jquery.innerfade.js"></script>
    <script>
    $(document).ready(function(e) {
    	$("#div_1").fadeIn(400);
    	setInterval("SecondDiv()",2000);
    	return false;
    });
    </script>
    </head>
    <body>
    <div style="width:100%; float:left;">
    <div style="float:left; width:29%; text-align:right;"><h3 class="Font">Gathering Info</h3></div>
    <div style="float:left; width:50%; margin-left:6px;" id="div_1"><img src="checked.png" /></div>
    </div>
    
    <div style="width:100%; float:left;">
    <div style="float:left; width:29%; text-align:right;"><h3 class="Font">Entry to DB</h3></div>
    <script>
    function SecondDiv()
    {
    	$("#div_2").fadeIn(400);
    	setInterval("ThirdDiv()",1000);
    	return false;
    }
    </script>
    <div style="display:none; float:left; width:50%; margin-left:6px;" id="div_2"><img src="checked.png" /></div>
    </div>
    
    <div style="width:100%; float:left;">
    <div style="float:left; width:29%; text-align:right;"><h3 class="Font">Creating Account</h3></div>
    <script>
    function ThirdDiv()
    {
    	$("#div_3").fadeIn(400);
    	setInterval("FourthDiv()",4000);
    	return false;
    }
    </script>
    <div style="display:none; float:left; width:50%; margin-left:6px;" id="div_3"><img src="checked.png" /></div>
    </div>
    
    <div style="width:100%; float:left;">
    <div style="float:left; width:29%; text-align:right;"><h3 class="Font">Sending Mail</h3></div>
    <script>
    function FourthDiv()
    {
    	$("#div_4").fadeIn(400);
    	setInterval("FifthDiv()",1000);
    	return false;
    }
    </script>
    <div style="display:none; float:left; width:50%; margin-left:6px;" id="div_4"><img src="checked.png" /></div>
    </div>
    
    <div style="width:100%; float:left;">
    <div style="float:left; width:29%; text-align:right;"><h3 class="Font">Cleaning Temp files</h3></div>
    <script>
    function FifthDiv()
    {
    	$("#div_5").fadeIn(400);
    	setInterval("SixthDiv()",2000);
    	return false;
    }
    </script>
    <div style="display:none; float:left; width:50%; margin-left:6px;" id="div_5"><img src="checked.png" /></div>
    </div>
    
    <div style="width:100%; float:left;">
    <div style="float:left; width:29%; text-align:right;"><h3 class="Font">Done</h3></div>
    <script>
    function SixthDiv()
    {
    	$("#div_6").fadeIn(400);
    	return false;
    }
    </script>
    <div style="display:none; float:left; width:50%; margin-left:6px;" id="div_6"><img src="checked.png" /></div>
    

     

    Could someone help/tell me why this code takes so much memory? What did i do wrong?

     

    Regards

  6. well there is a form tag but i didn't it is necessary to put entire page.

    I cropped with problem part.

     

    That code works fine if there is user less then 20 or something like it.

    And it update weekly schedule.

     

    But when user numbers reach 40 or more than php code is not entering inside of if(isset($_POST['hiddenField'])) block.

  7. Hi

    I have a little strange problem.

     

    I cannot get the post data from my form. It works fine if there is 10 or 15 user but reaching 40 or more than form values not posting.

     

    This is output of size:

    echo (int) $_SERVER['CONTENT_LENGTH'];  ===== 22164

     

    if(isset($_POST['hiddenField']))
    {
        // do some work;
    }
    
    $sql = mysql_query("SELECT id, name FROM user WHERE shop_id = '" .$_SESSION['id']. "' ORDER BY name ASC");
    while($row = mysql_fetch_array($sql))
    {
    echo '			
    <div style="width:100%; border:solid 1px #CCC; background-color:#f1e7e7; margin-bottom:5px;">
    	<table class="tableSmall">
    		<tr><th width="81">' .$row['name']. '</th><th width="71">';
    		echo $grl_pic .'
    		</th>
    			<td width="622"><table width="100%">
    				<tr>';
    				for($j=0; $j<7; $j++)
    				{
    					$sql2  = mysql_query("SELECT user_master_id, user_start, user_end FROM work_master WHERE user_master_id = '" .$row['id']. "' AND date = '" .$days_no_kanji[$j]. "'");
    					$row2 = mysql_fetch_array($sql2);
    					if(mysql_num_rows($sql2) == 0)
    					{
    						$start = "00:00";
    						$end   = "00:00";
    						$m	   = 0;
    					}
    					else
    					{
    						$start = $row2['user_start'];
    						$end   = $row2['user_end'];
    						$m	   = 1;
    					}
    					echo '
    					<th><input type="hidden" name="userData[]" value="' .$row['id']. '_' .$j .'_' .$m. '" />
    						<select name="' .$row['id']. '_' .$j .'_' .$m. '_start">' .ShopHour($start). '</select><br />~<br />
    						<select name="' .$row['id']. '_' .$j .'_' .$m. '_end">' .ShopHour($end). '</select>
    					</th>';
    				}
    				echo '
    				</tr>
    			</table></td>
    		</tr>
    	</table>
    </div>';
    }

     

    Is there someone has any idea why php is not posting?

  8. Hello

    I am crazy and very close to broke my monitor.

    I want to get max record from my table by using max() but result give me wrong title, content ..etc

     

    Here is my entire table

    INSERT INTO `news_event` (`news_id`, `shop_id`, `news_title`, `news_body`, `news_date`, `news_picture`, `news_icon`, `area`) VALUES
    (3, 31,  'title for news_id 3', 'contents for news_id 3', 1335498042, 'news_4f9a153aa2ee7.jpg', 'even', 'kansai'),
    (5, 32,  'title for news_id 5', 'contents for news_id 5', 1335499227, 'news_4f9a19dbd95f7.jpg', 'even', 'kansai'),
    (6, 33,  'title for news_id 6', 'contents for news_id 6', 1335499944, 'news_4f9a1ca8c8870.jpg', 'even', 'kansai'),
    (7, 1,   'title for news_id 7',  'contents for news_id 7',  1335515467, 'news_4f9a594b36886.jpg', 'disc', 'kansai'),
    (8, 2,   'title for news_id 8',  'contents for news_id 8',  1335517136, 'news_4f9a5fd0aa413.jpg', 'disc', 'kansai'),
    (9, 33,  'title for news_id 9', 'contents for news_id 9', 1335524124, 'news_4f9a7b1beca91.jpg', 'even', 'kansai'),
    (10, 33, 'title for news_id 10', 'contents for news_id 10', 1335525670, 'news_4f9a8126ca7c0.jpg', 'even', 'kansai'),
    (11, 33, 'title for news_id 11', 'contents for news_id 11', 1335578508, 'news_4f9b4f8cb1d2c.jpg', 'even', 'kansai'),
    (12, 13, 'title for news_id 12', 'contents for news_id 12', 1335580420, 'news_4f9b57041709a.jpg', 'disc', 'kansai'),
    (13, 31, 'title for news_id 13', 'contents for news_id 13', 1335612652, 'news_4f9bd4ec5606c.jpg', 'even', 'kansai'),
    (14, 3,  'title for news_id 14',  'contents for news_id 14',  1335849216, 'news_4f9f71005ff65.jpg', 'even', 'kansai'),
    (15, 7,  'title for news_id 15',  'contents for news_id 15',  1335866241, 'news_4f9fb3816c2b7.jpg', 'even', 'kansai'),
    (16, 20, 'title for news_id 16', 'contents for news_id 16', 1335935205, 'news_4fa0c0e5d4e7f.jpg', 'disc', 'kansai'),
    (17, 22, 'title for news_id 17', 'contents for news_id 17', 1335941694, 'news_4fa0c0e624e4f.jpg', 'even', 'kansai'),
    (18, 27, 'title for news_id 18', 'contents for news_id 18', 1335942440, 'news_4fa0dd2803ebe.jpg', 'even', 'kansai'),
    (19, 22, 'title for news_id 19', 'contents for news_id 19', 1335942585, 'news_4fa0ddb9e1d94.jpg', 'even', 'kansai'),
    (43, 15, 'title for news_id 43', 'contents for news_id 43', 1336370423, 'news_4fa764f74e627.jpg', 'news', 'kansai'),
    (42, 15, 'title for news_id 42', 'contents for news_id 42', 1336314946, 'news_4fa68c42b9ce7.jpg', 'even', 'kansai'),
    (41, 15, 'title for news_id 41', 'contents for news_id 41', 1336307933, 'news_4fa670dd33875.jpg', 'even', 'kansai'),
    (40, 15, 'title for news_id 40', 'contents for news_id 40', 1336304857, 'news_4fa664d8f0fb5.jpg', 'even', 'kansai'),
    (37, 32, 'title for news_id 37', 'contents for news_id 37', 1336189002, 'news_4fa4a04a5ff6e.jpg', 'even', 'kansai'),
    (38, 33, 'title for news_id 38', 'contents for news_id 38', 1336189330, 'news_4fa4a192a58ad.jpg', 'even', 'kansai'),
    (39, 15, 'title for news_id 39', 'contents for news_id 39', 1336210819, 'news_4fa4f5839b0be.jpg', 'even', 'kansai'),
    (35, 15, 'title for news_id 35', 'contents for news_id 35', 1336138506, 'news_4fa3db0a455a0.jpg', 'news', 'kansai'),
    (36, 15, 'title for news_id 36', 'contents for news_id 36', 1336141371, 'news_4fa3e63b2f60f.jpg', 'news', 'kansai'),
    (34, 15, 'title for news_id 34', 'contents for news_id 34', 1335976993, 'news_4fa164210812e.jpg', 'even', 'kansai');
    

     

    And this my query:

    SELECT `news_id` , `shop_id` , `news_title` , `news_body` , max( `news_date` ) , `news_picture` , `news_icon` , `area`
    FROM news_event
    WHERE area = 'kansai'
    GROUP BY shop_id
    ORDER BY `max(``news_date``)` DESC

     

    My another query:

    SELECT a.*, s.shop_name 
    FROM shop_master s 
    LEFT JOIN (SELECT news_id, shop_id, news_title, news_body, news_picture, news_icon, MAX(news_date) AS news_date FROM news_event GROUP BY shop_id) a ON s.id = a.shop_id 
    WHERE s.shop_area LIKE '%kansai%' 
    GROUP BY a.shop_id 
    ORDER BY a.news_date DESC

     

    I can type 100 different queries but i have no idea why all of them keep getting me wrong order.

    I am trying to get correct order about 4 hours.

     

    Please help me out.

  9. Hello

    I am trying to do something for my personal project such multiple process on single page.

    i have process as below:

    <div id="rightside">

    <h2 id="one">Gathering Info</h2>

    <h2 id="two">Entry to DB</h2>

    <h2 id="three">Creating Account</h2>

    <h2 id="four">Sending Mail</h2>

    <h2 id="five">Cleaning Temp files</h2>

    <h2 id="six">Done</h2>

    <h2 id="seven"><a href="../index.php">Click here go to back</a></h2>

    </div>

     

    And i want to display them one by one with a process bar.

     

    For example:

    when land on page <h2 id="one"> display at first

    and then display <h2 id="two"> when this process reaches to 100%

    then display three  and then four and then .... so on.

     

    Each process has it's own job.

     

    Is this possible? If yes, how can i do that?

    Even i have no idea what terms do i have to search for over internet for finding a sample

     

    Regards

  10. Okay

    I've changed my query something like this

     

    SELECT n.shop_id, n.news, MAX( n.news_date )

    FROM news n

    WHERE n.area = 'sydney'

    GROUP BY n.user_id

    ORDER BY n.news DESC

     

    This time it takes MAX date but news is oldest one

     

    This is how db holds the record

    news_id | user id | news | news_date

    1                3            aaa    2012/4/1

    2                3            ddd    2012/4/4

    3                3            eee    2012/4/5

    4                3            ggg    2012/4/7

     

    but above query gives me this

     

    news_id | user id | news | news_date

    1                3            aaa    2012/4/7

     

    it should give me

     

    news_id | user id | news | news_date

    1                3            ggg    2012/4/7

  11. Hi

    I have a database called news and there is records something like this

     

    news_id | user id | news | news_date

    1                3            aaa    2012/4/1

    2                2            bbb    2012/4/2

    3                5            ccc      2012/4/3

    4                3            ddd    2012/4/4

    5                3            eee    2012/4/5

    6                4            ffff      2012/4/6

    7                3            ggg    2012/4/7

    8                5            hhh    2012/4/8

    9                4            iii        2012/4/9

     

    and i want to get only one record for each user

    so result should be

     

    1  4  iii      2012/4/9  lisa

    2  5  hhh  2012/4/8  mike

    3  3  ggg  2012/4/7  jason

    4  2  bbb  2012/4/2  david

     

    and this is my query

    SELECT n.user_id, n.news, n.news_date, s.user_name, s.city

    FROM news_event n

    LEFT JOIN user_master s ON n.user_id = s.id

    WHERE s.city LIKE '%sydney%'

    AND s.is_activated = 'y'

    GROUP BY n.user_id 

    ORDER BY n.news_date DESC

     

    I know solution is so simple but i lost my capable of thinking after 18 hours of non stop work.

     

    Thanks for any help.

  12. Dear Muddy_Funster

    Seems i didn't make my self clear.  :-[

    I don't want to get pizza shops. I want to get NON-pizza shops

    Shops may be flower shop, or restaurant, or night club but not pizza.

     

    Pizza is just an example.

    Simply user will select some shop from shop category dropdown menu

    and i want to list every thing besides what he selected.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.