Jump to content

baris22

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

baris22's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thank you so much, it is sorted now.
  2. thank you for your help, it is working perfect now. $sql = "SELECT * FROM file As f1 INNER JOIN file As f2 ON (f1.topic = f2.topic AND f1.id != f2.id) ORDER BY f1.topic DESC LIMIT $start, $limit"; is there any way i can get the right count on here for the pagination by changing the query? $query = "SELECT COUNT(*) as num FROM file "; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; thanks again.
  3. if i do this $sql = "SELECT * FROM file As f1 INNER JOIN file As f2 ON (f1.topic = f2.topic AND f1.id != f2.id) ORDER BY topic LIMIT $start, $limit"; i get thie error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in index.php on line 191 that line is while($row = mysql_fetch_array($result)) { if i remove ORDER BY topic, it works.
  4. i get an error when i add this ORDER BY topic DESC LIMIT $start, $limit
  5. Thank you very much, it worked kind of. How can i add this to the code ORDER BY topic DESC LIMIT $start, $limit and How can i get the right count for pagination on here? $query = "SELECT COUNT(*) as num FROM file "; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; Thanks alot
  6. hello all, this is what i use to show the the data from mysql. // i use this to get the total count for pagination. $query = "SELECT COUNT(*) as num FROM file "; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; /* my codes continues.................*/ // i use this to get the data $sql = "SELECT * FROM file ORDER BY topic DESC LIMIT $start, $limit"; $result = mysql_query($sql); My question is what do i need to change here to show only duplicated entries according to topic field. Thanks all.
  7. Hello, Please help me to get this working This is my current database: This is the current output of my code: I am trying to get: This is my current code: <? include_once ("config/connect.php"); $ref=$_GET['ref']; if (isset($_POST['ok'])) { $worker = $_POST['worker']; $item_id = $_POST['item_id']; for ($i=0;$i<=count($item_id);$i++) { $query5 = mysql_query("UPDATE item SET worker_id = '".$worker[$i]."' WHERE item_id = '".$item_id[$i]."' ") or die(mysql_error()); } } ?> <table width="100%"> <? $query1 = "SELECT * FROM item WHERE order_reference_number='$ref' GROUP BY item_ref"; $portfolio = mysql_query($query1); while($row1 = mysql_fetch_array($portfolio)) { ?> <tr> <td><strong><?=$row1['item_amount'];?> of <?=$row1['item_name'];?></strong></td> </tr> <? } ?> </table> <form action="<?=$PHP_SELF;?>" method="post"> <table width="600" border="0" cellpadding="4" cellspacing="0" bordercolor="#CCCCCC"> <tr> <td height="24" bgcolor="#999999"><strong>Item amount</strong></td> <td height="24" bgcolor="#999999"><strong>Item name</strong></td> <td height="24" bgcolor="#999999"><strong>choice a worker</strong></td> <td height="24" bgcolor="#999999"><strong>chosen worker</strong></td> </tr> <tr> <?php $query99 = "SELECT * FROM item WHERE order_reference_number='$ref' ORDER BY item_name, item_ref"; $portfolio = mysql_query($query99); while($row109 = mysql_fetch_array($portfolio)) { if ($itemRefLast==$row109['item_ref']) { } else { if($skip){ $skipAmount -= 1; ?> <td height="32"></td> <td height="32"> <input name="item_id[]" type="hidden" value="<?=$row109['item_id'];?>" /></td> <?php }else{ ?> <td height="32"> <?=$row109['item_amount'];?></td> <td height="32"> <?=$row109['item_name'];?> <input name="item_id[]" type="hidden" value="<?=$row109['item_id'];?>" /></td> <?php if($skipAmount == 0){ $skip = False; } if($row109['item_amount']>1){ $skip = True; $skipAmount = $row109['item_amount']-1; } } ?> <td> <select name="worker[]" id=""> <option value="<?=$row109['worker_id'];?>"><?=$row109['worker_id'];?></option> <option value="-">-</option> <?php $query3 = "SELECT * FROM worker"; $portfolio1 = mysql_query($query3); while($row3 = mysql_fetch_array($portfolio1)) { ?> <option><?php echo $row3['worker_name'];?></option> <?php } ?> </select></td> <td> <a href="g"> <strong><?=$row109['worker_id'];?></strong> </a></td> </tr><?php $itemRefLast=$row109['item_ref']; } } ?> </table> <input type="submit" name="ok" value="Submit" onClick="return confirmPost()" /> </form>
  8. hello, This is the last code. <? include_once ("config/connect.php"); $ref=$_GET['ref']; if (isset($_POST['ok'])) { $worker = $_POST['worker']; $item_id = $_POST['item_id']; for ($i=0;$i<=count($item_id);$i++) { $query5 = mysql_query("UPDATE item SET worker_id = '".$worker[$i]."' WHERE item_id = '".$item_id[$i]."' ") or die(mysql_error()); } } ?> <form action="<?=$PHP_SELF;?>" method="post"> <table width="600" border="0" cellpadding="4" cellspacing="0" bordercolor="#CCCCCC"> <tr> <td height="24" bgcolor="#999999"><strong>Item amount</strong></td> <td height="24" bgcolor="#999999"><strong>Item name</strong></td> <td height="24" bgcolor="#999999"><strong>choice a worker</strong></td> <td height="24" bgcolor="#999999"><strong>chosen worker</strong></td> </tr> <tr> <?php $query99 = "SELECT * FROM item WHERE order_reference_number='$ref'"; $portfolio = mysql_query($query99); $i = 0; while($row109 = mysql_fetch_array($portfolio)) { ?> <td height="32"> <?=$row109['item_amount'];?></td> <td height="32"> <?=$row109['item_name'];?> <input name="item_id[]" type="hidden" value="<?=$row109['item_id'];?>" /></td> <td> <select name="worker[]" id=""> <option value="<?=$row109['worker_id'];?>"><?=$row109['worker_id'];?></option> <option value="-">-</option> <?php $query3 = "SELECT * FROM worker"; $portfolio1 = mysql_query($query3); while($row3 = mysql_fetch_array($portfolio1)) { ?> <option><?php echo $row3['worker_name'];?></option> <?php } ?> </select></td> <td> <a href="g"> <strong><?=$row109['worker_id'];?></strong> </a></td> </tr><?php } ?> </table> <input type="submit" name="ok" value="Submit" onclick="return confirmPost()" /> </form> This is the database: This is the output of my code: I want to display item_amount and item_name only once if the item_amount is bigger than 1. Can somebody help me please. Thanks
  9. Thank you for your help. One last question <?php $query99 = "SELECT * FROM item WHERE order_reference_number='$ref'"; $portfolio = mysql_query($query99); while($row109 = mysql_fetch_array($portfolio)) { ?> <?=$row109['item_name'];?> this is the code. How can I make an if statement that if <?=$row109['item_amount'];?> is bigger than 1 display <?=$row109['item_name'];?> only once. Thank you very much
  10. Thanks for replies. I changed the codes and it is working now. 1 more question: How can choice a worker select box value can be remembered instead of displaying "Select" value <? include_once ("config/connect.php"); $ref=$_GET['ref']; if (isset($_POST['ok'])) { $worker = $_POST['worker']; $item_id = $_POST['item_id']; for ($i=0;$i<=count($item_id);$i++) { $query5 = mysql_query("UPDATE item SET worker_id = '".$worker[$i]."' WHERE item_id = '".$item_id[$i]."' ") or die(mysql_error()); } } ?> <table width="100%" border="1" cellpadding="4" cellspacing="4"> <tr> <td><strong>Item</strong></td> <td><strong>choice a worker</strong></td> <td><strong>chosen worker</strong></td> </tr> <tr><?php $query99 = "SELECT * FROM item WHERE order_reference_number='$ref' "; $portfolio = mysql_query($query99); while($row109 = mysql_fetch_array($portfolio)) { ?> <td> <?=$row109['item_name'];?> <input name="item_id[]" type="hidden" value="<?=$row109['item_id'];?>" /> </td> <td> <select name="worker[]" id=""> <option value="Select">Select</option> <?php $query3 = "SELECT * FROM worker"; $portfolio1 = mysql_query($query3); while($row3 = mysql_fetch_array($portfolio1)) { ?> <option><?php echo $row3['worker_name'];?></option> <?php } ?> </select> </td> <td><?=$row109['worker_id'];?></td> </tr><?php } ?> </table>
  11. Still not working. Do you think is there anything to do with "GROUP BY item_amount"
  12. Hello all, I need some help. This is my database: This is the output of my code: When I submit the form it only updates the first row. It does not update the second one. Can you please help me. Thanks <? include_once ("config/connect.php"); $ref=$_GET['ref']; if (isset($_POST['ok'])) { $item_name = $_POST['item_name']; $worker = $_POST['worker']; $item_id = $_POST['item_id']; for ($i=0;$i<count($_POST['item_id']);$i++) { $query5 = mysql_query("UPDATE item SET item_name = '".$item_name[$i]."', worker_id = '".$worker[$i]."' WHERE item_id = '".$item_id[$i]."' ") or die(mysql_error()); } } ?> <?php $query1 = "SELECT * FROM item WHERE order_reference_number='$ref' GROUP BY item_amount"; $portfolio = mysql_query($query1); while($row1 = mysql_fetch_array($portfolio)) { ?> <table width="100%"> <tr> <td valign="top" width="266"> <?=$row1['item_amount'];?> of <input name="item_name[]" type="text" value="<?php echo $row1['item_name'];?>" size="30" /> <input name="item_id[]" type="hidden" value="<?=$row1['item_id'];?>" /> </td> <td width="480"> <?php for ($i=0; $i<$row1['item_amount']; $i++) { ?> Choice a worker for this job <select name="worker[]" id=""> <option value="Select">Select</option> <?php $query3 = "SELECT * FROM worker"; $portfolio1 = mysql_query($query3); while($row3 = mysql_fetch_array($portfolio1)) { ?> <option><?php echo $row3['worker_name'];?></option> <?php } ?> </select><br /><br /> <?php } ?> </td> </tr> </table> <?php } ?>
  13. Hello, I want to organize my php files so i will know where everything is. I want some feedback. This is my root: classes # class.php # another_class.php functions # function.php # another_function.php config # config.php files # footer.php # header.php # left.php # right.php # top.php images # logo.gif # style.css pages # about.php # contact.php # index.php index.php about.php contact.php On index.php I have got <?php $page_title = "title of site"; $page_keyword = "keywords"; define('_This_IS_not-FOR_YOU', TRUE); include "config/config.php"; // get config include "files/header.php"; // get header include "files/top.php"; // get topmenu include "pages/index.php"; // get content include "files/footer.php"; // get footer ?> On pages/index.php I have got <?php defined('_This_IS_not-FOR_YOU') or die('Direct access not allowed.'); ?> <table width="800" border="1" bgcolor="#FFFF00"> <tr> <td>Index</td> </tr> </table> On files/header.php I have got <?php defined('_This_IS_not-FOR_YOU') or die('Direct access not allowed.'); ?> <!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=utf-8" /> <title><?php echo $page_title; ?></title> <link type="text/css" rel="stylesheet" href="http://www.namepros.com/images/style.css"> </head> <body>
×
×
  • 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.