Jump to content

Insert Id Number Into Database


justlukeyou

Recommended Posts

Hi,

 

I can echo the id number of a member. "The ID Number is 239." I am now trying to enter number of the user as the organiserid.

 

I can insert eventname into the table but I am struggling to add the id number. Can anyone advise how I should be doing this please.

 

 

<div class="boardintro">
The ID Number is <?php echo (!empty($row['id'])) ? $row['id'] : ''; ?>
</div>

<?php
if(isset($_POST['createevent'])){
 $organiserid = trim($_POST['$id']);
$eventname = mysql_real_escape_string(trim($_POST['eventname']));

{
 $query = mysql_query("INSERT INTO table (eventname, organiserid) VALUES ('" .$eventname."', '" .$organiserid."')");
 if($query) {
 } else {
$error = "There was a problem with the submission. Please try again.";
 }
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/271561-insert-id-number-into-database/
Share on other sites

Okay, so Im selecting it from the database and I can echo it. How do I allocate it to a variable.

 

So to transfer a variable from one table to another table I have to allocate it to a variable first?

 

 <?php
$query = "SELECT * FROM users WHERE id = " . intval($_SESSION['userID']) . " LIMIT 1";
if ($result = mysql_query($query)) {

		    $row = mysql_fetch_array($result);
}
		    ?>

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.