How to pass data from one table to another in php?

Asked

Viewed 1,936 times

2

I’m new to programming, and I’m developing an advertising website. And I’m struggling, in my person has the option to publish an advertisement of her. It publishes and is sent to the database, and on the control panel I put to show the advertising information, and this is when I need help.

When the advertisement is ok, I wanted to put a button: "Publish" and would send that data to another table.

How I show account information in the Dashboard:

<table border="1" width="100%" cellspacing="0" cellpadding="0" height="20" bordercolor="#C0C0C0">
<tr>
<td width="50%"><h3>Descrição</h3></td>
<td width="20%"><h3>Site</h3></td>
<td width="10%"><h3>Edita</h3></td>
<td width="5%"><h3>Deleta</h3></td>
</tr>
<?php
include ("conexao.php");
$sql="select * from principal";
$res= mysql_query ($sql);
while ($dados=mysql_fetch_array($res)){
{
    echo "<tr><td>".$dados['descricaolink'];
    echo "<td>".$dados['sitelink'];
    echo "<td><a href='edita_divulgalink.php?codigo=$dados[idlink]'><img src='img/editar.png'></a>";
    echo "<td><a href='deleta_divulgalink.php?codigo=$dados[idlink]'><img width='24' height='24' src='img/deletar.png'></a></tr>";
?>
</table>

Before editing I wanted to put a Publish that when clicking it would send that data I’m getting to another table. Someone can help me?

  • 4
  • Didn’t help me :/

  • If really need copy to a separate table, it is probably the case to create a page and access with publica_divulgalink.php?codigo=$dados[idlink] using the same logic. On this page, you can use a query like Insert .. select with ID unique if the tables are of the same DB, and if they are different Dbs, do a select in PHP, followed by a insert or replace with the data collected.

  • @Mateuslapa when you say copy the table, is in the browser, that is, the HTML table or is in the database?

1 answer

-1

What you are trying to do is not right, The most certain to do is as the friend above said you create a field in the bank called published of type Boolean that by default in your case so I understood it should start with false value, and by clicking the publish button be updated to true.

select * from propagandas where now() > data_inicio and now() < data_fim 

This select if it has a publication interval date

select * from propagandas where now() > data_inicio and now() < data_fim and publicado = true

or even better so that it ascertains whether the publication is within the publication deadline and whether it is actually published as it may be on time but not published

Browser other questions tagged

You are not signed in. Login or sign up in order to post.