aebstract Posted February 12, 2009 Share Posted February 12, 2009 I don't get it :/ I have a column called payment, which is either 'credit' or '30Day' and right now I have this script: $result = mysql_query("SELECT * FROM p_orders WHERE customer_id='$id' ORDER BY id DESC") or DIE(mysql_error()); while($r=mysql_fetch_array($result)) { $invoice=$r["id"]; $orderdate=$r["order_date"]; $po=$r["po"]; $orderdate = explode(' ', $orderdate); $orderdate = $orderdate[0]; $payment=$r["payment"]; $payed=$r["payed"]; if ($payment == 'credit'){ if ($payed == 0){ $paynow = "<a href=\"$payment\"><font color=\"red\">(pay)</font></a>"; } } $row_color = ($row_count % 2) ? $color1 : $color2; $order_history .= "<tr class=\"tableRowCursor\" style=\"background-image: url($row_color);\" onclick=\"DoNav('index.php?page=myorders&invoice=$invoice');\"><td>$orderdate</td><td></td><td>i$invoice $paynow</td><td></td><td>$po</td></tr>"; $row_count++; } Which is placing all my rows from the database, correctly. However, the bit about the payment deal: if ($payment == 'credit'){ if ($payed == 0){ $paynow = "<a href=\"$payment\"><font color=\"red\">(pay)</font></a>"; } } It is displaying a link beside every item except the first one and every single item is saying credit, when half of them are 30Day in the database.. any ideas? Link to comment https://forums.phpfreaks.com/topic/144913-solved-weird-problem-in-small-script/ Share on other sites More sharing options...
aebstract Posted February 12, 2009 Author Share Posted February 12, 2009 nvm this was just me being stupid in the morning. The variable $paynow is staying set every time around ;( Link to comment https://forums.phpfreaks.com/topic/144913-solved-weird-problem-in-small-script/#findComment-760434 Share on other sites More sharing options...
PFMaBiSmAd Posted February 12, 2009 Share Posted February 12, 2009 You need to initialize $paynow to an empty string before your logic that sets it to the link so that it will only be set to the link when the correct conditions exist. Link to comment https://forums.phpfreaks.com/topic/144913-solved-weird-problem-in-small-script/#findComment-760437 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.