Archive for the ‘MySql’ Category


Inserting each .post data into a <td> using .each

I was wondering if this is possible to be done with jquery. Please see following code.

HTML

<table id="order">
    <tr>
        <td class="order_items"></td>
        <td class="order_items"></td>
        <td class="order_items"></td>
        <td class="order_items"></td>
        <td class="order_items"></td>
        <td class="order_items"></td>
    </tr>
    <tr>
        <td class="order_items"></td>
        <td class="order_items"></td>
        <td class="order_items"></td>
        <td class="order_items"></td>
        <td class="order_items"></td>
        <td class="order_items"></td>
    </tr>
    <tr>
        <td class="order_items"></td>
        <td class="order_items"></td>
        <td class="order_items"></td>
        <td class="order_items"></td>
        <td class="order_items"></td>
        <td class="order_items"></td>
    </tr>
</table>

javascript

$(document).ready(function(){
    $("td.load_ads").each(function(){
        $(this).html("Place a New Ad Free!");
    });
    var count=$("td.load_ads").length;  //18
    $.post('/fetch_orders.php',{count:count},function(data){
        var data_arr=data.split('/end');
        for(index=0;index < data_arr.length;index++){  //for each of the array values got back from fetch orders.php
            .
            ..
            ... Stuck here. How to make each data_arr(ie: each data_arr[index]) go into each td?

.POST script

$count =$_POST['count'];
$query="SELECT * FROM orders1_manager_orders ORDER BY RAND() LIMIT $count";
$db->setQuery($query);
$ads=$db->loadRowList();

foreach($ads as $ads_to_display){
    echo $orders_to_display[9].'/';
    echo $orders_to_display[10].'/end';
}

As explained in the title, i need each order to go into each empty td slot in the above html table. But if i were to put a .each function after my .post All of my tds will turn into the first data gotten from the script, meaning data_arr[1].

Difference between git branch –set-upstream-to vs git remote add origin

I find it little confusing to know the difference between git branch --set-upstream-to vs git remote add origin.

Basically I have a bare repository created with git init --bare which is shared on network so that other developers could also push to it so that we have our projects versioned locally but not sure which command should I run amonsts above two (or if there is some other) to track that central repo.

Can anyone please enlighten on this?

How to "Group By" with multiple "ORDER BY"

I am trying to show the last “date” of a picture that was added,
related to a specific person.

If I enter an additional element under
ORDER BY: ,timestamp DESC There is no change to the result. With
every group I get the date of the first picture.

Some people have one image, others have twent five or more.
There are about 1500 people in the database.

All other data/image is returned correctly.

I cannot find any reference on the internet to my problem,
more a generalisation.

Thanks

The output is:-

Person's - Person -  Nos Of - Last Picture 
Picture     Name    Pictures     "Date"
--------   ------   --------  ------------

image       Tony       5      26th June 2012

image       Beth       1      6th January 2011

image       John       2      5th May 2012

The msql_query is:-

<?php

   function person($person_id) {

      $persons = array();

      $persons_query = mysql_query("
         SELECT `persons`.`person_id`, `persons`.`person_name`, 
         LEFT(`persons`.`person_description`, 50) as `person_description`, 
         `person_images`.`timestamp`, `person_images`.`image_person_id`, 
         `person_images`.`person_name`, `person_images`.`ext`, 
          COUNT(`person_images`.`image_person_id`) as `image_count`
          FROM `persons`
          LEFT JOIN `person_images`
          ON `persons`.`person_id` = `person_images`.`person_id`
         LEFT JOIN `person_images`
         ON `persons`.`person_id` = `person_images`.`person_id`
         WHERE `persons`.`member_id` = ".$_SESSION['member_id]
         GROUP BY `persons`.`person_id`
         ORDER BY `persons`.`person_name`, 
     ");

     While ($persons_row = mysql_fetch_assoc($persons_query)) {

        $persons[] = array(
            'person_id'              => $persons_row['person_id'],
           'person_name'            => $persons_row['person_name'],
           'person_description'     => $persons_row['person_description'],
           'timestamp'               => $persons_row['timestamp'],
           'image_person_id'         => $persons_row['image_person_id'],
           'ext'                     => $persons_row['ext'],
           'count'                   => $persons_row['image_count']
        );
     }
     return $persons;
   }
?>

Java Script Validation-database

I have a Java Script code(below) which validates the mobile number.and working fine.But the problem I am facing is both the valid and invalid mobile number is being inserted into database.I want only the valid mobile Number to be inserted to database..
The Code is as follows.Can any one suggest any ideas or any suggestions to change the code?Please…

function CheckINumber(INumber)

{


var INum = /^[+]{1}[0-9]{2}-\d{10}$/; 



if(INum.test(INumber)) 



 {  
             alert("Your Mobile Number Is Valid.");  
 }   

else 
{  
             alert("Your Mobile Number Is Not Valid.");   
       }  
}          




<input name="Upload" type="submit" height="25" class="uploadbutton"  onClick="CheckINumber(mobile.value);"   

Importing .csv file into mysql in php

I have a .csv file with me but i am unable to import it into the database. I have parsed my .csv file using the below query. Can you please help me how to insert data into MySql.

My code is:-
$fp = fopen(‘test.csv’,'r’) or die(“can’t open file”);
print “\n”;

while($csv_line = fgetcsv($fp,1024)) 
{
print '<tr>';
for ($i = 0, $j = count($csv_line); $i < $j; $i++) {
    print '<td>'.$csv_line[$i].'</td>';
    $data[] = $csv_line[$i];
}
print "</tr>\n";
}
print '</table>\n';
fclose($fp) or die("can't close file");

php based full text search of MySQL data?

If this is true:

How can one full text search with PHP only? In other words, how can the search actually be processed in PHP while the data stays in MySQL?

Many thanks in advance!

How to send an email attachment using PHP [closed]

Possible Duplicate:
Send email with attachments in PHP?

How can I send an email attachment using PHP without installing any thing and just using the mail() function?

select query with date condition

I had a issue with select query with date condition . Query Not give proper result I don’t know Why ? Please Help Me Out Thanks In Advance.Created_Date field in database had value between 2013-01-01 to
2013-01-31

 SELECT * FROM (`cms_product`) WHERE `cms_product`.`Created_Date` >= 2013-01-01  and`cms_product`.`Created_Date` <= 2013-01-31 ;

    Created_Date field is in Datetime.

How to delete all files except one from a directory using PHP?

I have a few directories with some files in them:

/test1/123.jpg
/test1/124.jpg
/test1/125.jpg
/test2/123.jpg
/test2/124.jpg

I want to delete all except for /test1/124.jpg or /test2/124.jpg?

I know the directory name and the file name. Is there a way of doing that in a Linux environment with php and maybe unlink?

RoR’s session_write_close, http manipulation, and page persistence?

I love RoR’s ability to manipulate database data, and since I just read this

http://highscalability.com/blog/2010/3/23/digg-4000-performance-increase-by-sorting-in-php-rather-than.html

that makes me want to convert even more since I now have to rewrite my server-side anyways.

However, my site needs to be faster (almost as fast as I think I can get it when I finally get spdy), and that session serialization stuff really holds me back. Can ruby release the session like PHP so that subsequent AJAX calls can start? Can it turn it back on like PHP so that the AJAX page doesn’t have to permenantly isolate itself from the session at a single point?

Also, can it fully manipulate HTTP like PHP (unlike .net). I can’t stand that I have to learn some new ms system every time I want a different kind of page. With PHP, it’s always the same no matter what page type. With .net, I have to learn about some new “feature” that ends up limiting me (like no session_write_close) equivalent.

Here’s something I’ve found doesn’t happen in either php or .net: page persistence. Can ruby continue running yet sever the http connections?

Many thanks in advance!

source:stackoverflow.com
Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories