Info uit database halen en in input bar zetten
Heej, ik heb een upload script waarbij hij de foto op de server zet en de url in een database opslaat. Hoe kan ik nu in een bepaald form script een input bar maken dat mensen netzo als je adresbalk op een pijltje kunnen klikken en dan kunnen kiezen uit de url's die in de database staan?? Alvast bedankt
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
$sql = "
SELECT titel, url
FROM tabelnaam
ORDER BY titel ASC
";
if (!$res = mysql_query ($sql)) {
trigger_error (mysql_error ());
}
else {
echo '<select name="url">';
while ($row = mysql_fetch_assoc ($res)) {
echo '<option value="'.$row['url'].'">'.$row['titel'].'</option>';
}
echo '</select>';
}
?>
$sql = "
SELECT titel, url
FROM tabelnaam
ORDER BY titel ASC
";
if (!$res = mysql_query ($sql)) {
trigger_error (mysql_error ());
}
else {
echo '<select name="url">';
while ($row = mysql_fetch_assoc ($res)) {
echo '<option value="'.$row['url'].'">'.$row['titel'].'</option>';
}
echo '</select>';
}
?>
Heej jan hardstikke bedankt, ik dacht ff niet verder dan de <input type=" maar nu lukt het wel!! Thanks
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
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
<?php
if ( !defined('INSYS') )
{
die("Hacking attempt");
}
function content_center_newitem_set()
{
return 10;
}
function content_center_newitem()
{
$dates = explode("-",date("d-m-Y-G-i"));
$hour = '';
$minute = '';
$day = '';
$month = '';
$year = '';
for($i = 0; $i <= 23; $i++)
{
$hour .= '<option '.(($dates[3] == $i) ? 'selected="selected"' : '').'value="'.get_2_chars($i).'">'.get_2_chars($i).'</option>';
}
for($i = 0; $i <= 59; $i++)
{
$minute .= '<option '.(($dates[4] == $i) ? 'selected="selected"' : '').'value="'.get_2_chars($i).'">'.get_2_chars($i).'</option>';
}
for($i = 1; $i <= 31; $i++)
{
$day .= '<option '.(($dates[0] == get_2_chars($i)) ? 'selected="selected"' : '').'value="'.get_2_chars($i).'">'.get_2_chars($i).'</option>';
}
for($i = 1; $i <= 12; $i++)
{
$month .= '<option '.(($dates[1] == get_2_chars($i)) ? 'selected="selected"' : '').'value="'.get_2_chars($i).'">'.get_2_chars($i).'</option>';
}
for($i = date('Y')-1; $i < date('Y')+3; $i++)
{
$year .= '<option '.(($dates[2] == get_2_chars($i)) ? 'selected="selected"' : '').'value="'.get_2_chars($i).'">'.get_2_chars($i).'</option>';
}
$text = '
<form action="'.SITE_ROOT.'posting.php?c='.URI_CAT.'" method="post" name="newitem" enctype="multipart/form-data">
<p><input type="hidden" name="back" value="insert" /></p>
<p><input type="hidden" name="itemcat" value="'.URI_CAT_ID.'" /></p>
<p> '.LANG_LINK.': <span id="itemlink" class="red"></span></p>
<p><input type="text" name="itemlink" value="" maxlength="20" /><br /><br /></p>
<p> '.LANG_TITLE.': <span id="itemtitle" class="red"></span></p>
<p><input type="text" name="itemtitle" value="" style="width:50%;" maxlength="50" /><br /><br /></p>
<p> Image URL: <span id="itemimagename" class="red"></span></p>
<p><input type="text" name="itemimagename" value="" maxlength="100" /><br /><br /></p>
<p> '.LANG_TEXT.': <span id="itemtext" class="red"></span></p>
<p><textarea id="itemfield" name="itemtext" style="height:260px;"></textarea></p>
<div class="itemubb">
<a href="javascript:wrapSelection(document.newitem.itemtext,\'[b]\',\'[/b]\');">B</a> <a href="javascript:wrapSelection(document.newitem.itemtext,\'[i]\',\'[/i]\');">I</a>
<a href="javascript:wrapSelection(document.newitem.itemtext,\'[u]\',\'[/u]\');">U</a> <a href="javascript:wrapSelectionWithLink(document.newitem.itemtext);">'.LANG_URL.'</a>
<a href="javascript:wrapSelectionWithColor(document.newitem.itemtext);">'.LANG_COLOR.'</a> <a href="javascript:wrapSelectionWithImg(document.newitem.itemtext);">'.LANG_IMAGE.'</a>
<a href="javascript:wrapSelection(document.newitem.itemtext,\'[quote]\',\'[/quote]\');">'.LANG_QUOTE.'</a> <a href="javascript:wrapSelection(document.newitem.itemtext,\'\',\'\');">'.LANG_CODE.'</a>
</div>
<div class="itemsmiley">
<a href="javascript:addsmiley(\':)\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_smile.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':(\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_angry.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':D\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_biggrin.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':?\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_confused.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\'8)\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_cool.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':E\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_devil.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':|\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_irritated.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':k\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_kiss.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':{\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_nosmile.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':B\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_shiny.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':P\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_tongue.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\';)\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_wink.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':9\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_yummie.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':}\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_nothing.gif" border="0" alt="" /></a>
</div>
<p> '.LANG_PUBLISH.': <span id="itempub" class="red"></span></p>
<select name="itempubday">
'.$day.'
</select>
-
<select name="itempubmonth">
'.$month.'
</select>
-
<select name="itempubyear">
'.$year.'
</select>
<select name="itempubhour">
'.$hour.'
</select>
:
<select name="itempubminute">
'.$minute.'
</select><br /><br />
<p> '.LANG_COMMENTS.':</p>
<p><input type="checkbox" name="itemifcomment" value="1" checked="checked"/><br /><br /></p>
<p><input type="submit" value="'.OK.'" /></p>
</form>
<script language="JavaScript" type="text/javascript">
document.newitem.onsubmit=validate;
function validate()
{
var item_link = document.newitem.itemlink.value.length;
var item_title = document.newitem.itemtitle.value.length;
var item_text = document.newitem.itemtext.value.length;
document.getElementById("itemlink").innerHTML = "";
document.getElementById("itemtitle").innerHTML = "";
document.getElementById("itemtext").innerHTML = "";
if(item_link < 4 || item_title < 4 || item_text < 10 || item_link > 20 || item_title > 50)
{
if(item_link < 4)
{
document.getElementById("itemlink").innerHTML = " '.MIN.' 4 '.CHARS.'";
}
if(item_title < 4)
{
document.getElementById("itemtitle").innerHTML = " '.MIN.' 4 '.CHARS.'";
}
if(item_text < 10)
{
document.getElementById("itemtext").innerHTML = " '.MIN.' 10 '.CHARS.'";
}
if(item_link > 20)
{
document.getElementById("itemlink").innerHTML = " '.MAX.' 20 '.CHARS.'";
}
if(item_title > 50)
{
document.getElementById("itemtitle").innerHTML = " '.MAX.' 50 '.CHARS.'";
}
return false;
}
return true;
}
var thisForm;
function mozWrap(txtarea, lft, rgt)
{
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
if (selEnd==1 || selEnd==2) selEnd=selLength;
var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd)
var s3 = (txtarea.value).substring(selEnd, selLength);
txtarea.value = s1 + lft + s2 + rgt + s3;
}
function IEWrap(lft, rgt)
{
strSelection = document.selection.createRange().text;
if (strSelection!="")
{
document.selection.createRange().text = lft + strSelection + rgt;
}
}
function wrapSelection(txtarea, lft, rgt)
{
if (document.all) {IEWrap(lft, rgt);}
else if (document.getElementById) {mozWrap(txtarea, lft, rgt);}
}
function wrapSelectionWithLink(txtarea)
{
var my_link = prompt("'.LANG_GIVE_LINK.':","http://");
if (my_link != null)
{
var my_text = prompt("'.LANG_GIVE_TEXT.':","");
if (my_text != "")
{
lft="[url=" + my_link + "]" + my_text;
rgt="[/url]";
wrapSelection(txtarea, lft, rgt);
}
else
{
lft="[url]" + my_link;
rgt="[/url]";
wrapSelection(txtarea, lft, rgt);
}
}
return;
}
function wrapSelectionWithImg(txtarea)
{
var my_link = prompt("'.LANG_GIVE_IMAGE.':","http://");
if (my_link != null)
{
lft="[img]" + my_link;
rgt="[/img]";
wrapSelection(txtarea, lft, rgt);
}
return;
}
function wrapSelectionWithColor(txtarea)
{
var my_link = prompt("'.LANG_GIVE_COLOR.':","#");
if (my_link != null)
{
lft="[color=" + my_link + "]";
rgt="[/color]";
wrapSelection(txtarea, lft, rgt);
}
return;
}
</script>';
load('theme_item',array(LANG_SUB_NEWITEM,$text));
}
[/code]
if ( !defined('INSYS') )
{
die("Hacking attempt");
}
function content_center_newitem_set()
{
return 10;
}
function content_center_newitem()
{
$dates = explode("-",date("d-m-Y-G-i"));
$hour = '';
$minute = '';
$day = '';
$month = '';
$year = '';
for($i = 0; $i <= 23; $i++)
{
$hour .= '<option '.(($dates[3] == $i) ? 'selected="selected"' : '').'value="'.get_2_chars($i).'">'.get_2_chars($i).'</option>';
}
for($i = 0; $i <= 59; $i++)
{
$minute .= '<option '.(($dates[4] == $i) ? 'selected="selected"' : '').'value="'.get_2_chars($i).'">'.get_2_chars($i).'</option>';
}
for($i = 1; $i <= 31; $i++)
{
$day .= '<option '.(($dates[0] == get_2_chars($i)) ? 'selected="selected"' : '').'value="'.get_2_chars($i).'">'.get_2_chars($i).'</option>';
}
for($i = 1; $i <= 12; $i++)
{
$month .= '<option '.(($dates[1] == get_2_chars($i)) ? 'selected="selected"' : '').'value="'.get_2_chars($i).'">'.get_2_chars($i).'</option>';
}
for($i = date('Y')-1; $i < date('Y')+3; $i++)
{
$year .= '<option '.(($dates[2] == get_2_chars($i)) ? 'selected="selected"' : '').'value="'.get_2_chars($i).'">'.get_2_chars($i).'</option>';
}
$text = '
<form action="'.SITE_ROOT.'posting.php?c='.URI_CAT.'" method="post" name="newitem" enctype="multipart/form-data">
<p><input type="hidden" name="back" value="insert" /></p>
<p><input type="hidden" name="itemcat" value="'.URI_CAT_ID.'" /></p>
<p> '.LANG_LINK.': <span id="itemlink" class="red"></span></p>
<p><input type="text" name="itemlink" value="" maxlength="20" /><br /><br /></p>
<p> '.LANG_TITLE.': <span id="itemtitle" class="red"></span></p>
<p><input type="text" name="itemtitle" value="" style="width:50%;" maxlength="50" /><br /><br /></p>
<p> Image URL: <span id="itemimagename" class="red"></span></p>
<p><input type="text" name="itemimagename" value="" maxlength="100" /><br /><br /></p>
<p> '.LANG_TEXT.': <span id="itemtext" class="red"></span></p>
<p><textarea id="itemfield" name="itemtext" style="height:260px;"></textarea></p>
<div class="itemubb">
<a href="javascript:wrapSelection(document.newitem.itemtext,\'[b]\',\'[/b]\');">B</a> <a href="javascript:wrapSelection(document.newitem.itemtext,\'[i]\',\'[/i]\');">I</a>
<a href="javascript:wrapSelection(document.newitem.itemtext,\'[u]\',\'[/u]\');">U</a> <a href="javascript:wrapSelectionWithLink(document.newitem.itemtext);">'.LANG_URL.'</a>
<a href="javascript:wrapSelectionWithColor(document.newitem.itemtext);">'.LANG_COLOR.'</a> <a href="javascript:wrapSelectionWithImg(document.newitem.itemtext);">'.LANG_IMAGE.'</a>
<a href="javascript:wrapSelection(document.newitem.itemtext,\'[quote]\',\'[/quote]\');">'.LANG_QUOTE.'</a> <a href="javascript:wrapSelection(document.newitem.itemtext,\'\',\'\');">'.LANG_CODE.'</a>
</div>
<div class="itemsmiley">
<a href="javascript:addsmiley(\':)\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_smile.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':(\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_angry.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':D\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_biggrin.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':?\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_confused.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\'8)\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_cool.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':E\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_devil.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':|\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_irritated.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':k\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_kiss.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':{\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_nosmile.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':B\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_shiny.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':P\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_tongue.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\';)\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_wink.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':9\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_yummie.gif" border="0" alt="" /></a>
<a href="javascript:addsmiley(\':}\');"><img src="'.SITE_ROOT.'plugins/theme/'.SITE_THEME.'/smilies/icon_nothing.gif" border="0" alt="" /></a>
</div>
<p> '.LANG_PUBLISH.': <span id="itempub" class="red"></span></p>
<select name="itempubday">
'.$day.'
</select>
-
<select name="itempubmonth">
'.$month.'
</select>
-
<select name="itempubyear">
'.$year.'
</select>
<select name="itempubhour">
'.$hour.'
</select>
:
<select name="itempubminute">
'.$minute.'
</select><br /><br />
<p> '.LANG_COMMENTS.':</p>
<p><input type="checkbox" name="itemifcomment" value="1" checked="checked"/><br /><br /></p>
<p><input type="submit" value="'.OK.'" /></p>
</form>
<script language="JavaScript" type="text/javascript">
document.newitem.onsubmit=validate;
function validate()
{
var item_link = document.newitem.itemlink.value.length;
var item_title = document.newitem.itemtitle.value.length;
var item_text = document.newitem.itemtext.value.length;
document.getElementById("itemlink").innerHTML = "";
document.getElementById("itemtitle").innerHTML = "";
document.getElementById("itemtext").innerHTML = "";
if(item_link < 4 || item_title < 4 || item_text < 10 || item_link > 20 || item_title > 50)
{
if(item_link < 4)
{
document.getElementById("itemlink").innerHTML = " '.MIN.' 4 '.CHARS.'";
}
if(item_title < 4)
{
document.getElementById("itemtitle").innerHTML = " '.MIN.' 4 '.CHARS.'";
}
if(item_text < 10)
{
document.getElementById("itemtext").innerHTML = " '.MIN.' 10 '.CHARS.'";
}
if(item_link > 20)
{
document.getElementById("itemlink").innerHTML = " '.MAX.' 20 '.CHARS.'";
}
if(item_title > 50)
{
document.getElementById("itemtitle").innerHTML = " '.MAX.' 50 '.CHARS.'";
}
return false;
}
return true;
}
var thisForm;
function mozWrap(txtarea, lft, rgt)
{
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
if (selEnd==1 || selEnd==2) selEnd=selLength;
var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd)
var s3 = (txtarea.value).substring(selEnd, selLength);
txtarea.value = s1 + lft + s2 + rgt + s3;
}
function IEWrap(lft, rgt)
{
strSelection = document.selection.createRange().text;
if (strSelection!="")
{
document.selection.createRange().text = lft + strSelection + rgt;
}
}
function wrapSelection(txtarea, lft, rgt)
{
if (document.all) {IEWrap(lft, rgt);}
else if (document.getElementById) {mozWrap(txtarea, lft, rgt);}
}
function wrapSelectionWithLink(txtarea)
{
var my_link = prompt("'.LANG_GIVE_LINK.':","http://");
if (my_link != null)
{
var my_text = prompt("'.LANG_GIVE_TEXT.':","");
if (my_text != "")
{
lft="[url=" + my_link + "]" + my_text;
rgt="[/url]";
wrapSelection(txtarea, lft, rgt);
}
else
{
lft="[url]" + my_link;
rgt="[/url]";
wrapSelection(txtarea, lft, rgt);
}
}
return;
}
function wrapSelectionWithImg(txtarea)
{
var my_link = prompt("'.LANG_GIVE_IMAGE.':","http://");
if (my_link != null)
{
lft="[img]" + my_link;
rgt="[/img]";
wrapSelection(txtarea, lft, rgt);
}
return;
}
function wrapSelectionWithColor(txtarea)
{
var my_link = prompt("'.LANG_GIVE_COLOR.':","#");
if (my_link != null)
{
lft="[color=" + my_link + "]";
rgt="[/color]";
wrapSelection(txtarea, lft, rgt);
}
return;
}
</script>';
load('theme_item',array(LANG_SUB_NEWITEM,$text));
}
[/code]
Gewijzigd op 01/01/1970 01:00:00 door Lucas
Pas je script even aan en gebruik en tags om je code heen. Gebruik je knop om dit te doen.
Niet Bumpen.
Bumpen::
SanThe.
Edit:
Ik heb nu het script ook ff tussen de code tags gezet
Gewijzigd op 01/01/1970 01:00:00 door Lucas