hello. i've created this with help from a friend.
|uid || id ||url|
i have input fields to add the data.
<table width="100%">
<tr>
<td width="140" style="padding:4px;">url 1:</td>
<td ><input type="text" class="edit bk" name="urls[]" style="width:350px"></td>
</tr>
<tr>
<td width="140" style="padding:4px;">link 2:</td>
<td ><input type="text" class="edit bk" name="urls[]" style="width:350px"></td>
</tr>
<tr>
<td width="140" style="padding:4px;">link 3:</td>
<td ><input type="text" class="edit bk" name="urls[]" style="width:350px"></td>
<tr>
</table>
here is my php array
<?php
if(isset($_POST['urls']))
{
$urls = array_map(array_filter(array_map($_POST['urls'], 'trim')), 'htmlspecialchars');
//Create array to hold insert values
$values = array();
//Create array for results messages
$results = array();
//Process processed post data
foreach($_POST['urls'] as $url)
{
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $url))
{
$results[] = "'{$url}' is an invalid url.";
}
else
{
$values[] = "('{$row}', '{$url}')";
$results[] = "'{$url}' was inserted nto database.";
}
}
$query = "INSERT INTO " . PREFIX . "_post_links (id, url)
VALUES" . implode(', ', $values);
$db->query($query);
echo implode("<br>\n", $results);
}
?>
I'd like to add another column to my table which will be called 'name'. How do I do this?
Ive tried
foreach($_POST['urls'] as $url) && ($_POST['names'] as $name )
but this returns an error.
is there a way to put two $_post into one foreach? I'd just like to add another input field into my form and have it pass to the database.