PHP - Php Form Not Adding Links To Database
hello, i am hoping someone can help, i have a form that has a body and title fields and then sends to this function below.
it all works fine, but when i add a image or a link it stores it in the text field of the db like this: <IMG alt=\"\" src=\"/public/images/231781538234094.jpg\" width=796></P> this is what it should be /public/images/231781538234094.jpg so when i view the image it doesent show it and i right click the image and goto image properties and i get this: http://test.cyberglide.co.uk/%22public/images/231781538234094.jpg/%22 Code: [Select] function content_update() { $title = mysql_real_escape_string($_POST['title']); $body = mysql_real_escape_string($_POST['body']); $page = mysql_real_escape_string($_POST['page']); $location = mysql_real_escape_string($_POST['location']); $id = mysql_real_escape_string($_POST['id']); $sql = "UPDATE content SET title = '$title', body = '$body', page = '$page', location = '$location' WHERE id = '$id'"; $res = mysql_query($sql) or die(mysql_error()); echo "<script>window.location='content.php'</script>"; } if i manually edit it on the db it works fine please help, many thanks. Similar TutorialsSo i have an event page where it will show the next 3 events, then i need logged in users to click either of two buttons to say there attending or not attending. i have the below code showing events, and the <form> and the submit and both buttons, but if i submit 1 button on event ID: 1 it inserts data into the database but for event ID: 2, and if i click the button on event ID :2 it also puts it into database with eventid:2 so no matter which event i click it seems to submit data with the latest event ID shown on page, and not for "each" event seperatly. i have moved the submit query everywhere around and still same results or duplicate results if its in the loop. i assume its looping the submit and only submitting the latests event ID.
<?php if ($result = $con->query("SELECT * FROM events ORDER BY id ASC LIMIT 3")) { if ($result->num_rows > 0) { while ($row = $result->fetch_object()) { $event_id = $row->id; // set up table and echo data! echo "<table border='1' cellpadding='2' width='50%'>"; echo "<tr><td>"; echo "<p><img src='images/raid_banners/" . $row->bannerimg . "'>" . $row->name . " (iLvl: " . $row->itemlevel . ")</p>"; echo "<p>Event Starts: " . $row->datestart . " - " . $row->timestart . "</p>"; echo "<p>Event Ends: " . $row->dateend . " - " . $row->timeend . "</p>"; echo "<p>Raid Lead: " . $row->raidlead . "</p>"; echo "<form action='' name='$event_id' method='post'>"; // Process and populate SELECT form element echo "<select name=\"charname\">"; $sql = mysqli_query($con, "SELECT * FROM characters WHERE userid = $userid"); while ($row = $sql->fetch_assoc()){ echo "<option value=\"{$row['id']}\">{$row['charname']}</option>"; } echo "</select>"; echo "<input type='hidden' name='raidid' value ='$event_id'>"; echo "<input type='hidden' name='action' value='submit' />"; echo "<input type=\"submit\" name=\"submit\" value=\"going\">"; echo "<input type=\"submit\" name=\"submit\" value=\"notgoing\">"; echo "</form></td></tr></table><br><br>"; } if(isset($_POST['action'])){ $charid = $_POST['charname']; $submit = $_POST['submit']; // Submit the data from dropdown in the form mysqli_query($con,"INSERT INTO eventsignup (eventid, charid, userid, status) VALUES ('$event_id', '$charid', '$userid', '$submit')"); } } else { echo "No results to display!"; } } else { echo "Error: " . $con->error; } $con->close(); ?> any help would be awesome. im tearing my hair out here. I am trying to set up a item entry page form.png: Upon submission it shows unsuccessful even though I have checked the fields on mysql table and seem to be good am I missing something? Code: [Select] <form action="" method="post" enctype="multipart/form-data" name="Product_Entry"> <TABLE> <TR> <TD>Product ID</TD><TD><input name="SKU_ProductID" value="<?php if (isset($_post['SKU_ProductID'])) echo $_POST['SKU_ProductID']; ?>" type="text" size="11" maxlength="11" /></TD> </TR> <TR> <TD>Merchant SKU ID</TD><TD><input name="SKU_MerchSKUID" value="<?php if (isset($_post['SKU_MerchSKUID'])) echo $_POST['SKU_MerchSKUID']; ?>" type="text" size="18" maxlength="30" /></TD> </TR> <TR> <TD>Game Title</TD><TD><input name="Game_Title" value="<?php if (isset($_post['Game_Title'])) echo $_POST['Game_Title']; ?>" type="text" size="40" maxlength="40" /></TD> </TR> <TR> <TD>Platform</TD><TD><input name="Platform" value="<?php if (isset($_post['Platform'])) echo $_POST['Platform']; ?>" type="text" size="20" maxlength="20" /></TD> </TR> <TR> <TD>Genre</TD><TD><input name="Genre" value="<?php if (isset($_post['Genre'])) echo $_POST['Genre']; ?>" type="text" size="11" maxlength="11" /></TD> </TR> <TR> <TD>Weight</TD><TD><input name="Weight" value="<?php if (isset($_post['Weight'])) echo $_POST['Weight']; ?>" type="text" size="7" maxlength="7" /></TD> </TR> <TR> <TD>Supplier</TD><TD><input name="Supplier" Value="<?php if (isset($_post['Supplier'])) echo $_POST['Supplier']; ?>" type="text" size="25" maxlength="25" /></TD> </TR> <TR> <TD>Suppliers Price</TD><TD><input name="Supplier_Price" value="<?php if (isset($_post['Supplier_Price'])) echo $_POST['Supplier_Price']; ?>" type="text" size="10" maxlength="12" /></TD> </TR> <TR> <TD>Cashback</TD><TD><input name="Cashback" value="<?php if (isset($_post['Cashback'])) echo $_POST['Cashback']; ?>" type="text" size="6" maxlength="8" /></TD> </TR> <TR> <TD>Cashback Amount</TD><TD><input name="Cashback_Amount" value="<?php if (isset($_post['Cashback_Amount'])) echo $_POST['Cashback_Amount']; ?>" type="text" size="7" maxlength="11" /></TD> </TR> <TR> <TD><input type="hidden" name="submitted" value="true"/></TD><TD><input name="Submit" type="submit" value="Add_Product" /></TD> </TR></form></TABLE> <?php # Product Entry $page_title = 'Product Entry'; if (isset($_POST['Submit'])) { $errors = array(); if (empty($_POST['SKU_ProductID'])) { $errors[] = 'Please enter Product ID.'; } else { $sid = trim($_POST['SKU_ProductID']); } if (empty($_POST['SKU_MerchSKUID'])) { $errors[] = 'Please enter Merchant SKU.'; } else { $mid = trim($_POST['SKU_MerchSKUID']); } if (empty($_POST['Game_Title'])) { $errors[] = 'Please enter Game Title.'; } else { $gt = trim($_POST['Game_Title']); } if (empty($_POST['Platform'])) { $errors[] = 'Please enter Platform.'; } else { $pl = trim($_POST['Platform']); } if (empty($_POST['Genre'])) { $errors[] = 'Please enter Genre.'; } else { $ge = trim($_POST['Genre']); } if (empty($_POST['Weight'])) { $errors[] = 'Please enter Weight.'; } else { $we = trim($_POST['Weight']); } if (empty($_POST['Supplier'])) { $errors[] = 'Please enter Supplier.'; } else { $sup = trim($_POST['Supplier']); } if (empty($_POST['Supplier_Price'])) { $errors[] = 'Please enter Supplier Price.'; } else { $sp = trim($_POST['Supplier_Price']); } if (empty($_POST['Cashback'])) { $errors[] = 'Please enter Cashback %.'; } else { $cb = trim($_POST['Cashback']); } if (empty($_POST['Cashback_Amount'])) { $errors[] = 'Please enter Cashback Amount.'; } else { $cba = trim($_POST['Cashback_Amount']); } if (empty($errors)) { require_once ('connect.php'); [b]$q = "INSERT INTO `Products` (`SKU_ProductID`, `SKU_MerchSKUID`, `Game_Title`, `Platform`, `Genre`, `Weight`, `Supplier`, `Supplier_Price`, `Cashback`, `Cashback_Amount`) VALUES ('$sid', '$mid', '$gt', '$pl', '$ge', '$we', '$sup', '$sp', '$cb', '$cba')"; $r = @mysql_query ($dbc, $q); if ($r) { // If it ran OK. // Print a message: echo '<h1>Thank you!</h1> <p>Product Inserted!</p><p><br /></p>'; } else { // If it did not run OK. // Public message: echo '<h1>System Error</h1> <p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>'; // Debugging message: echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>'; } // End of if ($r) IF. mysqli_close($dbc); // Close the database connection.[/b] // Include the footer and quit the script: include ('includes/footer.html'); exit(); } else { echo '<H1>Error!</H1> <p class="error">The Following error(s) occurred:<br />'; foreach ($errors as $msg) { echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /></p>'; } } ?> If there is anything else needed let me know I added a search form on my site but I cannot figure out how to add links to the search results.
The results are being posted as the item name and the item pages look like this used-product.php?Item=102
I am not understanding how I can have that url match up with my item name.
Here is my results.php code
In the header
<?php include_once('mysql_connect.php'); if (!isset($_POST['search'])) { header ("Location:index.php"); } $search_sql="SELECT * FROM new_equip WHERE itemname LIKE '% " .$_POST ['search'] . " %'"; $search_query=mysql_query($search_sql); if(mysql_num_rows($search_query)!=0) { $search_rs=mysql_fetch_assoc($search_query); } ?>and where the results are being displayed <?phpif (mysql_num_rows($search_query)!=0){ do {?> <p><a href="new-product.php?Item=<?php echo $eid; ?>"><?php echo $search_rs ['itemname']?></a></p> <?php } while ($search_rs=mysql_fetch_assoc($search_query)) ; } else { echo "No Results Found"; } ?>I have been on this and trying to figure out another issue I am having and I cannot figure out either of them. (The other is deleting a row from a table with the click of a link) Any help on this would be greatly appreciated it. I have looked and trial and error all day and I cannot seem to get it. HI guys, On my site users are enabled to see the location of other users they are trying to find, but i want to add a link to that all users profiles on the window of their marker. Below is the code for the map. The link would be coded something like Code: [Select] <a href="userprofile.php?id=<?php echo $row['id'];?>"> im not sure if this is or the correct approach . I would thnk that it would have to be added to the create marker function... but i can get it to work Any help would be appreciated. Code: [Select] <script type="text/javascript"> //<![CDATA[ var iconBlue = new GIcon(); iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png'; iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; iconBlue.iconSize = new GSize(12, 20); iconBlue.shadowSize = new GSize(22, 20); iconBlue.iconAnchor = new GPoint(6, 20); iconBlue.infoWindowAnchor = new GPoint(5, 1); var iconRed = new GIcon(); iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png'; iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; iconRed.iconSize = new GSize(12, 20); iconRed.shadowSize = new GSize(22, 20); iconRed.iconAnchor = new GPoint(6, 20); iconRed.infoWindowAnchor = new GPoint(5, 1); var customIcons = []; customIcons["restaurant"] = iconBlue; customIcons["bar"] = iconRed; function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(51.89787, -8.47109), 13); GDownloadUrl("geo.php", function(data) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var name = markers[i].getAttribute("name"); var address = markers[i].getAttribute("address"); var type = markers[i].getAttribute("type"); var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var marker = createMarker(point, name, address, type); map.addOverlay(marker); } }); } } function createMarker(point, name, address, type) { var marker = new GMarker(point, customIcons[type]); var html = "<b>" + name + "</b><br/>" + address; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker; } //]]> Hey im trying to come up with a simple script that shows the databases in my localhost then create a insert box with a "submit button" and when i type in any name lets just say test1234 it should show up in the list and i want it to show the results below such as you successfully added a database. I have started this not too long ago but i've had experience with previous database adding and i just threw it in there to get me started. Here is my code as of now. By the way I am using PHP my admin and i have it so it creates it to the list but it does it automatically but i want it to add it by me typing it in the text box and when i hit the submit button it shows up in the list and below as well. Code: [Select] <? $connection = @mysql_connect("localhost", "root", "") or die(mysql_error());; $dbs = @mysql_list_dbs($connection)or die(mysql_error()); $db_list="<ul>"; $i =0; while ($i < mysql_num_rows($dbs)){ $db_names[$i] = mysql_tablename($dbs,$i); $db_list .="<li>$db_names[$i]"; $i++; } $db_list .="</ul>"; ?> <HTML> <HEAD> <TITLE>MySQL Databases</TITLE> </HEAD> <P><strong>Databases on localhost</strong>:</p> <? echo "$db_list"; ?> </BODY> </HTML> <HTML> <HEAD> <TITLE>Adding a Database to MySQL</TITLE> </HEAD> <BODY><H3> <FORM METHOD="post" ACTION="pretask.php"> <P>Database Name <INPUT TYPE="text" NAME="val1" SIZE=10></P> <P><INPUT TYPE="submit" NAME="submit" VALUE="Add database"></P> </FORM> </BODY></H3> </HTML> </font> <? $connection = @mysql_connect("localhost", "root", "") or die(mysql_error()); if ($connection) { $msg = "YES!"; } $sql = "CREATE DATABASE my_music "; $result = @mysql_query($sql,$connection) or die(mysql_error()) ?> <HTML> <BODY> <h1><center><? echo "$msg"; ?></h1></center> </BODY> </HTML> I am stuck on inserting the data into mysql via php. Its a foreach method and I am just stuck Code: [Select] include '../Database/take_an_exam.php'; $intNum = 1; $intnumber = 1; while( $info = mysql_fetch_array( $sqll )){ echo "<input type='hidden' name=\"Que_ID\" value=\"{$info['Que_ID']}\" /> "; echo " $intNum, {$info['Que_Question']} <br />\n"; $intNum++; for ($i =1; $i < 5; $i++) { echo "<input type=\"checkbox\" name=\"choice[{$info['Que_ID']}.$i][]\" />{$info['Que_Choice'.$i]}<br />\n"; $intnumber++; } } ?> <input type="submit" value="submit" name="submit"> This is my form that can output the Question and its choices. I am echoing this on to the next page, the code is shown below Code: [Select] <?PHP session_start(); $name= $_SESSION['username1']; echo "User ID: $name <br/>"; $gender = $_POST["choice"]; $que_ID = $_POST["Que_ID"]; foreach ($gender as $key => $array) { if($array) { $val=1; } ///echo "Question ID and the choice ID:$key. Value is:.$val <br />\n"; $well = array(floor($key), substr(strstr($key, '.'), 1)); //$well = array(floor($key), $key - floor($key)); echo "Question ID: $well[0], "; echo "Choice: $well[1]. value: $val<br/>"; } //}break; ?> Now, instead of echoing. I just want to add this to mysql. The layout of my sql is Que_ID, Ans_Choice1, Ans_Choice2, Ans_Choice3, Ans_Choice4, Use_ID When I echo my php my outcome is Quote User ID: 2 Question ID= 1 Choice 1 Question ID= 2 Choice 3 Question ID= 3 Choice 4 Question ID= 4 Choice 1 Hey anybody can please guide me where I m wrong in this php code please reply here is the code Only variables should be passed by reference on line 3 in that function area function get_file_extension($file_name) main error I guess is the explode one Aand yeah I checked adding $file_name = $_FILES['fld']; before the function is started <?php require("include/dbconn.php"); //$username = mysql_real_escape_string($_POST['username1']); function get_file_extension($file_name) { return end(explode('.',$file_name)); } function errors($error){ if (!empty($error)) { $i = 0; while ($i < count($error)){ $showError.= '<div class="msg-error">'.$error[$i].'</div>'; $i ++;} return $showError; }// close if empty errors } // close function if (isset($_POST['submit'])){ $username = "Sunny"; $date1 = date("d m y"); mysql_select_db("deals") or die(mysql_error()); if($username == "") { //header("location:newnewuser1.php"); echo "Username empty"; //header("location:newnewuser1.php"); } else { function createRandomPassword() { $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*1000000); $i = 0; $pass = '' ; while ($i <= 7) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass . $tmp; $i++; } return $pass; } // Usage $password = createRandomPassword(); //$password = mysql_real_escape_string($_POST['Password']); $date = strtotime("+2hours"); $date1 = date("d-m-y",$date); if(get_file_extension($_FILES["fld"]["name"])!= 'csv') { $error[] = 'Only CSV files accepted!'; echo "Wrong Input"; }//get_file_extension if (!$error) { $tot = 0; $handle = fopen($_FILES["fld"]["tmp_name"], "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { for ($c=0; $c < 1; $c++) { try { mysql_query("INSERT INTO newusers (email,password,location,company,name,contact,sourcename,date)VALUES('".mysql_real_escape_string($data[0])."','$password','".mysql_real_escape_string($data[1])."', '".mysql_real_escape_string($data[2])."','".mysql_real_escape_string($data[3])."','".mysql_real_escape_string($data[4])."','$username1','$date1')"); $tot++; } catch(Exception $e) { PRINT 'ERROR:' +$e; } }//for }//while fclose($handle); }// end no error }//close if isset upfile } ?> and this is the form code <form name="f1" action="" method="POST" enctype="multipart/form-data"> <table><tr><td><input type="file" value="Browse" name="fld" onselect="CheckExtension(fld)"><br/></td><td> </td></tr><tr><td>Username :<input type="text" name="username1" value="" id="user" onfocus="validateForm1()"></td> <td><input type="submit" name="submit" value="submit" id="submit"></td></tr></table> </form> Please help me I m stuck in this quite badly Please [attachment deleted by admin] Hey i have set up a database and im trying to ad records to it also upload an image, when i submit my form it clears the fields but does not add to the database. There are no errors that get outputted or anything so it gives no help I have read thru my code over and over and just cant see why its not adding. Any help would be great <html> <script language="JavaScript"> function validated(){ var matric = document.s.matric.value; var name = document.s.name.value; var course = document.s.course.value; var sem = document.s.sem.value; var semint = parseInt(sem); var tel = document.s.tel.value; var telint = parseInt(tel); var address = document.s.address.value; var picture = document.s.picture.value; if(matric==""){ window.alert("Please enter matric number!"); document.s.matric.focus(); return false; } if(name==""){ window.alert("Please enter student name!"); document.s.name.focus(); return false; } if(course==""){ window.alert("Please enter student course!"); document.s.course.focus(); return false; } if(isNaN(semint)){ window.alert("Please enter student semester!"); document.s.sem.focus(); return false; } if(isNaN(telint)){ window.alert("Please enter contact number!"); document.s.tel.focus(); return false; } if(address==""){ window.alert("Please enter student address!"); document.s.address.focus(); return false; } if(picture==""){ window.alert("Please enter student picture!"); document.s.picture.focus(); return false; } } </script> <body> <table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td align="center"><h1><font color="#0000FF" face="Arial">ADD STUDENT PROFILE</font></h1></td> </tr> </table> <br><br> <table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td align="right"><font size="1" face="Arial"><a href='main.php'>Student List</a></font></td> </tr> </table> <br><br> <form method="post" action="student_form.php" enctype="multipart/form-data" name='s' onsubmit='return validated()';> <table width="70%" border="0" align="center" cellpadding="2" cellspacing="2"> <tr> <td width="33%" align="right"><font size="2" face="Arial"><strong>Matric Number</strong></font></td> <td width="5%" align="center">:</td> <td width="62%"><input type='text' name='matric' size=30 maxlength=15></td> </tr> <tr> <td align="right"><font size="2" face="Arial"><strong>Name</strong></font></td> <td align="center">:</td> <td><input type='text' name='name' size=30 maxlength=50></td> </tr> <tr> <td align="right"><font size="2" face="Arial"><strong>Course</strong></font></td> <td align="center">:</td> <td><input type='text' name='course' size=30 maxlength=50></td> </tr> <tr> <td align="right"><font size="2" face="Arial"><strong>Semester</strong></font></td> <td align="center">:</td> <td><input type='text' name='sem' size=5 maxlength=2></td> </tr> <tr> <td align="right"><font size="2" face="Arial"><strong>Sex</strong></font></td> <td align="center">:</td> <td><input type='radio' name='sex' value='Male' checked> Male <input type='radio' name='sex' value='Female'> Female</td> </tr> <tr> <td align="right"><font size="2" face="Arial"><strong>Contact Number</strong></font></td> <td align="center">:</td> <td><input type='text' name='tel' size=30 maxlength=50></td> </tr> <tr> <td align="right"><font size="2" face="Arial"><strong>Address</strong></font></td> <td align="center">:</td> <td><input type='text' name='address' size=50 maxlength=100></td> </tr> <tr> <td align="right"><font size="2" face="Arial"><strong>Picture</strong></font></td> <td align="center">:</td> <td> <input type="hidden" name="MAX_FILE_SIZE" value="10485760"> <input type="file" name="picture" size="40"> <font size="1" face="Arial"> Maxsize 1MB</font> </td> </tr> <tr> <td> </td> <td> </td> <td><input type='submit' name="submit" value='Submit'> <input type='reset' value='Reset'></td> </tr> </table> <?php if ($submit) { include 'db_connect.php'; $data = addslashes(fread(fopen($picture, "r"), filesize($picture))); $pjpeg="image/pjpeg"; $jpeg="image/jpeg"; $gif="image/gif"; $png="image/png"; $bmp="image/bmp"; if ($picture_type == $pjpeg OR $picture_type == $jpeg OR $picture_type == $gif OR $picture_type == $png OR $picture_type == $bmp) { $sql="INSERT INTO info (matric, name, course, sem, sex, tel, address ,bin_data,filename,filesize,filetype) VALUES ('$matric', '$name', '$course', '$sem', '$sex', '$tel', '$address', '$data','$picture_name','$picture_size','$picture_type')"; $result=mysql_query($sql); header ("Location: main.php"); } else{ echo "<script language='JavaScript'>"; echo "window.alert('Error! You only can upload jpeg, gif, png, bmp file type.')"; echo "</script>"; } } ?> </form> </body> </html> Thanks, Code: [Select] $product_id=$_GET['product']; $sql500="SELECT * FROM $tbl_name3 WHERE product_id='$product_id'"; $result500=mysql_query($sql500); $num_rows500=mysql_num_rows($result500); while($row500=mysql_fetch_array($result500)){ extract($row500); $review_product_rating_total=$review_product_rating; //What do I do here? } $average_rating=$review_product_rating_total/$num_rows500; I need a way to take a column of product ratings (0-5 in 1/2 increments), add them together, and divide by the number of rows taken from the database. I know how to get the number of rows with mysql_num_rows. But how would I add together the data from database? Hey All, first off Merry X-Mas ok so I'm trying to insert something into the batabse in one of three areas' let me explain there are three fields in the users database bounceone, bouncetwo and bouncethree now what I want to do is when the user clicks add to bounce list insert a value into the databse in one of these three hole, if bounceone is empty put it there, if not check bouncetwo if it's empty put it there, if not check the final one and if it's empty put it there else echo sorry please either remove a bounce any ideas on how this can be done. Hi, how to make this form + php to make it work this way from the drop-down box choose the database title, or ID, and then the form in which I write some content will be added to the database that matches the title or ID that is sometimes so as not to invade a mistake and content that I type is not added to another title or ID I created something like this: <?php $db = new mysqli('localhost','xxxxx','xxxx','xxxx'); mysqli_query($db,'SET NAMES `utf8`'); $sqlnowe = mysqli_query($db,'SELECT * FROM `cc` ORDER BY `id` DESC '); ?> <form action="formu.php" method="post"> <select name="tytul"> <?php while ($rownowe = mysqli_fetch_array($sqlnowe)) { ?> <option><? echo $rownowe['tytul']; ?></option><?php };?> </select> opismax:<br /> <input type="text" name="opismax" /><br /> <textarea name="opismax" cols="50" rows="10">Proszę, wpisz tutaj jakiś komentarz...</textarea> <input type="submit" value="dodaj" /> </form> <?php // odbieramy dane z formularza $tytul = $_POST['tytul']; $opismax = $_POST['opismax']; if($tytul and $opismax) { // dodajemy rekord do bazy $ins = mysqli_query("INSERT tytul='$tytul' INTO publications SET opismax='$opismax'"); if($ins) echo "Good"; else echo "Bad"; } ?> I have a php page where I have posts about different topic. I have a menu listing all this categories of topics . Some topics may belong to more than one category. So when i click on a particular menu item, the topic belonging to that category will be displayed. While displaying it is in this format---Topic Heading,Belongs to which all categories,date posted and the description. All this are taken from database. Now my actual issue is I am not able to give links to the categories dispalyed ,if the category exceeds more than 1. For eg: Global Warming Posted on March 11,2011 in News, Issue -----------description of global warming goes here. In the above eg: News and issue are the two categories,when i click on News it should display all the items in news category,and when i click on issue it should display all items of issue category. But I am not able to give this link to the categories. Code: [Select] while($row = mysql_fetch_array($q)) { if($row[6]=='News'){ $c='<a href="category_disp.php?category=news">News</a>'; } if($row[6]=='Issues'){ $c='<a href="category_disp.php?category=issues">Issues</a>'; } echo "<tr><td><p >$row[1]</p><br></td></tr>"; echo "<tr><td> <div >". "<p><span>$row[4]</span> <span>". "<a href='$row[6]' >$row[6]|<a href='$row[5]'> Post Comments</a></span></p>". "<p> </p></div><br></td></tr>"; echo "<tr><td><p >$row[2]</p><br></td></tr>"; echo "<tr><td><p ><a href='$row[3]' >Click Here to read more...</a></p></td></tr>"; echo "</div></td></tr>"; } echo" </table> Hi there I've been working with some code to display a single record on page. This all works fine and I'm able to pull what I want from the database. My problems is trying to use that data and turning it into something else like a link. I have a field in the database called image url which contains rows of image urls. So here is the problem area of the code: Code: [Select] <?php //////Displaying Data///////////// $id=$_GET['id']; // Collecting data from query string if(!is_numeric($id)){ // Checking data it is a number or not echo "Data Error"; exit; } $fetch=mysql_query("select * from productfeeds where ProductID=$id "); $row=mysql_fetch_object($fetch); echo mysql_error(); echo "<table>"; echo " <tr><td><b>ProductID</b></td><td>$row->ProductID</td></tr> <tr><td><b>ProductName</b></td><td>$row->ProductName</td></tr> <tr><td><b>ProductPrice</b></td><td>$row->ProductPrice</td></tr> //problem area for me <tr><td><b>Image</b></td><td>$row->ImageURL</td></tr> echo "</table>"; I'm trying to edit this part of the code: <tr><td><b>Image</b></td><td>$row->ImageURL</td></tr> I've tried this: <tr><td><b>Image</b></td><td><a href='{$row['URL']}'> <img src='{$row['ImageURL']}'></a> and <tr><td><b>Image</b></td><td><a href='$row['URL']'> <img src='$row['ImageURL']'></a> //removed brackets but I'm just getting errors. Can you guys help please? Thank you very much. Good day guyz... I dont know why this code does not work... the connection is fine, the database is also fine it works with the localhost, when i upload it on free hosting site like 000webhost and infinityfree this is not working.. the database on free hosting site are also working also the connection is code, just only this code i cant figure it out.. else{ $sql = "INSERT INTO .$name (TrxID, ProductName, Price, ProductImage, PurchasedDate, PurchasedStatus) VALUES (?, ?, ?, ?, ?, ?)"; $stmt = mysqli_stmt_init($conn2); if(!mysqli_stmt_prepare($stmt, $sql)){ echo 'connection error'; } mysqli_stmt_bind_param($stmt, "isssss", $val, $PName, $Price, $PImage, $PDate, $PStatus); mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); header("location: ../customer/cart.html"); exit(); } }
Like many projects, this started small, and keeps growing! I am building a photo gallery and would now like to add labels/captions below each photo, HOWEVER, I really don't want to have to build a database and do all the related coding. (I know how, but its a PITA.) To display photos in the gallery, I read in files from my "images/" directory, store them in a simple array, and then iterate through the array to display the thumbnails in a gallery. I am wondering if there would be an easy way that I could merge photo metadata (e.g. a brief caption) with my array or something like that? If I could type up the file names and a brief description/caption in a Text File or Spreadsheet and then somehow slurp that into my code and merge it with my array or something like that, then I would be willing to type up captions. (This is for like 600 photos which is why I don't want to do a database as data entry in phpMyAdmin is a PITA!) Any suggestions how I could do this and add a "cherry on the top" of this mini project I am doing for my co-workers? Thanks!
Hi Im having some trouble implementing info into a database Hi all, I have a code which works just fine for adding one picture to my database but when I change the form to add mutliples i get an error because my code is set for multiple pictures as an array. Error says this is a string code. Does anyone know the code for array? Code: [Select] $target = "upload/"; $target = $target . basename( $_FILES['photo']['name']); Error message says Warning: basename() expects parameter 1 to be string, array given in /home/content/19/6550319/html/listingsss.php on line 7 Thanks, Philip Hello to all phpfreaks out there I need help with sorting some database columns. I ve been searching all day but i didnt found something nice to implement (or my mind is too tired to think right at this specific time) I have a table and inside it i display a picture and some other data.Above the table i inserted a div and inside it i have 5 links which when clicking on them i want to change the display order of the data being displayed in the table, and if clicked again to change again the state for ASC to DESC and so on... Is there any short solution that do the trick? With an array maybe? PS:I have also a pagination which i would like to keep the sorted order from the above table so not to mess around with the results. Thanks in advance I have a field gmap the data would be a variation of this, the gmap data to place the map on the site. The rest of the string is in my code because I want to size the iframe etc. Whean I use an input form to update this field using Null data and using a simple text line like yellow, the script works, when I try and add data as below I get a 403 error, how can I resolve this? https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3573.197380400117!2d28.465316315605516!3d-26.41710627907957!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x1e94d9c942963de9%3A0xc560ec1cd5d52b74!2sArrie%20Nel%20Nigel%20Pharmacy!5e0!3m2!1sen!2sza!4v1603786030983!5m2!1sen!2sza>
Code Hello and good day to all of you I have passed my midterms project(Online Shopping) with a score of 94 in PHP ( Click here to see file ) ( Sorry if the design is too ugly, I'm just new in programming XD ) Now our finals project will be a PHP site again but now with a database in it.. So instead of making a new project/design for a site, why not just add a database to my existing midterms? I would like to ask for some help here in helping me on connecting to the database, adding a database/tables and anything that would be of help like suggesting Databases would be like, - Users ( Admin and Members ) - Upper Clothing ( Shirts, Jackets, Long Sleeves, Raglan and etc ) - Lower Clothing ( Pants, Shorts, Boxers and etc ) - Stock on a current item - Single member's Transaction History - All user's Transaction History Is there a way that I could add those database named above to my project? Thank you in advance! |