PHP - Cannot Insert Into Table
hello, anybody able to see what im doing wrong?
Code: [Select] $id2=mysql_insert_id(); $year=$_POST['y']; $yr=substr($year,-2); $mth=$_POST['m']; $init=$_POST['initial']; $jobnumber=$yr.$mth.'-'.$id2.$init; $query = "INSERT INTO jobs VALUES ( '', '$id2', '$_POST[initial]', '$_POST[y]-$_POST[m]-$_POST[d]',date '$_POST[contact]', '$_POST[contactphone]', '$_POST[customer]', '$_POST[address]', '$_POST[city]', '$_POST[postal]', '$_POST[province]', '$_POST[description]' )"; mysql_query($query) or die('Error, adding new job failed. Check you fields and try again.'); echo "You have successfully entered a new job. The job number is $jobnumber"; Similar TutorialsHi
I am very new to PHP & Mysql.
I am trying to insert values into two tables at the same time. One table will insert a single row and the other table will insert multiple records based on user insertion.
Everything is working well, but in my second table, 1st Table ID simply insert one time and rest of the values are inserting from 2nd table itself.
Now I want to insert the first table's ID Field value (auto-incrementing) to a specific column in the second table (only all last inserted rows).
Ripon.
Below is my Code:
<?php $con = mysql_connect("localhost","root","aaa"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ccc", $con); $PI_No = $_POST['PI_No']; $PO_No = $_POST['PO_No']; $qry = "INSERT INTO wm_order_entry ( Order_No, PI_No, PO_No) VALUES( NULL, '$PI_No', '$PO_No')"; $result = @mysql_query($qry); $val1=$_POST['Size']; $val2=$_POST['Style']; $val3=$_POST['Colour']; $val4=$_POST['Season_Code']; $val5=$_POST['Dept']; $val6=$_POST['Sub_Item']; $val7=$_POST['Item_Desc']; $val8=$_POST['UPC']; $val9=$_POST['Qty']; $N = count($val1); for($i=0; $i < $N; $i++) { $profile_query = "INSERT INTO order_entry(Size, Style, Colour, Season_Code, Dept, Sub_Item, Item_Desc, UPC, Qty, Order_No ) VALUES( '$val1[$i]','$val2[$i]','$val3[$i]','$val4[$i]','$val5[$i]','$val6[$i]','$val7[$i]','$val8[$i]','$val9[$i]',LAST_INSERT_ID())"; $t_query=mysql_query($profile_query); } header("location: WMView.php"); mysql_close($con); ?>Output is attached. Hi there, I have a form which I want to submit data into my tables. There are going to be 4 tables involved with this form, and these 4 tables should relate to one another in some sort of way. My problem is either PHP or MySQL, but I keep getting a warning which I can't figure out. I remember this warning appearing even if the code before it is wrong, therefore I am not relying on it. This is what the error says: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in G:\xampp\htdocs\xampp\dsa\wp3.php on line 40 Here's my code: Code: [Select] <html> <head> <title>WP3</title> </head> <body> <form id="search" name="search" id="search" method="get" action="searchresults.php" /> <input type="text" name="terms" value="Search..." /> <input class="button" type="submit" name="Search" value="Search" /> </form> <?php include_once('connectvars.php'); $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if(isset($_POST['report'])){ $firstname = mysqli_real_escape_string($dbc, trim($_POST['firstName'])); $middlename = mysqli_real_escape_string($dbc, trim($_POST['middleName'])); $lastname = mysqli_real_escape_string($dbc, trim($_POST['lastName'])); $image = mysqli_real_escape_string($dbc, trim($_POST['image'])); $phone = mysqli_real_escape_string($dbc, trim($_POST['phone'])); $organisation = mysqli_real_escape_string($dbc, trim($_POST['organisation'])); $street = mysqli_real_escape_string($dbc, trim($_POST['street'])); $town = mysqli_real_escape_string($dbc, trim($_POST['town'])); $city = mysqli_real_escape_string($dbc, trim($_POST['city'])); if (!empty($firstname) && !empty($middlename) && !empty($lastname) && !empty($image) && !empty($phone) && !empty($organisation) && !empty($city)) { $query = "INSERT INTO report (organisation, phoneNo) VALUES ('$organisation', '$phone'); INSERT INTO person (firstName, middleName, lastName) VALUES ('$firstname', '$middlename', '$lastname'); INSERT INTO identification (image) VALUES ('$image'); INSERT INTO location (street, town, city) VALUES ('$street', '$town', '$city')"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 0) { mysqli_query($dbc, $query); echo "Thank you, your report has been received."; } else { // An account already exists for this username, so display an error message echo '<p>This report already exists.</p>'; $username = ""; } } else echo "Please enter all of the fields"; } ?> <form id="report_sighting" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <h2>Report a sighting</h2> <table> <tr> <td> <label>First name:</label> </td> <td> <input type="text" id="firstname" name="firstName" value="<?php if (!empty($firstname)) echo $firstname; ?>" /> </td> </tr> <tr> <td> <label>Middle name:</label> </td> <td> <input type="text" id="middlename" name="middleName" value="<?php if (!empty($middlename)) echo $middlename; ?>" /> </td> </tr> <tr> <td> <label>Last name:</label> </td> <td> <input type="text" id="lastname" name="lastName" value="<?php if (!empty($lastname)) echo $lastname; ?>" /> </td> <tr> <td> <label>Upload Identification:</label> </td> <td> <input type="file" id="image" name="image" /> </td> <tr> <tr> <td> <label>Contact phone number: </label> </td> <td> <input type="text" id="phone" name="phone" /> </td> <tr> <tr> <td> <label>Organisation: </label> </td> <td> <input type="text" id="organisation" name="organisation" /> </td> </tr> <tr> <td> <label>Street seen: </label> </td> <td> <input type="text" id="street" name="street" /> </td> </tr> <tr> <td> <label>Town seen: </label> </td> <td> <input type="text" id="town" name="town" /> </td> </tr> <tr> <td> <label>City seen: </label> </td> <td> <input type="text" id="city" name="city" /> </td> </tr> <tr> <td> </td> <td> <input type="submit" value="Report" name="report" /> </td> </tr> </table> </form> </body> </html> I've checked out the SQL statement and it's alright, so that leaves me with the PHP. I would very much appreciate if anyone could help me out here, thanks. Hello guys, this is my first post so sorry if I made any mistake
I need select record from one table and move to another table
But I get this message saying "Warning: mysqli_query() expects at least 2 parameters, 1 given in" I had that on line 158, but now i get on line 156
I start to do PHP and mysql few weeks ago, only respond i get from teacher is search and search.
<?php if (isset($_POST['username'])) { $searchq = $_POST['username']; mysqli_query("SELECT * FROM login WHERE username='$searchq'")or die ("could not search"); while($row = mysqli_fetch_array($con, $query)) { $username = $row['username']; $password = $row['password']; $age = $row['age']; $phonenumber = $row['phonenumber']; $nationality = $row['nationality']; mysqli_query("INSERT INTO admin SET username ='$username', password='$password', age='$age', phonenumber='$phonenumber', nationality='$nationality'" ) ; echo"Data successfully inserted"; } } ?>When i search i see this type of code "$data = mysqli_query" add variable before mysqli What should I do, to make it work. And send record from one table to another. Thank you Hey guys, it seems that so far in my little script everything is working except for the MySQL insert Nothing seems to appear in the table it's supposed to insert too but i dont see any errors anywhere. Any help would be appreciated. I know it's very messy but it's my first actual 'project' Code: [Select] <?php $apiKey="<omitted>"; $playeritemsURL="http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/"; $fullURL=$playeritemsURL."?key=".$apiKey."&SteamID=".$_GET["SteamID64"]."&format=xml"; $playerLocalName=$_GET["SteamID64"].".xml"; $ch=curl_init($fullURL); $fh=fopen($playerLocalName, 'w'); ?> You entered ID: <?php echo $_GET["SteamID64"];?></br> <?php echo $fullURL; curl_setopt($ch,CURLOPT_FILE,$fh); curl_exec($ch); curl_close($ch); ?> </br> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("csv_db", $con); $readXML=file_get_contents($playerLocalName); $xml=simplexml_load_file($playerLocalName); $output=$_GET["SteamID64"].".defindex.txt"; $fh=fopen($output, 'w') or die("can't open file"); //echo $xml->items->item->defindex[0]; foreach ($xml->xpath('//defindex') as $defindex) { fwrite($fh, $defindex."\n"); echo $defindex."</br>"; mysql_query("INSERT INTO ".$_GET["SteamID64"]." (defindex) VALUES (".$defindex.")"); } ?> Code: [Select] $myusername = $_POST['myusername']; mysql_query("INSERT INTO logedin ( username ) VALUES ('$myusername')") OR die("Could not send the message: <br>".mysql_error()); wont insert anything no error's given even just trying to insert username into the the loged in table yes i know i spelt loged in wrong but i did that on the db lol Hi,
The following code was written by someone else. It allows me to upload images to a directory while saving image name in the mysql table.
I also want the code to allow me save other data (surname, first name) along with the image name into the table, but my try is not working, only the images get uploaded.
What am I missing here?
if(isset($_POST['upload'])) { $path=$path.$_FILES['file_upload']['name']; if(move_uploaded_file($_FILES['file_upload']['tmp_name'],$path)) { echo " ".basename($_FILES['file_upload']['name'])." has been uploaded<br/>"; echo '<img src="gallery/'.$_FILES['file_upload']['name'].'" width="48" height="48"/>'; $img=$_FILES['file_upload']['name']; $query="insert into imgtables (fname,imgurl,date) values('$fname',STR_TO_DATE('$dateofbirth','%d-%m-%y'),'$img',now())"; if($sp->query($query)){ echo "<br/>Inserted to DB also"; }else{ echo "Error <br/>".$sp->error; } } else { echo "There is an error,please retry or check path"; } } ?>joseph Hi, I would like to do the following in PHP using a MySQL database, but not sure how. select a, b,c etc.. from mailbox where id = X then insert id,a,b,c etc.. into problem When I select, I will be calling the id So I would like it to get data from mailbox and then insert it into problem. How would I go about doing this? Thanks for any help you can give me Hello, I'm working on a PHP register form, all I want to do, is to be able to insert an extra variable into the database: Code: [Select] // now we insert it into the database $insert = " INSERT INTO users (username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."') "; $add_member = mysql_query($insert); right, so I have the username and password variable being passed. But I also want to pass a variable into a column called 'weaponAttachments', all I want for this variable to be is 5000. So, in other words, something like this: 5000['weaponAttachments'] Thanks Hi, I'm quite new to php and not the greatest of coders, so urgently require your help. I want to be able to take data from an un-normalised table and load into 2 normalised tables as below: 1) Table 1 - All Music Tracks (Un-normalised table) Album Name Artist Name Track Name Track Length etc. 2) Table 2 - Albums Table (Normalised table) ID Artist Name Album Name etc. 3) Table 3 - Tracks Table (Normalised table) ID Track Name Album ID (foreign key to Albums table) etc. Can someone please provide some sample code as a starting point? The All Music Tracks table includes both the album name and track name in each row, but I only want the album appearing once in the Albums tables, would I have to do an Distinct select first to get the album names into an array? I'm not sure how I would then have nested loop to do the insert into the Tracks table. Much Appreciated, PD Im trying to insert some values automatically into a table once the form loads, but Im getting an error. Here is the code Code: [Select] <?php $aid = $_GET['aid']; $sd = $_GET['sd']; ?> <style> #message {margin:20px; padding:20px; display:block; background:#cccccc; color:#cc0000;} </style> <div id="message">Your notification has been submitted.</div> <div style="text-align:center "> <?php $connection = mysql_connect("localhost", "username", "password"); mysql_select_db("articles", $connection); $query="INSERT INTO broken_links (articleid, article) VALUES ('$aid', '$sp')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Submitted"; mysql_close($con) ?> <table border="0" cellpadding="3" cellspacing="3" style="margin:0 auto;" > <input type="submit" id="Login" value=" Thank you. Please press to close " onclick="tb_remove()"></td> </tr> </table> </div> Any help will be appreciated I am trying to insert records from an foreach array, it only inserts the first record and I cannot work out how to get it to loop through all of the records. Thank you foreach($_SESSION['post_data_array'] AS $seat) { $rowId = substr($seat, 0, 1); $columnId = substr($seat, 1); echo $rowId . $columnId . ", "; } $sql125 = "INSERT INTO booked_seats(booking_id, row_id, column_id) values ('$book_id', '$rowId', '$columnId')"; $result125 = mysql_query($sql125); if ($result125) { echo "worked"; } else { echo "didnt work"; } Im trying to insert a name into my database but I need it to go into the column that matches the sessions user id Code: [Select] "INSERT INTO users SET name = '".$_POST['name']."'"; how do I tell it to put name into name column with id matching Session id. really appreicate if someone could please help me with this. Hey yall! I'm working on a new site idea and I've run across a problem that I know is simple enough but I'm stumped. It's in the signup form What I want to do is insert the new user into the 'Login' table and get the user id that was just created and use that to create a table with the user id in the name. Here is what I have: // now we insert user into 'Login' table mysql_real_escape_string($insert = "INSERT INTO `Login` (`UID`, `pass`, `HR`, `mail`, `FullName`) VALUES ('{$_POST['username']}', '{$_POST['pass']}', '{$_POST['pass2']}', '{$_POST['e-mail']}', '{$_POST['FullName']}')"); mysql_query($insert) or die( 'Query string: ' . $insert . '<br />Produced an error: ' . mysql_error() . '<br />' ); $error="Thank you, you have been registered."; setcookie('Errors', $error, time()+20); // Get user ID mysql_real_escape_string($checkID = "SELECT * FROM Login WHERE `mail` = '{$_POST['e-mail']}'"); while ($checkIDdata = mysql_fetch_assoc($checkID)) { $userID = $checkIDdata; // now we create table 'Transactions" for the user mysql_real_escape_string($create = "CREATE TABLE `financewatsonn`.`Transactions_{$userID}` ( `ID` INT( 20 ) NOT NULL AUTO_INCREMENT COMMENT 'Transaction ID', `name` VARCHAR( 50 ) NOT NULL COMMENT 'Name/Location', `amount` VARCHAR( 50 ) NOT NULL COMMENT 'Amount', `date` VARCHAR( 50 ) NOT NULL COMMENT 'Date', `category` VARCHAR( 50 ) DEFAULT NULL COMMENT 'Category', `delete` INT( 1 ) NOT NULL DEFAULT '0', UNIQUE KEY `ID` ( `ID` ) ) ENGINE = MYISAM DEFAULT CHARSET = utf8 COMMENT = 'User ID {$userID}'"); mysql_query($create) or die( 'Query string: ' . $create . '<br />Produced an error: ' . mysql_error() . '<br />' ); } I know in 'Get user ID' that I need to get the ID but I'm not sure how to get that information. i get the error Quote Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource at 166 which is the while line under Get user ID Hello, i have this php code. Its for sms insertion of links in to table <table border="1"> <?PHP $db_user = 'user'; $db_pass = 'pass'; $db_name = 'name'; $db_host = 'localhost'; if(mysql_connect($db_host,$db_user,$db_pass)) { mysql_select_db($db_name); mysql_query("CREATE TABLE IF NOT EXISTS smsads(id bigint unsigned primary key auto_increment, link varchar(255), fromnum varchar(60))"); $res = mysql_query("SELECT * FROM smsads ORDER BY id DESC LIMIT 10"); while($row = mysql_fetch_object($res)) { $http_link = $row->link; if(strstr($http_link, 'http') === FALSE) $http_link = 'http://'.$http_link; echo "<tr><td><a href=\"{$http_link}\" target=\"_blank\">{$row->link}</a></td></tr>"; } } ?> </table> The problem is that i use tpl files for the visual part and all my other tables are in tpl. How can i insert the table above in my tpl file, whitout loosing its functions? What gets put in for the values is my problem. I have tried every way I can think of but I get errors in the code or I don't get the row inserted. Can anyone give me a code sample using $ variables, preferably a multi-line list? I would have to fix up my code to show you what I am trying as it is in between tries now. I have to be doing something wrong and may have to put together a simple test script but a working example would be better. Everything I look at on the web shows "xxxxx xxxx" examples not $variables. Thanks in advance. Hi to All, I am performing calculation which i echo it in the input form to insert it to DB table The calculation works fine when i submit the form but the it does not correct calculation to the DB. it seems that the isert to database is done before the calculation and I can't figure a way around it. Because i'm submitting to the same page, the calculation populate in the input form correctly but it insert Zero to the database table instead of correct calculation populated in the input field to DB table You could see from the line 114 to 116 that, i'm performing some calculations and echo it at line 128 and line 128 in the input form value field. Please any help on how to do this...All the function in the code is in another file and it works fine...so the only program is that the calculated value is not inserted as expected Here is the code <?php include 'core/initForMainLogPage.php'; if(isset($_GET['empId']) && !empty($_GET['empId'])){ //delete employee here $empId=$_GET['empId']; grabEmpId($empId); } ?> <?php if(logged_in()){ $data=user_dataManager('username'); $usernameData=$data['username']; }else{ header('Location: index.php'); } ?> <?php include 'includes/adminHeadAll.php';?> <header> <?php include 'includes/managerMenu.php';?> </header> <div class="container"> <br/> <h3>Pay Employee</h3> <?php $error=array(); $errorAll=''; $leave=""; if(isset($_POST['empId']) && isset($_POST['name']) && isset($_POST['date']) && isset($_POST['basicSalary']) && isset($_POST['leave']) && isset($_POST['salaryPerDay']) && isset($_POST['leaveDeduct']) && isset($_POST['netSalary'])){ $empId=htmlentities(mysql_real_escape_string($_POST['empId'])); $name=htmlentities(mysql_real_escape_string($_POST['name'])); $date=htmlentities(mysql_real_escape_string($_POST['date'])); $basicSalary=htmlentities(mysql_real_escape_string($_POST['basicSalary'])); $leave=htmlentities(mysql_real_escape_string($_POST['leave'])); $salaryPerDay=htmlentities(mysql_real_escape_string($_POST['salaryPerDay'])); $leaveDeduct=htmlentities(mysql_real_escape_string($_POST['leaveDeduct'])); $netSalary=htmlentities(mysql_real_escape_string($_POST['netSalary'])); //checking for the validity of data entered if(empty($leave) || empty($date)){ $error[]='Pleave leave or date field is empty.'; }else{ if(preg_match('/[0-9]/',$leave)==false){ $error[]='Leave should only contain numbers'; } if(empId($empId)===false){ $error[]="This employee is not recoganize by the system and can not be paid,he may need to register first."; } } if(!empty($error)){ $errorAll= '<div class="error"><ul><li>'.implode('</li><li>',$error).'</li></ul></div>'; }else{ //this funciton insert into database payrollData($name,$empId,$date,$basicSalary,$leave,$salaryPerDay,$leaveDeduct,$netSalary); echo '<p class="pa">Payment made successfully. <a href="employees-salary-report.php">See Payment Records</a></p>'; } }//end isset ?> <div class="tableWrap"> <form action="" method="post" > <div class="styletable"><table cellpadding="" cellspacing="" border="0"> <?php $query=mysql_query("SELECT empId,name,level,company.compId,company.levelOne,company.levelTwo, company.levelThree,company.levelFour,company.levelFive FROM employee JOIN company ON company.compId=1 WHERE empId='$empId' LIMIT 1"); while($row=mysql_fetch_array($query)){ $empId=$row['empId']; $name=$row['name']; $levelEmp=$row['level']; $levelOne=$row['levelOne']; $levelTwo=$row['levelTwo']; $levelThree=$row['levelThree']; $levelFour=$row['levelFour']; $levelFive=$row['levelFive']; if($levelEmp==1){ $levelPay=$levelOne; }elseif($levelEmp==2){ $levelPay=$levelTwo; }elseif($levelEmp==3){ $levelPay=$levelThree; }elseif($levelEmp==4){ $levelPay=$levelFour; }elseif($levelEmp==5){ $levelPay=$levelFive; } //making calculations here $basicSalary=$levelPay * 30; $leaveDeduct=$leave * $levelPay; $netSalary=$basicSalary - $leaveDeduct; } ?> <tr><td>Employee ID: </td><td><input type="text" name="empId" readonly="readonly" value="<?php if(isset($empId)){echo $empId;}?>"></td></tr> <tr><td>Employee: </td><td><input type="text" name="name" readonly="readonly" value="<?php if(isset($name)){ echo $name;}?>"></td></tr> <tr><td>Date: </td><td><input type="text" id="Date" class="picker" name="date"></td></tr> <tr><td> Basic Salary: </td><td><input type="text" name="basicSalary" readonly="readonly" value="<?php echo $basicSalary;?>"></td></tr> <tr><td> No. Of Absent: </td><td><input type="text" name="leave" class="input" value=""></td></tr> <tr><td> Salary Per Day:</td><td><input type="text" name="salaryPerDay" readonly="readonly" value="<?php echo $levelPay;?>"></td></tr> <tr><td> Deduction For Absentee:</td><td><input type="text" name="leaveDeduct" readonly="readonly" value="<?php echo $leaveDeduct;?>"></td></tr> <tr><td> Net Salary:</td><td><input type="text" name="netSalary" readonly="readonly" value="<?php echo $netSalary;?>"></td></tr> <tr><td> </td><td><input type="submit" value="Submit Pay" class="submit" name="pay"></td></tr> </table></div> </form> <?php ?> </div> <br /> <?php echo $errorAll; ?> <p>Manage the monthly salary details of your employee along with the allowances, deductions, etc. by just entering their leave</p> </div> <?php include 'includes/footerAll.php';?> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery-ui.js"></script> <script type="text/javascript" src="js/ui.js"></script> </body> </html> Hi guys, Im making an event booking/reservation site, I have 5 tables (Malls, Events, Booking, Reservation and Users) which are all connected and doing fine. I created a function which is this... function select_all_events_by_mall_id($mall_id) { echo "<table id='event_table'>"; echo "<th>Event Name</th>"; echo "<th>Event Location</th>"; echo "<th>Number of Cars</th>"; echo "<th>Description</th>"; echo "<th>Booked</th>"; echo "<th>Reserved</th>"; echo "<th>Reserved Until</th>"; echo "<th>Vacant</th>"; $events_set = select_all_events($mall_id); while($events = mysql_fetch_array($events_set)) { echo "<tr>"; echo "<td>" . $events['event_name'] . "</td>"; echo "<td>" . $events['event_location'] . "</td>"; echo "<td>" . $events['number_of_cars'] . "</td>"; echo "<td>" . $events['description'] . "</td>"; // Booked echo "<td>"; $booked_set = select_all_booking($events['id']); while($booked = mysql_fetch_array($booked_set)) { $user_set = select_all_user_booked($booked['users_id']); while($user = mysql_fetch_array($user_set)) { echo $user['company'] . ", " . $user['branch'] . "<br />"; } } echo "</td>"; // Reserved echo "<td>"; echo "<ol>"; $reserved_set = select_all_reservation($events['id']); while($reserved = mysql_fetch_array($reserved_set)) { if(empty($reserved['events_id'])) { echo "No Reservation's "; } else { $reserved_user = select_all_user_reserved($reserved['users_id']); while($user_set = mysql_fetch_array($reserved_user)) { echo "<li>" . $user_set['brand'] . ", " . $user_set['branch'] . "</li>"; } } } echo "</ol>"; echo "</td>"; // Expiration Date echo "<td>"; echo "<ol>"; $reserved_set = select_all_reservation($events['id']); while($reserved = mysql_fetch_array($reserved_set)) { $reserved_user = select_all_user_reserved($reserved['users_id']); while($user_set = mysql_fetch_array($reserved_user)) { $exp_date = select_all_expiration_date($user_set['id']); while($date = mysql_fetch_array($exp_date)) { echo "<li>" . $date['expiration_date'] . "</li>"; } } } echo "</ol>"; echo "</td>"; //Vacant echo "<td>"; $vacant_set = select_all_booking($events['id']); $booking_count = mysql_num_rows($vacant_set); $reserved_count = mysql_num_rows($reserved_set); $total_count = $booking_count + $reserved_count; $vacant = $events['number_of_cars'] - $total_count; if($vacant < 0) { echo "This Event is fully booked"; } else { echo $vacant; } echo"</td>"; echo "</tr>"; } echo "</table>"; } The function starts by receiving an id from picking a mall name from a select tag. It works fine, it outputs the data on the page like i want it to, but my problem is that i need a way to add a submit or any button to each generated row that will, when clicked will insert the event id and user id (who clicked it) to my booking/reservation table as a new row. I tried adding a form inside my function and saving the event id every loop but when i click the submit button i think it doesn't work (or i made a mistake).. Sorry if my coding sucks, I'm kinda new in php. Sorry if its kinda confusing my head is spinning right now from thinking this stuff the whole day.. Thanks in advance for any comments and ideas. Good evening,
I am working on a program that takes images, and casts them into an associated array, I then want to display thumbnails of those images into a 3 column by 4 row table...
[image][image][image]
[image][image][image]
[image][image][image]
[image][image][image]
(For my visual friends)
here is my current, pardon for the mess, but right now, functionality is more important.
<!DOCTYPE html> <html> <head> <title>Zodiac Gallery</title> </head> <body> <h2 style="text-align:center">Zodiac Gallery</h2> <p>Click a thumbnail image to see enlarged view.</p> <?php $ZodiacArray = array ( "Images/rat.jpg" => "Rat", "Images/ox.jpg" => "Ox", "Images/tiger.jpg" => "Tiger", "Images/rabbit.jpg" => "Rabbit", "Images/dragon.jpg" => "Dragon", "Images/snake.jpg" => "Snake", "Images/horse.jpg" => "Horse", "Images/goat.jpg" => "Goat", "Images/monkey.jpg" => "Monkey", "Images/rooster.jpg" => "Rooster", "Images/dog.jpg" => "Dog", "Images/pig.jpg" => "Pig"); foreach ($ZodiacArray as $image => $zodiac) { echo "<table> <tr> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> </tr> <tr> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> </tr> <tr> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> </tr> <tr> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> </tr> </table>"; ?>Help is welcome, thank you. |