Jump to content

displaying mysql data to a html page after submit


OGBugsy

Recommended Posts

Hi all,  I have a form that submits data to a mysql db. It's working fine. What I am trying to do is output an html page (or possibly 2) that is propagated with the data that I just sent to the db.

 

example: when I submit a new workorder, a page comes up with all the data i just submitted. so that can be printed as a "customer copy". and in a perfect world, another page comes up that is a material order form. That can be faxed to my vendor to order the materials for that job.

 

Not looking to auto print or fax anything. I am just having trouble getting the data into my html page. Here is what I have, but sadly is not working.

<?php	

    $link = mysqli_connect("xxxx", "xxxx", "xxxx", "xxxx");

    $sql = "SELECT customer FROM jobs WHERE id=6487";
		
        echo $sql;
		 
    mysqli_close($link);
?>

I would like to use the data from the last id submitted and have tried several things like: WHERE  id=mysqli::$insert_id     and   WHERE  id=$insert_id   with no luck.

 

Here is a pic of the html form and the output i'm getting.

pic.jpg

 

Any help would be greatly appreciated. Thanks in advance.

 

OGBugsy

The last insert id is only available for the current connection. You need to get it and store it ($_SESSION) as soon as possible after the insert. When the script ends the connection closes automatically

something worth considering may be, rather than going and getting the exact same info back out the database that you just put in there, check the query status of the insert and then recycle your current data in the event of a success.

You've got the first part correct. The next part should be the result.
 
Here's your code, with the missing stuff put into it:
 
<?php    
 
$link = mysqli_connect("xxxx", "xxxx", "xxxx", "xxxx");
 
$sql = "SELECT customer FROM jobs WHERE id=6487";
        
#the missing stuff:
$result = $mysqli->query($sql) or die();
if($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo stripslashes($row['customer']);
}
}
        
mysqli_close($link);

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.