Tuesday, 4 August 2015

PHP _Script_ to_ select _multiple _ids _from _mysql database

07:06

(1)<?php


$coursename=$_POST['coursename'];


$semester=$_POST['semester'];

echo '<h3>';

echo '<table border=0>';

echo '<tr> <td>';
echo "CourseName&nbsp;=".$coursename;

echo '</td> <td>&nbsp;&nbsp;&nbsp;</td>';

echo '<td>';

echo "Semester&nbsp;=".$semester;

echo '</td></tr>';
echo '</table>';

echo '</h3>';

$con=mysql_connect("localhost","root","");



mysql_select_db("itexam",$con);


$sql="select * from   notes    where   coursename='$coursename'    AND semester='$semester'  order by subject";


$result=mysql_query($sql) or die(mysql_error());

echo '<h4>';
echo '<table border=0>';

echo '<tr><td>id</td><td><h2>Subject Name </h2></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td><h2>Unit </h2></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td> <td> <h2>Download Link</h2></td></tr>';

;
echo '<form action="downloadall.php" method=post>';
while($row=mysql_fetch_array($result))

{


echo ' <tr><td><input type=checkbox  name=data[]  value="'.$row['id'].'"></td><td>"'.$row['subject'].'" </td><td>&nbsp;</td><td>"'.$row['unit'].'" </td><td>&nbsp;</td>
<td>
<button ><a href=../proudct_images/download1.php?download_file="'.$row['file'].'">
Download file</a></button> </td></tr>';










}
echo '</table>';


echo '

     <input type=submit  name=submit value=Download-all>

 </form>';

?>

(2)



<?php



//$data=$_POST['data'];



//$test=implode(',',$data);

//echo $test;

include("connect.php");


//$sql="select  file from notes where id IN('$test')";




$ids=$_POST['data'];



$num_list=implode(',', $ids);







echo $sql = "select * FROM notes WHERE  id IN($num_list)";




$result=mysql_query($sql) or die(mysql_error());



while($row=mysql_fetch_array($result))

{



echo '<a href=../proudct_images/download1.php?download_file="'.$row['file'].'">

Download file</a>';










}





?>

Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

1 comments:

  1. Good article about PHP. Thanks for sharing this information about PHP. Its really useful for me. Best PHP training in Bangalore

    ReplyDelete

PHP Training Mumbai, PHP MySQL Training Mumbai, PHP Course Mumbai, PHP Institute Mumbai

 

© 2013 PHP TRAINING IN MUMBAI BY OM SIR . All rights resevered. Designed by OM SIR

Back To Top