Forum Moderators: coopster
I was wondering if their was a way to make this link pop up in a new window if poss.
<a href=\"job-info.php?id=".$id."\">I'm Interested</a>
Many Thanks
I click the button and nothing happens, i might not have the query correct.
Many Thanks
$sql = "SELECT * FROM job_board";
$res = mysqli_query($mysqli, $sql);
if($res) {
while ($newArray = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
$id = $newArray['id'];
$title = $newArray['title'];
$short = $newArray['short'];
$salary = $newArray['salary'];
$end_date = $newArray['end_date'];
echo "<div id='border'>";
echo "<div class='bg'><div class='subject'>".$title. " £" .$salary."</div></div>";
echo "<div class='body'>".$short."</div>";
echo "<input type='submit' name='delete' id='delete' value='Delete'>";
echo "</div><br>";
}
} else {
printf("Could not retrieve records: %s\n", mysqli_error($mysqli));
}
if(isset($_POST['delete'])) {
$query = "DELETE FROM job_board WHERE id=?$id";
mysql_query($mysqli, $query) or die('Error : ' . mysql_error());
echo "job deleted";
}
} else {
echo "Could not delete job";
}
as I mentioned unless your code is different than what is here
this line doesn't work
mysql_query($mysqli, $query)
in your other queries you show that $mysqli is your connection and for that function you need to feed it query first, or you need to change to mysqli_query
just making sure that was done or nothing will work, and if it does work without changing it then you have another unknown error
at this point I would repost the code so that we could see what changes have been made, there have been a lot of catches
target="_blank" is the code to open the link in a new window.
Paste this anywhere between <head> and </head>:
<script type="text/javascript">
function newWin(url,w,h) {
var day = new Date();
var id = day.getTime();
var params='width='+w+'.height='+h+',resizable,scrollbars';
var win = open(url,id,params);
return false;
}
</script>
Then for every link you need,
<a href="file.html" onclick="return newWin('file.html',600,600);">new window</a>
Control the width and height with the last two numbers.
Per your PHP problem, I don't see form tags which may be the problem, but also you have
echo "<input type='submit' name='delete' id='delete' value='Delete'>";
if(isset($_POST['delete'])) {
$query = "DELETE FROM job_board WHERE id=?$id";
.....
Where does $id get set? Id you echo'ed $_POST['delete'], you would get
Delete
Because that's the submitted value of delete. You would probably need to do something like this:
echo "<input type=\"hidden\" name=\"delete_id\" value=\"$id\">";
echo "<input type='submit' name='delete' id='delete' value='Delete'>";
if(isset($_POST['delete_id'])) {
$query = "DELETE FROM job_board WHERE id=".$_POST['delete_id'];
.....
or
if(isset($_POST['delete']) and ($id==$_POST['delete_id'])) {
$query = "DELETE FROM job_board WHERE id=$id";
.....
Of course, the variable delete_id should be cleansed before performing the delete, but that's the Cliff notes . . .