Jump to content

xavier.rayne

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

xavier.rayne's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. here is the table structure for table clean: CREATE TABLE `clean` ( `type` int(2) NOT NULL default '0', `msg` text, `popup1` int(11) default NULL, `popup2` int(11) default NULL, `empId` int(11) default NULL, PRIMARY KEY (`type`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; the type field holds 3 rows of data: type 1 for daily popup type 2 for weekly popup type 3 for biweekly popup msg holds the popup message popup1 holds the timestamp for 1st time popup popup2 holds the timestamp for 2nd time popup empId holds the member that login to the system Thanks alot.
  2. Sorry, guy Here is the code for the page that i want the popup box to appear: <?php session_start(); if(isset($_SESSION["session_post"])) { if ($_SESSION['session_post'] == "Admin") { include("../../config_sales.php"); $date = date("g:i A Y-m-d"); $h = substr($date,0,2); if($h>=10){ $h = substr($date,0,2); $min = substr($date,3,2); $d1 = substr($date,9); //get current date $m1 = substr($date,14,2); $am = substr($date,6,2); }else{ $h = substr($date,0,1); $min = substr($date,2,2); $d1 = substr($date,; $m1 = substr($date,13,2); $am = substr($date,5,2); } if($am=="PM" && $h<12){ $h = $h+12; }else{ $h=$h; } $t1 = substr($date,0,; //assign 1st popup timestamp $popup = mktime($h,$min,0,date("m"),date("d"),date("Y")); $day = diswk($d1); $tomorrow = day_tomorrow($d1); $dT =substr($tomorrow,8,2); $popT = mktime($h,$min,0,date("m"),$dT,date("Y")); $a = date("g:i A Y-m-d",$popT); $week = week($d1); $dW =substr($week,8,2); $popW = mktime($h,$min,0,date("m"),$dW,date("Y")); $b = date("g:i A Y-m-d",$popW); $biweek = bi_week($d1); $dB =substr($week,8,2); $popB = mktime($h,$min,0,date("m"),$dB,date("Y")); $c = date("g:i A Y-m-d",$popB); $popup2 = ""; //check whether there is someone login before daily $queryD = "SELECT * FROM clean WHERE popup2<='$popup' AND type='1'"; echo $queryD; $resultD = mysql_query($queryD); $numD =mysql_num_rows($resultD); $rowD = mysql_fetch_array($resultD); $msg = $rowD['msg']; if($numD==1){ //popup message?> <script>alert('Have you clean the toilet?');</script> <script>alert('Is all of your jobs are done?');</script> <? $queryUD = "UPDATE clean SET popup1='$popup' WHERE popup2<='$popup'"; echo $queryUD; mysql_query($queryUD); $query = "SELECT * FROM clean WHERE popup2<='$popup' AND type='1'"; echo $query; $result = mysql_query($query); $row = mysql_fetch_array($result); $p1 = $row['popup1']; $day1 = date("g:i A Y-m-d",$p1); $h2 = substr($day1,0,2); if($h>=10){ $h2 = substr($day1,0,2); $min2 = substr($day1,3,2); $day2 = substr($day1,9); $m2 = substr($day1,14,2); $am = substr($day1,6,2); }else{ $h2 = substr($day1,0,1); $min2 = substr($date,2,2); $day2 = substr($day1,; $am = substr($day1,5,2); } if($am=="PM" && $h<12){ $h = $h+12; }else{ $h=$h; } $tomorrow2 = day_tomorrow($day2); $y2 = substr($tomorrow2,0,4); $m2 = substr($tomorrow2,5,2); $d2 = substr($tomorrow2,8,2); $to2 = mktime($h2,$min2,0,$m2,$d2,$y2); $queryUD2 = "UPDATE clean SET popup2='$to2' WHERE popup1='$popup'"; echo $queryUD2; $resultUD2 = mysql_query($queryUD2); }else if ($numD==0){ //popup message?> <script>alert('Have you clean the toilet?');</script> <script>alert('Is all of your jobs are done?');</script> <? $queryI = "UPDATE clean SET popup1='$popup', popup2='$popT' WHERE type='1'"; echo $queryI; mysql_query($queryI); } //check whether there is someone login before weekly $queryW = "SELECT * FROM clean WHERE popup2<='$popup' AND type='2'"; echo $queryW; $resultW = mysql_query($queryW); $numW = mysql_num_rows($resultW); //echo "NUM".$numW; $rowW = mysql_fetch_array($resultW); $msg = $rowW['msg']; if($numW==1){ //echo $msg; //popup message?> <script>alert('Have you clean the indoor air-conditioner?');</script> <? $queryUW = "UPDATE clean SET popup1='$popup' WHERE popup2='$popup'"; echo $queryUW; mysql_query($queryUW); $query2 = "SELECT * FROM clean WHERE popup2<='$popup' AND type='2'"; echo $query2; $result2 = mysql_query($query2); $row2 = mysql_fetch_array($result2); $p1 = $row2['popup1']; $day1 = date("g:i A Y-m-d",$p1); //echo "DAY!".$day1; $h2 = substr($day1,0,2); if($h>=10){ $day2 = substr($day1,9); $m2 = substr($day1,14,2); }else{ $day2 = substr($day1,; $m2 = substr($day1,13,2); } //echo "DD".$day2; $week2 = week($day2); //echo "WEEK2 ".$week2; $d2 = substr($week2,8,2); //echo $d2.",".$m2.",".$y2; $m2 = substr($week2,5,2); $y2 = substr($week2,0,4); $popup2 = mktime(2,0,0,$m2,$d2,$y2); $queryUW2 = "UPDATE clean SET popup2='$popup2' WHERE popup1='$popup'"; echo $queryUW2; $resultUW2 = mysql_query($queryUW2); }else if ($numW==0){ $queryI2 = "UPDATE clean SET popup1='$popup',popup2='$popW' WHERE type='2'"; echo $queryI2; mysql_query($queryI2); } //check whether there is someone login before biweekly $queryBW = "SELECT * FROM clean WHERE popup2<='$popup' AND type='3'"; echo $queryBW; $resultBW = mysql_query($queryBW); $numBW = mysql_num_rows($resultBW); $rowBW = mysql_fetch_array($resultBW); $msg = $rowBW['msg']; if($numBW==1){ //popup message?> <script>alert('Have you clean the outdoor air-conditioner?\n');</script> <? $queryUBW = "UPDATE clean SET popup1='$popup' WHERE popup2<='$popup'"; echo $queryUBW; mysql_query($queryUBW); $query3 = "SELECT * FROM clean WHERE popup2<='$popup' AND type='3'"; echo $query3; $result3 = mysql_query($query3); $row3 = mysql_fetch_array($result3); $p1 = $row3['popup1']; $day1 = date("g:i A Y-m-d",$p1); //echo "DAY!".$day1; $h2 = substr($day1,0,2); if($h>=10){ $day2 = substr($day1,9); $m2 = substr($day1,14,2); }else{ $day2 = substr($day1,; $m2 = substr($day1,13,2); } //echo "DD".$day2; $biweek2 = bi_week($day2); echo $biweek2; $d2 = substr($biweek2,8,2); $m2 = substr($biweek2,5,2); $y2 = substr($biweek2,0,4); $popup2 = mktime(15,0,0,$m2,$d2,$y2); $queryUW2 = "UPDATE clean SET popup2='$popup2' WHERE popup1='$popup'"; echo $queryUW2; $resultUW2 = mysql_query($queryUW2); }else if ($numBW==0){ //popup message?> <!--<script>alert('Have you clean the toilet?');</script> <script>alert('Is all of your jobs are done?');</script>--> <? $queryI3 = "UPDATE clean SET popup1='$popup', popup2='$popB' WHERE type='3'"; echo $queryI3; mysql_query($queryI3); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>Sky Online Sales Reporting System - Menu Admin</title> </head> <body> <font color="#FF0000"> <center><h3>Sky Online Sales Reporting System</h3></center></font> <tr align="center"><td colspan="10" class="content"><p class="welcometxt"><?php echo "Welcome, " .$_SESSION['session_user']; ?></p> <p class="welcometxt"> </p></td></tr> <TR> <TD COLSPAN=10 valign="top" class="content" height=""><table cellpadding="3" cellspacing="5" border="0" align="center" width="449" class="content"> <tr> <td><a href="registration.php"><img src="images/emp.jpg" width="40" height="40" border="0" /></a></td> <td><a href="registration.php">Employee Registration </a> </td> <td><a href="employeeList.php"><img src="images/edit.jpg" width="40" height="40" border="0" /></a></td> <td><a href="employeeList.php">Employee Profile </a></td> </tr> <tr> <td><a href="registrationF.php"><img src="images/mMember.gif" width="40" height="40" border="0" /></a></td> <td><a href="registrationF.php">Franchiser Registration </a> </td> <td><a href="franchiserList.php"><img src="images/edit.jpg" width="40" height="40" border="0" /></a></td> <td><a href="franchiserList.php">Franchiser Profile </a></td> </tr> <tr> <td><a href="menuReport.php"><img src="images/sales.jpg" width="40" height="40" border="0" /></a></td> <td><a href="menuReport.php">Sales Report </a> </td> <td><a href="salesView.php"><img src="images/sales1.jpg" width="40" height="40" border="0" /></a></td> <td><a href="salesView.php">Edit Sales</a> </td> </tr> <tr> <td><a href="branchView.php"><img src="images/branch.jpg" width="40" height="40" border="0" /></a></td> <td><a href="branchView.php">Branch </a> </td> <td><a href="changepswdA.php"><img src="images/mPsw.gif" width="40" height="40" border="0" /></a></td> <td><a href="changepswdA.php">Change Password </a></td> </tr> <tr> <td><a href="resetpswd.php"><img src="images/reset.jpg" width="40" height="40" border="0" /></a></td> <td><a href="resetpswd.php">Reset Password </a> </td> <td><a href="../signout.php"><img src="images/mOut.gif" width="40" height="40" border="0" /></a></td> <td><a href="../signout.php">Sign Out</a> </td> </tr> </table> </body> </html> <?php } else {header("Location:../signin.php?msg=You do not have the authority to access the page");} } else {header("Location:../signin.php");} function diswk($d){ $y1= substr($d,0,4); $m1= substr($d,5,2); $d1= substr($d,8,2); $wk = date("l", mktime(0,0,0, $m1, $d1, $y1)); return $wk; } function bi_week($d){ $y1= substr($d,0,4); $m1= substr($d,5,2); $d1= substr($d,8,2); $biweek = date("Y-m-d", mktime(0,0,0, $m1, $d1+14, $y1)); return $biweek; } function day_tomorrow($d){ $y1= substr($d,0,4); $m1= substr($d,5,2); $d1= substr($d,8,2); $tomorrow = date("Y-m-d", mktime(0,0,0, $m1, $d1+1, $y1)); return $tomorrow; } function week($d){ $y1= substr($d,0,4); $m1= substr($d,5,2); $d1= substr($d,8,2); $week = date("Y-m-d", mktime(0,0,0, $m1, $d1+7, $y1)); return $week; } ?> The 'Have you clean the toilet?' and 'Is all of your jobs are done?' popup for the 1st person who login in a day for everyday. The 'Have you clean the indoor air-conditioner?' popup for the 1st person who login in a week for every week. The 'Have you clean the outdoor air-conditioner?' popup for the 1st person who login in a day for twice a week. Thanks.
  3. Hi,there. I'm quite new to php and now working with the popup box that appears for the first person who login to the system daily, weekly and bi-weekly. So,how to check whether the person is the first person who login to the system and popup a message box for him? I really have no idea on it :'( Please help me. Thanks.
  4. I've test one part of my program, that is the selected date with selected branch part and below is the code for that: <? if(!empty($branch)){ $queryB = "SELECT * FROM branch WHERE name ='$branch'"; $resultB = mysql_query($queryB); $rowB = mysql_fetch_array($resultB); $branchid = $rowB['branchId']; $name = $rowB['name']; $queryE = "SELECT * FROM sales WHERE branchId='$branchid'"; $resultE = mysql_query($queryE); $numE = mysql_num_rows($resultE); if($numE!=0){ echo "<table><tr><td width=680 colspan=5><table border=0 cellpadding=0 cellspacing=0 class=table width=100%></td></tr>"; echo "<tr bgcolor=#000066><td colspan=3><center><font color=ffffff><b>Branch: $name</b></font></center></td></tr>"; $overallTotal[] = displayDay($from,$to,$branchid); echo "</table></td>"; echo "<tr><td colspan=5 height=5><hr></td></tr></table>"; ?><p class="pagebreak"></p><?php } echo "<table><tr><td width=600 colspan=5 align=right><font color=red><b>Overall Total Sales: </font></td><td><font color=red><b> RM ".array_sum($overallTotal)."</font></td></tr></table>"; } //end if(!empty($name)) ?> <?php function displayDay($from,$to,$branchid) { //while($from<=$to){ $wk = diswk($from); $queryDate = "SELECT DISTINCT date1 FROM sales WHERE date1 BETWEEN '$from' AND '$to'"; $resultDate = mysql_query($queryDate); while($rowDate = mysql_fetch_array($resultDate)) { $date[] = $rowDate['date1']; } echo "<tr bgcolor=#6699FF><td colspan=3><center><b>$from $wk</center></td></tr>"; echo "<tr bgcolor=#FDDFFC><td valign=top><p><span style=color: #FFFFFF;><b>Time </span></p></td><td valign=top><p><span style=color: #FFFFFF;><b>Employee Name </span></p></td><td valign=top><p><span style=color: #FFFFFF;><b>Total Sales(RM) </span></p></td></tr>"; if(isset($_GET['f'])){ $selectedDate = $_GET['f']; echo "AA".$selectedDate; }else{ $selectedDate = $date[0]; } $queryS = "SELECT DISTINCT empId FROM sales WHERE date1='$from' AND branchId=$branchid"; $resultS = mysql_query($queryS); $total = 0; while($rowS = mysql_fetch_array($resultS)) { $empid = $rowS['empId']; $queryE = "SELECT * FROM sales WHERE date1='$from' AND empId=$empid ORDER BY timeStart"; $resultE = mysql_query($queryE); $empTotal =0; while ($rowE = mysql_fetch_array($resultE)){ //get sales amount for each employee $amount = $rowE['amt']; $start = $rowE['timeStart']; $amount1[] = $rowE['amt']; } //calculate employee's total sales $empTotal+=$amount; //show employee name $query3 = "SELECT * FROM employee WHERE empId=$empid"; $result3 = mysql_query($query3); $row3 = mysql_fetch_array($result3); $name = $row3['name']; //show branch name $query4 = "SELECT * FROM branch WHERE branchId=$branchid"; $result4 = mysql_query($query4); $row4 = mysql_fetch_array($result4); $branch = $row4['name']; echo "<tr bgcolor=#D8FCFA><td>$start</td><td>$name</td><td><font color=0000ff> $empTotal </td>"; $total+=$empTotal; //calculate daily total $netTotal=array_sum($amount1); } //end while ($rowS = mysql_fetch_array($resultS)) echo "<tr><td align=right colspan=2><font color=red>Daily Total Sales: </font></td><td><b>$total</td>"; $from = day_tomorrow($from); //} //end while($from<=$to) //hyperlink for each day's sales for($i=0;$i<=count($date);$i++){ echo "<a href=daily_sales.php?b=$branch&f=$from&t=$to>".$date[$i].";</a>"; } return $netTotal; } function day_tomorrow($d){ $y1= substr($d,0,4); $m1= substr($d,5,2); $d1= substr($d,8,2); $tomorrow = date("Y-m-d", mktime(0,0,0, $m1, $d1+1, $y1)); return $tomorrow; } function diswk($d){ $y1= substr($d,0,4); $m1= substr($d,5,2); $d1= substr($d,8,2); $wk = date("l", mktime(0,0,0, $m1, $d1, $y1)); return $wk; } ?> It can link to the page that i want to view but why after i've selected a date, it will disappeared and how if i wish to select it again??? Thanks.
  5. Hi, there. I'm currently doing on a sales system assignment which can generate daily report order by branch and date. There is a report menu which users can choose the branch and date that they would like to view. my currently report form is to show all the chosen date report in one page.so if the user choose from 1st of the month to 31st of the month, then the page will become so long. So, is there any means to generate the daily report that just show one-day daily record with the hyperlinks of other selected date below the report.if the user wish to see other day's daily report,then he can click on the hyperlink itself. Below is my code: There are two section in my daily report: - selected date without selected branch(show all branches) - selected date with selected branch <?php $date = date("Y-m-d"); if(isset($_GET['b'])){ $branch = $_GET['b']; $from = $_GET['f']; $to = $_GET['t']; }else{ $branch = $_POST['branch']; $from = $_POST['from']; $to = $_POST['to']; }?> <?php echo "<form action=menuReport.php method=post> <p>"; //show records from all branches if(empty($branch)){ while($from<=$to){ $wk=diswk($from); $querySales = "SELECT * FROM sales WHERE date1='$from' ORDER BY timeStart"; $resultSales= mysql_query($querySales); $numSales = mysql_num_rows($resultSales); if($numSales==0){ echo "<table><tr><td width=680 colspan=5><table border=0 cellpadding=0 cellspacing=0 bgcolor=#FDDFFC class=table width=100%></table></td></tr>"; echo "<tr><td colspan=5><center><font color=red>No Record on $from has been found!</font></center></td></tr>"; echo "</table>"; } if($numSales!=0){ echo "<table><tr><td width=680 colspan=5><table border=0 cellpadding=0 cellspacing=0 class=table width=100%></td></tr>"; echo "<tr bgcolor=#6699FF><th colspan=5><font color=#FFFFFF>$from $wk</font></th></tr>"; //echo "<tr bgcolor=#D8FCFA><th colspan=5>Branch $name</th></tr><tr bgcolor=#FDDFFC><th>Time</th><th>Employee Name</th><th>Sales (RM)</th></tr>"; $i=0; while($i<$numSales){ $start = mysql_result($resultSales,$i,'timeStart'); $empID = mysql_result($resultSales,$i,'empId'); $amt = mysql_result($resultSales,$i,'amt'); $total+=$amt; $queryE = "SELECT name,branchId FROM employee WHERE empId='$empID'"; $resultE = mysql_query($queryE); $rowE = mysql_fetch_array($resultE); $branchid= $rowE['branchId']; $empName = $rowE['name']; $queryB = "SELECT name FROM branch WHERE branchId='$branchid'"; $resultB = mysql_query($queryB); $rowB = mysql_fetch_array($resultB); $name = $rowB['name']; echo "<tr bgcolor=#D8FCFA><th colspan=5>Branch $name</th></tr><tr bgcolor=#FDDFFC><th>Time</th><th>Employee Name</th><th>Sales (RM)</th></tr>"; echo "<tr><td><center>$start</td><td><center>$empName</td><td><center>$amt</td></tr>"; $i++; } //end while($i<$numSales) echo "</table></td><tr><td colspan=5 height=5><hr></td></tr></table>"; } //end if($numSales!=0) $from = day_tomorrow($from); } //end while($from<=$to) //hyperlink for each day's sales /*for($i=0;$i<=count($date);$i++){ echo "<a href=daily_sales.php?f=$from&&t=$to>".$date[$i].";</a>"; }*/ echo "<table><tr><td width=600 colspan=5 align=right><font color=red><b>Overall Total Sales: </font></td><td><font color=red><b> RM $total</b></font></td></tr></table>"; } //end if(empty($name)) else if(!empty($branch)){ $queryB = "SELECT * FROM branch WHERE name ='$branch'"; $resultB = mysql_query($queryB); $rowB = mysql_fetch_array($resultB); $branchid = $rowB['branchId']; $name = $rowB['name']; $queryE = "SELECT * FROM sales WHERE branchId='$branchid'"; $resultE = mysql_query($queryE); $numE = mysql_num_rows($resultE); if($numE!=0){ echo "<table><tr><td width=680 colspan=5><table border=0 cellpadding=0 cellspacing=0 class=table width=100%></td></tr>"; echo "<tr bgcolor=#000066><td colspan=3><center><font color=ffffff><b>Branch: $name</b></font></center></td></tr>"; $overallTotal[] = displayDay($from,$to,$branchid); echo "</table></td>"; echo "<tr><td colspan=5 height=5><hr></td></tr></table>"; ?><p class="pagebreak"></p><?php } echo "<table><tr><td width=600 colspan=5 align=right><font color=red><b>Overall Total Sales: </font></td><td><font color=red><b> RM ".array_sum($overallTotal)."</font></td></tr></table>"; } //end if(!empty($name)) ?> </center></table></form> </body> </html> <?php } else {header("Location:../signin.php?msg=You do not have the authority to access the page");} } else {header("Location:../signin.php");} ?> <?php function displayDay($from,$to,$branchid) { while($from<=$to){ $wk = diswk($from); $queryDate = "SELECT DISTINCT date1 FROM sales WHERE date1 BETWEEN '$from' AND '$to'"; $resultDate = mysql_query($queryDate); while($rowDate = mysql_fetch_array($resultDate)) { $date[] = $rowDate['date1']; } echo "<tr bgcolor=#6699FF><td colspan=3><center><b>$from $wk</center></td></tr>"; echo "<tr bgcolor=#FDDFFC><td valign=top><p><span style=color: #FFFFFF;><b>Time </span></p></td><td valign=top><p><span style=color: #FFFFFF;><b>Employee Name </span></p></td><td valign=top><p><span style=color: #FFFFFF;><b>Total Sales(RM) </span></p></td></tr>"; if(isset($_GET['f'])){ $selectedDate = $_GET['f']; echo "AA".$selectedDate; }else{ $selectedDate = $date[0]; } $queryS = "SELECT DISTINCT empId FROM sales WHERE date1='$from' AND branchId=$branchid"; $resultS = mysql_query($queryS); $total = 0; while($rowS = mysql_fetch_array($resultS)) { $empid = $rowS['empId']; $queryE = "SELECT * FROM sales WHERE date1='$from' AND empId=$empid ORDER BY timeStart"; $resultE = mysql_query($queryE); $empTotal =0; while ($rowE = mysql_fetch_array($resultE)){ //get sales amount for each employee $amount = $rowE['amt']; $start = $rowE['timeStart']; $amount1[] = $rowE['amt']; } //calculate employee's total sales $empTotal+=$amount; //show employee name $query3 = "SELECT * FROM employee WHERE empId=$empid"; $result3 = mysql_query($query3); $row3 = mysql_fetch_array($result3); $name = $row3['name']; //show branch name $query4 = "SELECT * FROM branch WHERE branchId=$branchid"; $result4 = mysql_query($query4); $row4 = mysql_fetch_array($result4); $branch = $row4['name']; echo "<tr bgcolor=#D8FCFA><td>$start</td><td>$name</td><td><font color=0000ff> $empTotal </td>"; $total+=$empTotal; //calculate daily total $netTotal=array_sum($amount1); } //end while ($rowS = mysql_fetch_array($resultS)) echo "<tr><td align=right colspan=2><font color=red>Daily Total Sales: </font></td><td><b>$total</td>"; $from = day_tomorrow($from); } //end while($from<=$to) //hyperlink for each day's sales for($i=0;$i<=count($date);$i++){ echo "<a href=daily_sales.php?b=$branch&f=$from&t=$to>".$date[$i].";</a>"; } return $netTotal; } function day_tomorrow($d){ $y1= substr($d,0,4); $m1= substr($d,5,2); $d1= substr($d,8,2); $tomorrow = date("Y-m-d", mktime(0,0,0, $m1, $d1+1, $y1)); return $tomorrow; } function diswk($d){ $y1= substr($d,0,4); $m1= substr($d,5,2); $d1= substr($d,8,2); $wk = date("l", mktime(0,0,0, $m1, $d1, $y1)); return $wk; } ?> Please help me. Thanks alot.
  6. I created a dropdown list that display all the available group name to let users to choose a group that they want to upload photos..but after the user choosing a group and submit one image, the dropdown list cannot display any group name to let users to choose again. Why??? Thanks
  7. Hi,there I've manage to settle the uploading problem but the dropdown list is still available for once only. Why ??? Here is my new edited code: <?php session_start(); define ("MAX", 32); if(isset($_SESSION["session_post"])) { if ($_SESSION['session_post'] == "admin") { include("../config_pic.php"); // This page allows users to upload files to the server. if (isset($_POST['submit'])) { include("../config_pic.php"); // Add the record to the database. $gid = $_POST['grpid']; $queryA = "SELECT * FROM images WHERE grpId='$gid'"; $resultA = mysql_query($queryA); $count = mysql_num_rows($resultA); $row = mysql_fetch_array($resultA); $id = $row['Id']; $path = "http://localhost/photo_album/mall/images/"; $filename = ""; if ($count < MAX) { if ($_FILES['upload']['name'] != "") { // Create the file name and path name if ($_FILES['upload']['name'] != ""){ $filename = $_FILES['upload']['name']; $path = $path.$filename; } else{ $path = ""; } $queryI = "INSERT INTO images (name, grpId) VALUES ('$filename', '$gid')"; $resultI = @mysql_query ($queryI); } } else { echo "<font color='red'>You have reach the maximum limit of photo upload!<br>If you wish to upload more photos, please delete the photos you don't want."; } $suceed = 0; if ($filename != "" && $gid != ""){ if(move_uploaded_file($_FILES['upload']['tmp_name'], "mall/images/$filename")){ $suceed = 1;} else {$suceed = 0;} } if($suceed ==1) {$msg="The file has been uploaded!";} else {$msg="<font color='red'>Your submission could not be processed due to a system error. We apologize for any inconvenience.";} mysql_close(); } ?> <html> <body> <p align="right"><a href="gallery.php">Back To Gallery</a></p> <br><br> <table border="0" align="center" width="400"> <tr><td> <table cellpadding="3" cellspacing="0" border="0" valign="top" align="center" width="400"> <tr><td><span style="color:#FF0000; font-size:13px"><?php echo (isset($msg)) ? $msg : " <br>" ?></span></td></tr> </table> </td></tr> <tr><td> <table cellpadding="5" cellspacing="0" border="0" valign="top" align="center" width="400" bgcolor="#CCCCFF"> Please select the group name that you would like to upload images before starting upload.Thanks for cooperation. <form id="form1" name="form1" method="post" action="upload_image.php"><center> <table> <tr> <td colspan="2">Please select group name: <select name="grpId" onChange='this.form.submit()'> <option>Group</option> <?php $result=mysql_query("Select Id, description from groupname ORDER BY Id"); while($row=mysql_fetch_array($result)) { ?> <option value="<?php echo $row['Id'];?>"><?php echo $row['description'];?> </option> <?php }?> </select> </td></tr></table></form> <p><p> <table cellpadding="5" cellspacing="0" border="0" valign="top" align="center" width="400" bgcolor="#CCCCFF"> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000000"> <tr><td colspan="2" bgcolor="#000000" align="center"><span style="color:#FFFFFF; font-size:15px"><strong>Upload Photo</strong></span> </td> </tr> <tr><td colspan="2" height="10"></td></tr> <?php $gid = $_POST['grpId'] ?> <tr><td width="80" align="center"><span style="color:#000000; font-size:13px"><b>Group:</b></span></td> <td width="300"><input type="text" name="grpid" value="<?php echo $gid ?>"></td></tr> <tr><td width="80" align="center"><span style="color:#000000; font-size:13px"><b>Image:</b></span></td> <td width="300"><input type="file" name="upload" size="30"/></td></tr> <tr><td colspan="2" align="center"> <input type="submit" name="submit" value="Submit" /> <input type="reset" name="Reset" value="Reset"> </td></tr> </form><!-- End of Form --> </table> <tr><td> </td></tr> <tr><td align="right"><a href="index.php?status=signout">Sign Out</a></td></tr> </table> </body> </html> <?php } else {header("Location:index.php?msg=You do not have the authority to access the page");} } else {header("Location:index.php");} ?> Anyone please help me. Thanks..
  8. Why the dropdown list only available for one time? After i have choose the group name for once, the dropdown list will not be able to show all the group name..and the image could not be uploaded.Why?? What's wrong with my codes?Please help me... <?php session_start(); define ("MAX", 32); if(isset($_SESSION["session_post"])) { if ($_SESSION['session_post'] == "admin") { include("../config_pic.php"); // This page allows users to upload files to the server. if (isset($_POST['submit'])) { // Add record to database. $gid = $_POST['grpid']; $queryA = "SELECT * FROM images WHERE grpId='$gid'"; $resultA = mysql_query($queryA)or die(mysql_error()); $count = mysql_num_rows($resultA); $rowA = mysql_fetch_array($resultA); $path = "http://localhost/photo_album/mall/images/"; $filename= ""; if ($count < MAX) { if ($_FILES['upload']['name'] != "") { // Create the file name and path name if ($_FILES['upload']['name'] != ""){ $filename = $_FILES['upload']['name']; $path = $path.$filename; } else{ $path = ""; } $gid = $_POST['grpid']; $queryI = "INSERT INTO images (name, grpId) VALUES ('$filename', '$gid')"; $resultI = @mysql_query ($queryI); } } else { echo "<font color='red'>You have reach the maximum limit of photo upload!<br>If you wish to upload more photos, please delete the photos you don't want."; } $suceed = 0; if ($filename != "" && $gid != ""){ if(move_uploaded_file($_FILES['upload']['tmp_name'], "mall/images/$filename")){ $suceed = 1;} else {$suceed = 0;} } if($suceed ==1) {$msg="The file has been uploaded!";} else {$msg="<font color='red'>Your submission could not be processed due to a system error. We apologize for any inconvenience.";} mysql_close(); } ?> <html> <body> <p align="right"><a href="gallery.php">Back To Gallery</a></p> <br><br> <table border="0" align="center" width="400"> <tr><td> <table cellpadding="3" cellspacing="0" border="0" valign="top" align="center" width="400"> <tr><td><span style="color:#FF0000; font-size:13px"><?php echo (isset($msg)) ? $msg : " <br>" ?></span></td></tr> </table> </td></tr> <tr><td> <table cellpadding="5" cellspacing="0" border="0" valign="top" align="center" width="400" bgcolor="#CCCCFF"> Please select the group name that you would like to upload images before starting upload.Thanks for cooperation. <form id="form1" name="form1" method="post" action="upload_image.php"><center> <table> <tr> <td colspan="2">Please select group name: <select name="grpId" onChange='this.form.submit()'> <option>Group</option> <?php $result=mysql_query("Select Id, description from groupname ORDER BY Id"); while($row=mysql_fetch_array($result)) { ?> <option value="<?php echo $row['Id'];?>"><?php echo $row['description'];?> </option> <?php }?> </select> </td></tr></table></form> <p><p> <table cellpadding="5" cellspacing="0" border="0" valign="top" align="center" width="400" bgcolor="#CCCCFF"> <form id="form1" name="form1" method="post" action="upload_image.php"> <? include("../config_pic.php"); $gid = $_POST['grpId']; $desc = $_POST['description']; $query4 = "SELECT * FROM images where grpId='$gid'"; $result4 = mysql_query($query4) or die (mysql_error()); $count = mysql_num_rows($result4); $row4 = mysql_fetch_array($result4); $path = "http://localhost/photo_album/mall/images/"; $filename= ""; ?> <input type="hidden" name="MAX_FILE_SIZE" value="1000000000"> <tr><td colspan="2" bgcolor="#000000" align="center"><span style="color:#FFFFFF; font-size:15px"><strong>Upload Photo</strong></span> </td> </tr> <tr><td colspan="2" height="10"></td></tr> <tr><td width="80" align="center"><span style="color:#000000; font-size:13px"><b>Group:</b></span></td> <td width="300"><input type="text" name="grpid" value="<?php echo $gid ?>"></td> </tr><!--<input type="hidden" name="grpid" value="<?php echo $gid ?>">--> <tr><td width="80" align="center"><span style="color:#000000; font-size:13px"><b>Image:</b></span></td> <td width="300"><input type="file" name="upload" size="30"/></td></tr> <tr><td colspan="2" align="center"> <input type="submit" name="submit" value="Submit" /> <input type="reset" name="Reset" value="Reset"> </td></tr> </form><!-- End of Form --> </table> <tr><td> </td></tr> <tr><td align="right"><a href="index.php?status=signout">Sign Out</a></td></tr> </table> </body> </html> <?php } else {header("Location:index.php?msg=You do not have the authority to access the page");} } else {header("Location:index.php");} ?> Thanks
  9. I want to create a dropdown list to select group name from table groupName: Table Structure for groupName: CREATE TABLE `groupname` ( `Id` int(11) NOT NULL auto_increment, `description` text, `image` text, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; which Id is the group id, description is the group name. I want to select group name from list and i just want to keep the group id and the group name in another table. How to do it? Please help me One more question. Why the dropdown list only available for one time ??? Thanks Below is my code: <?php session_start(); define ("MAX", 32); if(isset($_SESSION["session_post"])) { if ($_SESSION['session_post'] == "admin") { include("../config_pic.php"); ?> <?php // This page allows users to upload files to the server. if (isset($_POST['submit'])) { // Add record to database. $gid = $_POST['grpid']; $queryA = "SELECT * FROM images WHERE grpId='$gid'"; $resultA = mysql_query($queryA); $count = mysql_num_rows($resultA); $rowA = mysql_fetch_array($resultA); $path = "http://localhost/photo_album/mall/images/"; $filename = ""; if ($count < MAX) { if ($_FILES['upload']['name'] != "") { // Create the file name and path name if ($_FILES['upload']['name'] != ""){ $filename = $_FILES['upload']['name']; $path = $path.$filename; } else{ $path = ""; } $gid = $_POST['grpid']; $queryI = "INSERT INTO images (name, grpId) VALUES ('$filename', '$gid')"; $resultI = @mysql_query ($queryI); } } else { echo "<font color='red'>You have reach the maximum limit of photo upload!<br>If you wish to upload more photos, please delete the photos you don't want."; } $suceed = 0; if ($filename != ""){ if(move_uploaded_file($_FILES['upload']['tmp_name'], "mall/images/$filename")){ $suceed = 1;} else {$suceed = 0;} } if($suceed ==1) {$msg="The file has been uploaded!";} else {$msg="<font color='red'>Your submission could not be processed due to a system error. We apologize for any inconvenience.";} mysql_close(); } ?> <html> <body> <p align="right"><a href="gallery.php">Back To Gallery</a></p> <br><br> <table border="0" align="center" width="400"> <tr><td> <table cellpadding="3" cellspacing="0" border="0" valign="top" align="center" width="400"> <tr><td><span style="color:#FF0000; font-size:13px"><?php echo (isset($msg)) ? $msg : " <br>" ?></span></td></tr> </table> </td></tr> <tr><td> <table cellpadding="5" cellspacing="0" border="0" valign="top" align="center" width="400" bgcolor="#CCCCFF"> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000000">Please fill in the group name that you would like to upload images before starting upload.Thanks for cooperation. <tr><td colspan="2" bgcolor="#000000" align="center"><span style="color:#FFFFFF; font-size:15px"><strong>Upload Photo</strong></span> </td> </tr> <tr><td colspan="2" height="10"></td></tr> <tr><td width="80" align="center"><span style="color:#000000; font-size:13px"><b>Group:</b></span></td> <td width="300"><!--<input type="text" name="desc" size="30"/>--><select name="description"> <option>Group</option> <?php $result=mysql_query("Select Id,description from groupname ORDER BY Id"); while($row=mysql_fetch_array($result)) { ?> <option value="<?php echo $row['Id'];?>"><?php echo $row['description']; $grpid=$row['Id'];?> </option> <?php }?> </select> <input type="hidden" name="grpid" value="<?php echo $row['Id'] ?>"></td></tr> <tr><td width="80" align="center"><span style="color:#000000; font-size:13px"><b>Image:</b></span></td> <td width="300"><input type="file" name="upload" size="30"/></td></tr> <!-- <input name="description" type="hidden" size="65">--> <tr><td colspan="2" align="center"> <input type="submit" name="submit" value="Submit" /> <input type="reset" name="Reset" value="Reset"> </td></tr> </form><!-- End of Form --> </table> </td></tr> <tr><td> </td></tr> <tr><td align="right"><a href="index.php?status=signout">Sign Out</a></td></tr> </table> </body> </html> <?php } else {header("Location:index.php?msg=You do not have the authority to access the page");} } else {header("Location:index.php");} ?> Thanks
  10. the name field did not save the path, it just save the filename. $imgLoc2[$i] is to show the path to the image. i've try your code already but it didn't work.
  11. I'm still facing with the offset problem: The error message: Notice: Undefined offset: 1 in C:\Program Files\Apache Group\Apache2\htdocs\photo_album\album.php on line 48 Notice: Undefined offset: 2 in C:\Program Files\Apache Group\Apache2\htdocs\photo_album\album.php on line 48 Notice: Undefined offset: 3 in C:\Program Files\Apache Group\Apache2\htdocs\photo_album\album.php on line 48 Notice: Undefined offset: 4 in C:\Program Files\Apache Group\Apache2\htdocs\photo_album\album.php on line 48 Notice: Undefined offset: 5 in C:\Program Files\Apache Group\Apache2\htdocs\photo_album\album.php on line 48 Notice: Undefined offset: 6 in C:\Program Files\Apache Group\Apache2\htdocs\photo_album\album.php on line 48 Notice: Undefined offset: 7 in C:\Program Files\Apache Group\Apache2\htdocs\photo_album\album.php on line 48 looping for 4 times. Below is my edited code: <?php //select images from table images(display all thumbnails for a category) $query2 = "SELECT name FROM images"; $result2 = mysql_query($query2); if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 8; while($row2 = mysql_fetch_array($result2)){ //print_r($row2); $ProImg2 = $row2; //$ProImg2[] = $row2; // open row if counter is zero if($i == 0) echo "<tr>"; $imgLoc2[]="mall/smallthumbnail.php?i=http://localhost/photo_album/mall/images/$ProImg2[$i]&w=50&h=50"; ?> <td><A onmouseover=replaceImage($i);><IMG style="CURSOR: hand" height=50 alt="pink" src="<?php echo $imgLoc2[$i]; ?>" width=50 border="0" onClick="window.location.href='deleteimage.php?image=<?php echo $imgLoc2[$i]; ?>'"></A></td> <? // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if(++$i == $max_columns) } // end while($row2 = mysql_fetch_array($result2)){ } // end if results ?> Anyone, please help me.. Thanks
  12. Hi, shab. I can delete the files from db but then i'm facing with problems when i try to delete files from server. It shows the error message like below: Warning: unlink(localhost/album/mall/images/No_2897.jpg) [function.unlink]: No such file or directory I put all my images in ../album/mall/images/ directory and I've checked that the image is in the directory. Below is my code for deleting images: <?php if (isset($_POST['delete'])) { $query = "SELECT * FROM images"; $result = mysql_query($query)or die(mysql_error()); $row = mysql_fetch_array($result); $id = $row['Id']; $path = "mall/smallthumbnail.php?i=http://localhost/album/mall/images/"; $name = $row['name']; $path = $path.$name; // Delete the record from database. $query2 = "DELETE FROM images WHERE Id='$id'"; $result2 = mysql_query($query2)or die(mysql_error()); //delete record from server unlink($path); } ?> <body> <p align="right"><a href="gallery.php">Back To Gallery</a></p> <form name="delete" action="<?php $_SERVER['PHP_SELF'] ?>" method="post"> <input type="hidden" name="id" value="<?php echo $id ?>"> <center> <img src="<?php echo $path ?>" width="400" height="400"> <br> <input type="submit" name="delete" value="Delete"> </center> </form> Thanks.
  13. Hi,there. I am doing on a php photo album. Here is my table structure for images: CREATE TABLE `images` ( `Id` int(11) NOT NULL auto_increment, `name` text, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; I save the images as a path(e.g. http://localhost/album/images/pic.jpg) in field 'name' of table 'images'. and now i would like to know how to delete the images from both the DB and the directory that i saved the images. Any ideas? Thanks..
  14. Here is the table structure for image: CREATE TABLE `images` ( `Id` int(11) NOT NULL auto_increment, `name` text, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; The field name for image is name in table images.
  15. Hi.. According to your code: <? if($row2['$ProImg2']!=""){?> <img src="<?=$row2['$ProImg2']?>" alt="" width="135" height="136" border="0" /></td> <? } ?> I've try it already but then there is an error message appears: Undefined index: $ProImg2 there are only Id and name fields in my image table and $ProImg2 = $row2 so i just changed the $row2['$ProImg2'] to $ProImg2[$i]... but it just show one photo only :'( Below is my edited code: <?php //select images from table images(display all thumbnails for a category) $query2 = "SELECT name FROM images"; $result2 = mysql_query($query2); $quantity = mysql_num_rows($result2); $colsPerRow = 8; $i = 0; while($row2 = mysql_fetch_array($result2)){ $ProImg2 = $row2; if ($i % $colsPerRow == 0) { // start a new row echo '<tr>'; $imgLoc2[$i]="mall/smallthumbnail.php?i=http://localhost/photo_album/mall/images/$ProImg2[$i]&w=50&h=50"; ?> <td> <? if($ProImg2[$i]!=""){?> <A onmouseover=replaceImage($i);><IMG style="CURSOR: hand" height=50 alt="pink" src="<?php echo $imgLoc2[$i]; ?>" width=50 border="0"></A></td> <? } ?> </table> <? $i += 1; } }?> </table> </tr> Please help me. Thanks
×
×
  • 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.