Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. This is pointless.. your showing me an output without letting me know the matching code and when i question it you show me another output that my code won't produce without changes.. have you even viewed source ?
  2. Doh!... very true
  3. BACKUP BACKUP your database this should work but still backup first i hope it makes sense <style> .rowgreen { background-color: #00FF00; } .rowred { background-color: #FF0000; } <?php function rowclass ( ) { if ($row['invoiced'] == "Yes") { return "green"; }else{ return "red"; } } mysql_select_db("ipendpoi_Purchase", $conn); //1 or more ticked if(count($_POST['invoiced']) > 0) { //Get the values and put them into a comma delimited string $invoiced = implode(",",$_POST['invoiced']); //update database $result = mysql_query("UPDATE po SET invoiced ='Yes' WHERE number IN ($invoiced)"); echo "Updated"; } $result = mysql_query("SELECT * FROM po ORDER BY number DESC"); echo "<table width='100%' border='1'> <tr> <th>Date</th> <th>PO Number</th> <th>Requester</th> <th>Amount</th> <th>Vendor</th> <th>Department</th> <th>End User</th> <th>Invoiced</th> </tr>"; echo "<form name=\"form1\" method=\"post\">"; while($row = mysql_fetch_array($result)) { echo "<tr class = row". rowclass () . ">"; echo "<td>" . "<div align=\"center\">" . $row['date'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . "<a href=\"upload_directory/Purchase-Order-" . $row['number'] . ".pdf\">" . $row['number'] . "</a>" . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['requester'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . "£" . $row['amount'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['vendor'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['department'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['End_User'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['invoiced'] . "<input type=\"checkbox\" name=\"invoiced[]\" value=\"".$row['number']."\" id=\"checkbox\">"; echo "</tr>"; } echo "</table>";mysql_close($conn); echo "<input type=\"submit\" name=\"Update\" id=\"Update\" value=\"Submit\">"; echo "</form>"; ?> EDIT: oops messed up the query (now fixed)
  4. Well that doesn't match the code... Coupon Id: should be at the very last thing printed in the code i posted.... plus that doesn't help me i don't know if theirs problems with the html or the database...
  5. LOL, thanx for point that out, when i said create a new field.. i did mean a date field .. but didn't say that ...
  6. SELECT *,STR_TO_DATE('paymentdate', '%d/%m/%Y') as pdate FROM table ORDER BY pdate But you should really create a new field then do UPDATE table SET newfield = STR_TO_DATE('paymentdate', '%d/%m/%Y') check it then remove the 'paymentdate' and rename 'newfield' to 'paymentdate' hope that helps EDIT: backup before the update (i am not taking any blame if it goes wrong .. as you could probably find me in the UK *hide* ) but it should be fine
  7. Yeah that should be OK.. (i assume thats unique) thats just to output the select boxes so add it to the page your posting to
  8. But i am not going to re-create it.. thus i can't truly test it, do you have the page online ?
  9. okay, but you will still need to change <input type=\"checkbox\" name=\"checkbox\" id=\"checkbox\"> to <input type=\"checkbox\" name=\"checkbox[]\" value=\"".$row['ID']."\" id=\"checkbox\"> then you can then do this print_r($_POST['checkbox']); to get the IDs of the records you ticked
  10. without look access to the DB it's hard to say.. but i would probably strip out the table for or view source, as the output doesn't seam to match the code
  11. try this *untested* but looks correct to me $result = mysql_query("SELECT * FROM `coupons` WHERE `member_id` = '$memb_id' && `agent_id` = '$agn_id' ORDER BY coupon_id"); $previd = ''; while($row = mysql_fetch_assoc($result)) { echo "<tr> <td>{$row['coupon_id']}</td> <td>{$row['event']}</td> <td>{$row['bet']}</td> <td align='right'>{$row['winings']}</td> </tr><tr>"; if($row['coupon_id'] != $previd) { $previd = $row['coupon_id']; $result_o = mysql_query("SELECT * FROM `coupon_winnings` WHERE `coupon_id` = '$previd' ORDER BY `coupon_id`"); while($row_o = mysql_fetch_assoc($result_o)) { echo"<tr><td></td><td></td><td bgcolor='#CCCCCC'><b><u>Total:</b></u></td><td bgcolor='#CCCCCC' align='right'>{$row_o['total_winings']}</td></tr>"; echo"<tr><td></td><td></td><td bgcolor='#CCCCCC'><b><u>Stake:</b></u></td><td bgcolor='#CCCCCC' align='right'>{$row_o['stake']}</td></tr>"; echo"<tr><td></td><td></td><td bgcolor='#CCCCCC'><b><u>Possible Winnings:</b></u></td><td bgcolor='#CCCCCC' align='right'>{$row_o['poss_total_winnings']}</td></tr>"; echo"<tr><td></td><td></td><td></td><td></td></tr>"; echo"<tr><td></td><td></td><td></td><td></td></tr>"; echo"<table cellspacing='2' width='550' border='0' ><tr><td width='50'><u><b>Id:</b></u></td><td width='260'><u><b> Game </b></u></td><td width='100'><div><u><b> Bet </b></u></div></td><td width='40'><div align='center'><u><b> Winings </b></u></div></td></tr><tr>"; } echo "<td>Coupon Id:</td><td>{$row['coupon_id']}</td>"; } }
  12. okay but how to i work out the total amount? ie total amount = account X qty as for the check box i assumed you have a unique ID as if your posting this back to update your need to know what records have been checked, bur for display it doesn't matter to much <?php mysql_select_db("ipendpoi_Purchase", $conn); $result = mysql_query("SELECT * FROM po ORDER BY number DESC"); echo "<table width='100%' border='1'> <tr> <th>Date</th> <th>PO Number</th> <th>Requester</th> <th>Amount</th> <th>Vendor</th> <th>Department</th> <th>End User</th> <th>Invoiced</th> </tr>"; $rowclass = 0; while($row = mysql_fetch_array($result)) { echo "<tr class = row" . $rowclass . ">"; echo "<td>" . "<div align=\"center\">" . $row['date'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . "<a href=\"upload_directory/Purchase-Order-" . $row['number'] . ".pdf\">" . $row['number'] . "</a>" . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['requester'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . "£" . $row['amount'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['vendor'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['department'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['End_User'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">"; /*if the value is "yes" then tick it*/ $check = ($row['Invoiced'] == "yes")?"checked":""; /*I assume you have a unique ID called id*/ echo "<input type=\"checkbox[".$row['id']."]\" name=\"Invoiced\" $check>"; echo "</div>" . "</td>"; echo "</tr>"; $rowclass = 1 - $rowclass; } echo "</table>";mysql_close($conn); die; ?>
  13. move $previd = $row['coupon_id']; here //HERE $result_o = mysql_query("SELECT * FROM `coupon_winnings` WHERE `coupon_id` = '$previd' ORDER BY `coupon_id`");
  14. test <?php //test #1 $query = "SELECT * FROM mysqltable WHERE NOT ISNULL(field)"; //test #2 #$query = 'SELECT * FROM mysqltable WHERE field !="" '; $result = mysql_query($query) or die("error in: '$query'<br>".mysql_error()); $myrow=mysql_fetch_array($result); echo "<pre>"; print_r($myrow); ?>
  15. cool can you click solved topic please (saves people turning up to help and learning the party has finished)
  16. what do you mean by
  17. How would you know whether that PO has a corresponding invoice ? i assume a field called Invoiced is not null or something ? do you have a quantity field, to workout the total amount ?
  18. looks okay to me (i assume ‘ and ’ are single quotes)
  19. okay.. first change echo "<input type='checkbox' name='".$country[$order]."' value = ' ".$count2."'>".$country[$order]. "<br />"; to echo "<input type='checkbox' name='myorders[]' value = ' ".$count2."'>".$country[$order]. "<br />"; myorders can be anything just make sure you have the brackets [] now to display <?php if (isset($_POST['continue'])) { //I need to have the checked values to variables here foreach($_POST['myorders'] as $mo) { //only the check boxes appear echo "$mo<br>"; } } ?> *untested but should be fine
  20. here some examples, that i use <?php //Int #1 $number = (int)$number; $query = "SELECT * FROM users WHERE number=$number"; //Int #2 $query = sprintf("SELECT * FROM users WHERE number=%d", $number); //Int #3 (i don't use this one i would use #1 instead, but that personal pref.) settype($number, "integer"); $query = "SELECT * FROM users WHERE number=$number"; //String $query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'", mysql_real_escape_string($user), mysql_real_escape_string($password)); ?> EDIT: i would recommned using Int #2 and String for all SQL querys out of habbit, if you have a function that require an int then use Int #1 (if the var is being used in other places as well)
  21. Heres an example of how i would do it <?php #$fc = @file_get_contents( urldecode( $url ) ); #if( !$fc ) return false; //example $HTML = ' <a href="http://www.phpfreaks.com/1">test1</a> <a href=\'http://www.phpfreaks.com/1\'>test1</a> <a href="http://www.phpfreaks.com/1">test1</a> <a href="http://www.phpfreaks.com/1">test1</a> <a href=\'http://www.phpfreaks.com/2\'>test2</a> <a href=http://www.phpfreaks.com/3>test3</a> <a href="http://www.phpfreaks.com/4">test4</a> <a href="http://www.phpfreaks.com/5">test5</a> <a href="http://www.phpfreaks.com/6">test6</a> <a href="http://www.phpfreaks.com/7">test7</a> <a href="http://www.phpfreaks.com/8">test8</a> '; //Match URLs preg_match_all('/\s+href\s*=\s*(["\'])?([^\1]*?)\1/si', $HTML, $result, PREG_PATTERN_ORDER); //Remove Dups $result = array_unique($result[2]); //output echo "<pre>"; print_r($result); ?>
  22. And the problem is ?
  23. $text = preg_replace('/[^a-zA-Z0-9_ -]/s', '', $text); or i shorter version $text= preg_replace('/[^\w\d_ -]/si', '', $text); EDIT: the above is a clean up heres to match <?php if (preg_match('/[^\w\d_ -]/si', $text)) { echo "found unknown characters"; } ?>
  24. i see no reason why you can't! just use your current parsa to do the list after the php parsa ie bb2html(docode($text));
  25. header("Location: URL"); please note the URL is the absolute URI so myfile.php won't work correctly your need to use "http://{$_SERVER['HTTP_HOST']}/Blar.php" <?php /* Redirect to a different page in the current directory that was requested */ $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); $extra = 'mypage.php'; header("Location: http://$host$uri/$extra"); exit; ?>
×
×
  • 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.