Query resultaat selecteren
Mijn vraag is:
Ik zoek een product dit resultaat laat hij vervolgens zien.
maar dan moet je eerst klikken op dit product om vervolgens het te selecteren kan iemand mij vertellen hoe ik dit automatish kan laten gebeuren?
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<?
$item_result=mysql_query($query,$dbf_osc->conn);
$item_title=isset($_SESSION['current_item_search']) ? "<b><font color=white>$lang->selectItem</font></b>":"<font color=white>$lang->selectItem</font>";
echo "<tr>
<td colspan='4' align='left'><font color=white>$lang->findItem:</font>
<input type='text' size='8' name='item_search'>
<input type='submit' value='zoek' tabindex='3'> <a href='delete.php?action=item_search'><font size='-1' color='white'>[$lang->clearSearch]</font></a></td></tr>";
?>
$item_result=mysql_query($query,$dbf_osc->conn);
$item_title=isset($_SESSION['current_item_search']) ? "<b><font color=white>$lang->selectItem</font></b>":"<font color=white>$lang->selectItem</font>";
echo "<tr>
<td colspan='4' align='left'><font color=white>$lang->findItem:</font>
<input type='text' size='8' name='item_search'>
<input type='submit' value='zoek' tabindex='3'> <a href='delete.php?action=item_search'><font size='-1' color='white'>[$lang->clearSearch]</font></a></td></tr>";
?>
Gewijzigd op 07/05/2012 16:31:42 door Bjorn cornelissen
- geen foutafhaneling
- veel te veel html in je php
maar wat bedoel je? bedoel je dat je net als op een webshop onder ieder product specificaties ziet staan, of dat wanneer je eroverheen hovert specificaties te zien zijn?
dus het is een overbodige stap die ik er graag uit wil hebben of dat het resultaat gelijk geselecteerd word zodat je gewoon gelijk volgende kan drukken zonder het product eerst aan te moeten klikken
Toevoeging op 07/05/2012 16:36:10:
Hier wat meer van het script
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?
//updating row for an item already in sale.
if(isset($_GET['update_item']))
{
$k=$_GET['update_item'];
$new_price=$_POST["price$k"];
$new_tax=$_POST["tax$k"];
$new_quantity=$_POST["quantity$k"];
$item_info=explode(' ',$_SESSION['items_in_sale'][$k]);
$item_id=$item_info[0];
$_SESSION['items_in_sale'][$k]=$item_id.' '.$new_price.' '.$new_tax.' '.$new_quantity;
}
if(isset($_POST['addToCart']))
{
if(empty($_POST['items']))
{
echo "<b>$lang->youMustSelectAtLeastOneItem</b><br>";
echo "<a href='sale_ui.php'>$lang->refreshAndTryAgain</a>";
exit();
}
$items_to_add=array();
$items_to_add=$_POST['items'];
$quantity_to_add=$_POST['quantity'];
for($k=0;$k<count($items_to_add);$k++)
{
$_SESSION['items_in_sale'][]=$items_to_add[$k].' '.$quantity_to_add;
}
}
$display->displayTitle("$lang->newSale1");
echo "<center><form name='additem' method='POST' action='sale_ui.php'>
<table border=0 cellspacing='0' cellpadding='2' bgcolor='$table_bg'>";
if(isset($_POST['item_search']) and $_POST['item_search']!='')
{
$search=$_POST['item_search'];
$_SESSION['current_item_search']=$search;
$query="SELECT p.products_id,p.products_quantity,p.products_model,pd.products_name,p.products_price,tr.tax_rate
FROM products as p,products_description as pd,tax_rates as tr,tax_class as tc
WHERE p.products_id=pd.products_id and
p.products_tax_class_id=tc.tax_class_id and
tr.tax_class_id=tc.tax_class_id and
p.products_model like \"%$search%\"
and pd.language_id=1
ORDER by pd.products_name"; }
elseif(isset($_SESSION['current_item_search']))
{
$search=$_SESSION['current_item_search'];
$query="SELECT p.products_id,p.products_quantity,p.products_model,pd.products_name,p.products_price,tr.tax_rate
FROM products as p,products_description as pd,tax_rates as tr,tax_class as tc
WHERE p.products_id=pd.products_id and
p.products_tax_class_id=tc.tax_class_id and
tr.tax_class_id=tc.tax_class_id and
p.products_model like \"%$search%\"
and pd.language_id=1
ORDER by products_description.products_name";
}
else
{
$query="SELECT p.products_id,p.products_model,pd.products_name,p.products_price,tr.tax_rate
FROM products as p,products_description as pd,tax_rates as tr,tax_class as tc
WHERE p.products_id=pd.products_id and
p.products_tax_class_id=tc.tax_class_id and
tr.tax_class_id=tc.tax_class_id and pd.language_id=1 ORDER by pd.products_name";
}
$item_result=mysql_query($query,$dbf_osc->conn);
$item_title=isset($_SESSION['current_item_search']) ? "<b><font color=white>$lang->selectItem</font></b>":"<font color=white>$lang->selectItem</font>";
echo "<tr>
<td colspan='4' align='left'><font color=white>$lang->findItem:</font>
<input type='text' size='8' name='item_search'>
<input type='submit' value='zoek' tabindex='3'> <a href='delete.php?action=item_search'><font size='-1' color='white'>[$lang->clearSearch]</font></a></td></tr>";
echo "<tr><td colspan='4' align='center'>$item_title</td></tr>
<tr><td align='center' colspan='4'>
<select name='items[]' multiple size='8'>\n";
while($row=mysql_fetch_assoc($item_result))
{
$id=$row['products_id'];
$unit_price=$row['products_price'];
$tax_percent=$row['tax_rate'];
$option_value=$id.' '.$unit_price.' '.$tax_percent;
$display_item="$row[products_name]";
echo "<option value='$option_value'>$display_item</option>\n";
}
echo "</select></td></tr></center>
<tr><td align='center' colspan='4'><font color=white>$lang->quantity:</font> <input type='text' size='4' name='quantity' value='1'>
<input type='submit' value='Ga verder' name=addToCart tabindex='1'></td></tr></table></form>";
if(empty($_SESSION['items_in_sale']))
{
echo "<center><h3>$lang->yourShoppingCartIsEmpty</h3></center>";
}
if(isset($_SESSION['items_in_sale']))
{
$num_items=count($_SESSION['items_in_sale']);
$temp_item_name='';
$temp_item_id='';
$temp_quantity='';
$temp_price='';
$finalSubTotal=0;
$finalTax=0;
$finalTotal=0;
$totalItemsPurchased=0;
$item_info=array();
echo "<hr><center><a href=delete.php?action=all>[Clear Sale]</a><h3>$lang->shoppingCart</h3><form name='add_sale' action='addsale.php' method='POST'>
";
echo "<table border='0' bgcolor='$table_bg' cellspacing='0' cellpadding='2'>
<tr><th><font color=CCCCCC>$lang->remove</font></th>
<th><font color=CCCCCC>$lang->itemName</font></th>
<th><font color=CCCCCC>$lang->unitPrice</font></th>
<th><font color=CCCCCC>$lang->tax %</font></th>
<th><font color=CCCCCC>$lang->quantity</font></th>
<th><font color=CCCCCC>$lang->quantityStock</font></th>
<th><font color=CCCCCC>$lang->extendedPrice</font></th>
<th><font color=CCCCCC>$lang->update</font></th></tr>";
for($k=0;$k<$num_items;$k++)
{
$item_info=explode(' ',$_SESSION['items_in_sale'][$k]);
$temp_item_id=$item_info[0];
$query="SELECT pd.products_name,p.products_quantity FROM products as p,products_description as pd
WHERE p.products_id=pd.products_id and
p.products_id=\"$temp_item_id\"";
$result=mysql_query($query,$dbf_osc->conn);
$row=mysql_fetch_assoc($result);
$temp_item_name=$row['products_name'];
$temp_price=$item_info[1];
$temp_tax=$item_info[2];
$temp_quantity=$item_info[3];
$products_quantity=$row['products_quantity'];
$subTotal=$temp_price*$temp_quantity;
$tax=$subTotal*($temp_tax/100);
$rowTotal=$subTotal+$tax;
$rowTotal=number_format($rowTotal,2,'.', '');
$finalSubTotal+=$subTotal;
$finalTax+=$tax;
$finalTotal+=$rowTotal;
$totalItemsPurchased+=$temp_quantity;
echo "<tr><td align='center'><a href=delete.php?action=item&pos=$k><font color=white>[$lang->delete]</font></a></td>
<td align='center'><font color='white'><b>$temp_item_name</b></font></td>
<td align='center'><input type=text name='price$k' value='$temp_price' size='8'></td>
<td align='center'><input type=text name='tax$k' value='$temp_tax' size='3'></td>
<td align='center'><input type=text name='quantity$k' value='$temp_quantity' size='3'></td>
<td align='center'><font color='white'><b>$products_quantity</b></font></td>
<td align='center'><font color='white'><b>$cfg_currency_symbol$rowTotal</b></font></td>
<td align='center'><input type='button' name='updateQuantity$k' value='$lang->update' onclick=\"document.add_sale.action='sale_ui.php?update_item=$k';document.add_sale.submit();\"></td>
<input type='hidden' name='item_id$k' value='$temp_item_id'>
</tr>";
}
$finalSubTotal=number_format($finalSubTotal,2,'.', '');
$finalTax=number_format($finalTax,2,'.', '');
$finalTotal=number_format($finalTotal,2,'.', '');
echo '</table>';
echo "<table align='center'><br>
<tr><td align='left'>$lang->saleSubTotal: $cfg_currency_symbol $finalSubTotal</td></tr>
<tr><td align='left'>$lang->tax: $cfg_currency_symbol $finalTax</td></tr>
<tr><td align='left'>$lang->saleTotalCost: $cfg_currency_symbol $finalTotal</td></tr>
</table>";
echo "<br><table border='0' bgcolor='$table_bg'>
<tr>
<td>
<font color='white'>$lang->paidWith:</font>
</td>
<td>
<select name='paid_with'>
<option value='$lang->credit'>$lang->credit</option>
<option value='$lang->cash'>$lang->cash</option>
<option value='$lang->giftCertificate'>$lang->giftCertificate</option>
<option value='$lang->account'>$lang->account</option>
</select></td>
</tr>
<tr>
<td>
<font color='white'>$lang->saleComment:</font>
</td>
<td>
<input type=text name=comment size=25>
</td>
</tr>
</table>
<br>
<input type=hidden name='totalItemsPurchased' value='$totalItemsPurchased'>
<input type=hidden name='totalTax' value='$finalTax'>
<input type=hidden name='finalTotal' value='$finalTotal'>
<input type='submit' value='Afrekenen'></center></form>";
}
?>
//updating row for an item already in sale.
if(isset($_GET['update_item']))
{
$k=$_GET['update_item'];
$new_price=$_POST["price$k"];
$new_tax=$_POST["tax$k"];
$new_quantity=$_POST["quantity$k"];
$item_info=explode(' ',$_SESSION['items_in_sale'][$k]);
$item_id=$item_info[0];
$_SESSION['items_in_sale'][$k]=$item_id.' '.$new_price.' '.$new_tax.' '.$new_quantity;
}
if(isset($_POST['addToCart']))
{
if(empty($_POST['items']))
{
echo "<b>$lang->youMustSelectAtLeastOneItem</b><br>";
echo "<a href='sale_ui.php'>$lang->refreshAndTryAgain</a>";
exit();
}
$items_to_add=array();
$items_to_add=$_POST['items'];
$quantity_to_add=$_POST['quantity'];
for($k=0;$k<count($items_to_add);$k++)
{
$_SESSION['items_in_sale'][]=$items_to_add[$k].' '.$quantity_to_add;
}
}
$display->displayTitle("$lang->newSale1");
echo "<center><form name='additem' method='POST' action='sale_ui.php'>
<table border=0 cellspacing='0' cellpadding='2' bgcolor='$table_bg'>";
if(isset($_POST['item_search']) and $_POST['item_search']!='')
{
$search=$_POST['item_search'];
$_SESSION['current_item_search']=$search;
$query="SELECT p.products_id,p.products_quantity,p.products_model,pd.products_name,p.products_price,tr.tax_rate
FROM products as p,products_description as pd,tax_rates as tr,tax_class as tc
WHERE p.products_id=pd.products_id and
p.products_tax_class_id=tc.tax_class_id and
tr.tax_class_id=tc.tax_class_id and
p.products_model like \"%$search%\"
and pd.language_id=1
ORDER by pd.products_name"; }
elseif(isset($_SESSION['current_item_search']))
{
$search=$_SESSION['current_item_search'];
$query="SELECT p.products_id,p.products_quantity,p.products_model,pd.products_name,p.products_price,tr.tax_rate
FROM products as p,products_description as pd,tax_rates as tr,tax_class as tc
WHERE p.products_id=pd.products_id and
p.products_tax_class_id=tc.tax_class_id and
tr.tax_class_id=tc.tax_class_id and
p.products_model like \"%$search%\"
and pd.language_id=1
ORDER by products_description.products_name";
}
else
{
$query="SELECT p.products_id,p.products_model,pd.products_name,p.products_price,tr.tax_rate
FROM products as p,products_description as pd,tax_rates as tr,tax_class as tc
WHERE p.products_id=pd.products_id and
p.products_tax_class_id=tc.tax_class_id and
tr.tax_class_id=tc.tax_class_id and pd.language_id=1 ORDER by pd.products_name";
}
$item_result=mysql_query($query,$dbf_osc->conn);
$item_title=isset($_SESSION['current_item_search']) ? "<b><font color=white>$lang->selectItem</font></b>":"<font color=white>$lang->selectItem</font>";
echo "<tr>
<td colspan='4' align='left'><font color=white>$lang->findItem:</font>
<input type='text' size='8' name='item_search'>
<input type='submit' value='zoek' tabindex='3'> <a href='delete.php?action=item_search'><font size='-1' color='white'>[$lang->clearSearch]</font></a></td></tr>";
echo "<tr><td colspan='4' align='center'>$item_title</td></tr>
<tr><td align='center' colspan='4'>
<select name='items[]' multiple size='8'>\n";
while($row=mysql_fetch_assoc($item_result))
{
$id=$row['products_id'];
$unit_price=$row['products_price'];
$tax_percent=$row['tax_rate'];
$option_value=$id.' '.$unit_price.' '.$tax_percent;
$display_item="$row[products_name]";
echo "<option value='$option_value'>$display_item</option>\n";
}
echo "</select></td></tr></center>
<tr><td align='center' colspan='4'><font color=white>$lang->quantity:</font> <input type='text' size='4' name='quantity' value='1'>
<input type='submit' value='Ga verder' name=addToCart tabindex='1'></td></tr></table></form>";
if(empty($_SESSION['items_in_sale']))
{
echo "<center><h3>$lang->yourShoppingCartIsEmpty</h3></center>";
}
if(isset($_SESSION['items_in_sale']))
{
$num_items=count($_SESSION['items_in_sale']);
$temp_item_name='';
$temp_item_id='';
$temp_quantity='';
$temp_price='';
$finalSubTotal=0;
$finalTax=0;
$finalTotal=0;
$totalItemsPurchased=0;
$item_info=array();
echo "<hr><center><a href=delete.php?action=all>[Clear Sale]</a><h3>$lang->shoppingCart</h3><form name='add_sale' action='addsale.php' method='POST'>
";
echo "<table border='0' bgcolor='$table_bg' cellspacing='0' cellpadding='2'>
<tr><th><font color=CCCCCC>$lang->remove</font></th>
<th><font color=CCCCCC>$lang->itemName</font></th>
<th><font color=CCCCCC>$lang->unitPrice</font></th>
<th><font color=CCCCCC>$lang->tax %</font></th>
<th><font color=CCCCCC>$lang->quantity</font></th>
<th><font color=CCCCCC>$lang->quantityStock</font></th>
<th><font color=CCCCCC>$lang->extendedPrice</font></th>
<th><font color=CCCCCC>$lang->update</font></th></tr>";
for($k=0;$k<$num_items;$k++)
{
$item_info=explode(' ',$_SESSION['items_in_sale'][$k]);
$temp_item_id=$item_info[0];
$query="SELECT pd.products_name,p.products_quantity FROM products as p,products_description as pd
WHERE p.products_id=pd.products_id and
p.products_id=\"$temp_item_id\"";
$result=mysql_query($query,$dbf_osc->conn);
$row=mysql_fetch_assoc($result);
$temp_item_name=$row['products_name'];
$temp_price=$item_info[1];
$temp_tax=$item_info[2];
$temp_quantity=$item_info[3];
$products_quantity=$row['products_quantity'];
$subTotal=$temp_price*$temp_quantity;
$tax=$subTotal*($temp_tax/100);
$rowTotal=$subTotal+$tax;
$rowTotal=number_format($rowTotal,2,'.', '');
$finalSubTotal+=$subTotal;
$finalTax+=$tax;
$finalTotal+=$rowTotal;
$totalItemsPurchased+=$temp_quantity;
echo "<tr><td align='center'><a href=delete.php?action=item&pos=$k><font color=white>[$lang->delete]</font></a></td>
<td align='center'><font color='white'><b>$temp_item_name</b></font></td>
<td align='center'><input type=text name='price$k' value='$temp_price' size='8'></td>
<td align='center'><input type=text name='tax$k' value='$temp_tax' size='3'></td>
<td align='center'><input type=text name='quantity$k' value='$temp_quantity' size='3'></td>
<td align='center'><font color='white'><b>$products_quantity</b></font></td>
<td align='center'><font color='white'><b>$cfg_currency_symbol$rowTotal</b></font></td>
<td align='center'><input type='button' name='updateQuantity$k' value='$lang->update' onclick=\"document.add_sale.action='sale_ui.php?update_item=$k';document.add_sale.submit();\"></td>
<input type='hidden' name='item_id$k' value='$temp_item_id'>
</tr>";
}
$finalSubTotal=number_format($finalSubTotal,2,'.', '');
$finalTax=number_format($finalTax,2,'.', '');
$finalTotal=number_format($finalTotal,2,'.', '');
echo '</table>';
echo "<table align='center'><br>
<tr><td align='left'>$lang->saleSubTotal: $cfg_currency_symbol $finalSubTotal</td></tr>
<tr><td align='left'>$lang->tax: $cfg_currency_symbol $finalTax</td></tr>
<tr><td align='left'>$lang->saleTotalCost: $cfg_currency_symbol $finalTotal</td></tr>
</table>";
echo "<br><table border='0' bgcolor='$table_bg'>
<tr>
<td>
<font color='white'>$lang->paidWith:</font>
</td>
<td>
<select name='paid_with'>
<option value='$lang->credit'>$lang->credit</option>
<option value='$lang->cash'>$lang->cash</option>
<option value='$lang->giftCertificate'>$lang->giftCertificate</option>
<option value='$lang->account'>$lang->account</option>
</select></td>
</tr>
<tr>
<td>
<font color='white'>$lang->saleComment:</font>
</td>
<td>
<input type=text name=comment size=25>
</td>
</tr>
</table>
<br>
<input type=hidden name='totalItemsPurchased' value='$totalItemsPurchased'>
<input type=hidden name='totalTax' value='$finalTax'>
<input type=hidden name='finalTotal' value='$finalTotal'>
<input type='submit' value='Afrekenen'></center></form>";
}
?>
Gewijzigd op 07/05/2012 16:37:11 door bjorn cornelissen
De scanner instellen dat ie er een <enter> achter plakt. (Indien mogelijk)
Maar anders kun je idd wat SanThe zegt een enter/return achter je invoer plakken (in de scanner).