PHP - Clickable Image In Html Pass To Php?
Is it possible for a clickable image to pass to a php page? It can lead to a linked web page, so can it be like a submit button on a form and pass to the $_POST in php?
Similar TutorialsHello World, I need some tips on how to make a button that does something like the code below. .......echo '<tr><td align="left"><a href="add_cart.php?pid=' . $row1['item_id'] . '">Add to Cart</a></td>........ I've been messing with html form and button type with no success. This code does the job but I prefer a button. Thanks I have a page that contains a List box containing a list of categories taken from a mysql database, 4 iframe elements and 4 submit button (code to follow)
When an item is selected from the List box the onchange event submits the page to jobs.php and loads it into the joblist iframe. Once the iframe is loaded and visible it makes the "Add Job To Category" submit button visible. This all works great
When I click the "Add Job To Category" Submit button it loads Jobnew.php into the jobed iframe this is working but I can not seem to figure out how to pass the selected item from the List box using this submit button
I hope I am clear in my question if not please advise any help is very much appreciated....
Jobtask.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Job Configuration</title> <head> </head> <body> <div style="position:absolute;left:5px;top:0px;width:1345px;height:50px;z-index:0;"> <img src="images/img0001.png" id="Shape1" alt="" style="border-width:0;width:1345px;height:50px;"></div> <span style='position:fixed;left:525px;top:8px;font-family:Arial;font-size:32px;width:275px;'>Job Configuration</span> <form action='index.html' target='' method='post'> <div style="position:absolute;left:205px;top:55px;width:1345px;height:50px;z-index:0;"> <Input type="submit" action="index.html" Target="_top" method='post'Value="Main Menu"> </div> </form> <form style=position:fixed;left:200px;top:82px;> <iframe name='joblist' id='joblist' style=position:fixed;left:200px;top:px;visibility:hidden;z-index:10 src='' height="475" width="1150" scrolling='yes' frameBorder='0' ></iframe> <iframe name='job' id='job' style=absolute:fixed;left:200px;top:0px;visibility:hidden;z-index:0 src='' height="475" width="1150" scrolling='yes' frameBorder='0' ></iframe> <iframe name='jobed' id='jobed' style=position:fixed;left:460px;top:150px;visibility:hidden;z-index:10 src='' height="217" width="350" scrolling='no' frameBorder='0' ></iframe> <iframe name='newcat' id='newcat' style=position:fixed;left:460px;top:150px;visibility:hidden;z-index:10 src='' height="125" width="350" scrolling='no' frameBorder='0' ></iframe> </form> <?php error_reporting(E_ALL); include('dbcon/dbconnect.php'); $con=mysqli_connect($host,$user,$password,$db); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } if (isset($_POST['id'])) { $insql= "INSERT INTO catagory (Catagory) VALUES ('$_REQUEST[newcat]')"; $con->query($insql); } $Catresult = mysqli_query($con, "SELECT CatID, Catagory FROM catagory"); echo "<div id='wb_CatSel' style='position:absolute;z-index:0;text-align:center;'bgcolor='#00b0e6';>"; echo "<span style='position:fixed;left:10px;top:82px;font-family:Arial;font-size:15px;background-color:#00b0e6;width:175px;'>Select Category</span></div>"; echo "<form action='jobs.php' target='joblist' style='position:fixed;left:10px;top:101px;'></td>"; echo "<select name='cat' size='11' style='width: 175px;' onchange='this.form.submit()'>"; while($row = mysqli_fetch_array($Catresult)) { echo "<option value=\"".$row['CatID']."\">".$row['Catagory']."</option>\n "; } echo "</select>"; echo "</form>"; echo "<form action='Jobnew.php' target='jobed' method='post'>"; echo "<div style='position:absolute;left:10px;top:285px;width:1345px;height:50px;z-index:0;'>"; echo "<Input type='hidden' id='id1'><Input type='submit' id='sbtn' style='width:175px;visibility:hidden;' Value='Add Job To Category'></div></form>"; echo "<form action='Jobtask.php' target='' method='post'>"; echo "<div style='position:absolute;left:10px;top:310px;width:1345px;height:50px;z-index:0;'>"; echo "<Input type='submit' style='width:175px;' action='Jobtask.php' Target='_top' method='post' Value='Reset Form'></div></form>"; echo "<form action='newcat.php' target='newcat' method='post'>"; echo "<div style='position:absolute;left:10px;top:335px;width:1345px;height:50px;z-index:0;''>"; echo "<Input type='submit' style='width:175px;'' action='newcat.php' Target='newcat' method='post' Value='Add New Category'></div></form>"; ?> </body> </html> I have a browser game already running that revolves around breeding dogs. Right now we use static images, and I'd like markings and colors to be traits that are inheritable through generations. I am able to layer images based on the parents layers to create a new dog with new markings. However, this only works with precolored layers. Which means the markings and such are not really being inherited, there is no chance for uniqueness at all. What I would like to achieve is the ability to colors parts of a layer or whole image based on what the parents have colored. So lets say you are breeding two border collies, the sire has four white socks and the dam has no socks at all. It should produce puppies anywhere on that spectrum, some with half socks, some with just white feet, etc. I hope I'm explaining this correctly. In my head, I see this being possible by coloring only those certain parts of an image. So I only color the feet for example, in a somewhat random pattern based on the parents feet patterns. So this eliminates the need for precolored layers and presents the possibility of random mutations. Is this at all achieveable? Is there another way that I'm not thinking of? I have an intermediate working knowledge of php, I've coded most of the game myself, but then I hit something like this and get completely stuck. Help put me on the right track please? I work with a large codebase and I have this situation come up fairly often:
the legacy class has large objects such as:
$design->motor->dimensions->a; $design->motor->dimensions->bd; $design->specifications->weight; $design->data->height; //etcWhen I create a new class, that class sometimes operates on the specific data, so say: class MyClass { public function compute($weight, $height, $a) { //stuff } } //and I call this for example as such: (new MyClass())->compute($design->specifications->weight, $design->data->height, $design->motor->dimensions->a);CONS: Potential issue: if design specs change and I need to change things parameters in "compute" function, I need to "re-key" the variables I pass to the function, and adjust things accordinly in MyClass as wel. PROS: only the exact data is being passed, and this data can come from anywhere it is viable, so in effect the function is fairly well separated, I think. Alternative option for me is to pass the entire design object, i.e class MyClass { public function compute(&$design) //can also be done via DI through a setter or constructor. { print $design->specifications->weight; print ($design->data->height + $design->motor->dimensions->a); //stuff } } (new MyClass())->compute($design);PROS: In this case when things change internally in which variables are needed and how things are computed, I only need to change the code in compute function of the class itself. CONS: MyClass now needs to be aware of how $design object is constructed. When it comes to this parameter passing, and Dependency Injection like this in general, does Computer Science advocate a preference on this issue? Do I pass the entire object, or do I pass only the bits and pieces I need? I'm trying to get a simple table to display and am not sure how to make it happen. Table will have just 2 columns. A TIME and an EVENT. What I want to have happen is for the first row to show the TIME and next to that, the EVENT. If a TIME has more than one event going I want the next row to show an empty first cell and then the second event below the first. If I set up the loop the only way I know how (so far) it would also output the TIME value again and again as many times as there were events for that same time. For example what I don't want is: 9:15 Sunday School 9:15 Nursery Available What I do want is: 9:15 Sunday School Nursery Available Thanks. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=359179.0 I have a calendar with a month view. I can click on a date to add or edit an event. The current date is coloured red. I made sure that when I click on next to go to the next month the day is not coloured red. However when I am in a month, not being the current month I CANNOT click on the day of today. So if I would like to click on 21 July or 21 September this is not possible. I have tried everything but it doesn't change anything. Code: [Select] <?php $i = 0; while (list(, $week) = each($weeks)) { echo "<tr class='mainrow'>\n"; while (list(, $d) = each($week)){ if($i < $offset_count){ //$day_link = "<a href=\"".$_SERVER['PHP_SELF']."?date=".mktime(0, 0, 0, $month -1, $d, $year)."\">$d</a>"; echo "<td class=\"nonmonthdays\">$day_link</td>\n"; } if(($i >= $offset_count) && ($i < ($num_weeks * 7) - $outset)){ $datecount=mktime(0, 0, 0, $month -1, $d, $year); $short = ''; //$day_link = $d; $day_link = "<A href=\"javascript:popWin('editcalendar.php?ID=$datecount', 450, 570)\">$d</a>"; $query = "SELECT * FROM bl_calender WHERE viewable='1'"; $r = mysql_query ($query) or die ("Query error: ".mysql_error()); while($row=mysql_fetch_array($r)) {//Array or records stored in $row if($row['dateclass']==$datecount) { $short = $row['short']; $day_link = "<A href=\"javascript:popWin('editcalendar.php?ID=$datecount', 450, 570)\" title=\"$short\"><FONT style='BACKGROUND-COLOR: yellow'><b>$d </b></font></a>";} } $this_month = date('M'); if($date == mktime(0, 0, 0, $month, $d, $year)){ if($this_month == $month_name) { // only make date red if it is current month echo "<td><A href=\"javascript:popWin('editcalendar.php?ID=$datecount', 450, 570)\" title=\"$short\"><font color='red'><b>$d</b></font></a></td>\n"; } else {echo "<td><A href=\"javascript:popWin('editcalendar.php?ID=$datecount', 450, 570)\" title=\"$short\"><a style='color:#0066FF'>$d</a></td>\n"; } } else { echo "<td class=\"days\">$day_link</td>\n"; } } elseif(($outset > 0)) { if(($i >= ($num_weeks * 7) - $outset)){ $day_link = ""; echo "<td class=\"nonmonthdays\">$day_link</td>\n"; } } $i++; } echo "</tr>\n"; } // Close out your table and that's it! echo "<tr class='headline'><td colspan='7' class='days'> </td></tr>"; echo '</table>'; ?> ok i display description from database with no isue but the thing is if there are links in description even the links like http://somesite.com shows as normal text on browser. how can i make them clickable? This one im took from php Code: [Select] print "<form action='registration.php' method='post'onsubmit='return msg();'>"; print "Your message:<br>"; print "<textarea name='message' cols='40' rows='2'></textarea><br>"; print "<a onClick=\"addSmiley(':)')\"><img src='smile.gif'></a> "; print "<a onClick=\"addSmiley(':(')\"><img src='blush.gif'></a> "; print "<a onClick=\"addSmiley(';)')\"><img src='images/wink.gif'></a> "; print "<input type='submit' name='submit' value='Set Name'></form>"; print "<script language=\"Java Script\" type=\"text/javascript\">\n"; print "function addSmiley(a)\n"; print "{\n"; print "document.form.message.value += a;"; print "document.form.message.focus();\n"; print "}\n"; print "</script>\n"; print "<br><br>"; and i converted it to html Code: [Select] <html> <form action='registration.php' method='post'> Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <a onClick=\"addSmiley(':)')\"><img src='smile.gif'></a> <a onClick=\"addSmiley(':(')\"><img src='blush.gif'></a> <a onClick=\"addSmiley(';)')\"><img src='images/wink.gif'></a> <input type='submit' name='submit' value='Set Name'></form> <script type="text/javascript">+"\n" function addSmiley(a)+"\n" { "\n" document.form.message.value + = a document.form.message.focus()+"\n" } "\n" </script> "\n" <br> <br> </html> but that html problem is im cannot integrate the javascript im means canot click the smiley button la may i know what is wrong Hi guys, thanks in advance. What im trying to do is present clickable linked buttons depending on results of the if statements. I want to replace the standard href links into the buttons if possible? Here is some of the code. Code: [Select] <?php if ($DetectionPercent <= 30){ // beg echo '<li><a href="http://www.google.com"> View Personalised Detection Content</a>'; } elseif ($DetectionPercent > 30 && $DetectionPercent <= 60){ //int echo '<li><a href="http://www.youtube.com"> View Personalised Detection Content</a>'; } else //exp { echo '<li><a href="http://www.facebook.com">View Personalised Detection Content</a>'; } ?><HR> Been looking into it a while and just can seem to find anyway to do this. Thanks Lance I want to display 3 clickable images in a single row which repeats as long as there is data in the database, so far it is displaying a single clickable image from the database. below is all the code.. <table width="362" border="0"> <?php $sql=mysql_query("select * from `publication` GROUP BY `catsue`") or die(mysql_error()); $num=mysql_num_rows($sql); while($rowfor=mysql_fetch_array($sql)) { $cat=$rowfor['catsue']; $pic=mysql_query("select * from `category` where `catsue`='$cat'") or die(mysql_error()); $picP=mysql_fetch_array($pic); $base=basename($picP['title']); ?> <tr> <td width="352" height="88"><table width="408" border="0"> <tr> <td width="113" rowspan="5"><a href="archive_detail.php?id=<?php echo $rowfor['id'];?>&category=<?php echo $rowfor['catsue'];?>"><img src="ad/pic/<?php echo $base;?>" width="100" height="100" border="0"/></a></td> <td width="94">Title</td> <td width="179" height="1"><?php echo $rowfor['catsue'];?> </td> </tr> <tr> <td> </td> <td width="179" height="3"> </td> </tr> <tr> <td> </td> <td width="179" height="8"> </td> </tr> <tr> <td> </td> <td width="179" height="17"> </td> </tr> <tr> <td> </td> <td width="179" height="36"> </td> </tr> </table></td> </tr> <?php }?> </table> images are uploaded to a directory and the sql database contains the filename. I added 'url' field and am trying to link the two I have used on of the posts to help me adapt some script however I'm not sure I have the syntax right. The image in DW live view looks ok and I get the link finger ok but when previewed in browser the image is not shown at all or any link. Any ideas <? echo !empty($row['pic']) ? "<a href=\"{$row['url']}\" <img src=\"js/images/{$row['pic']}\">" : ''; ?> it echos out to a table Mike I'm trying to make my text and images into clickable links. The images and text are in a database so its getting really tricky for me since I'm new to PHP. I've tried many different ways without success. Here is a snippet of the code I'm working with. As you can see, I'm also working with an image re-sizer. I would really like to make those images and text clickable links(i.e. Title). Any help is appreciated! if ($res) { while ($newArray = mysqli_fetch_array($res, MYSQLI_ASSOC)) { $detail = $newArray['id']; $photo = $newArray['photo']; $id = $newArray['title']; $price = $newArray['price']; list($width) = getimagesize($photo); // set the maximum width of the image here $maxWidth = 100; if ($width > $maxWidth) echo "<p><img alt=\"Image\" width=\"$maxWidth\" src=\"$photo\" />"; echo "Title:".$id." Price:".$price."<br/"; This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=320820.0 Hi, I have a blog page I am working on and I am trying to make some enhancements that I need some help with. In MySQL I have a table with id, title and post. In my page display I want to enable the user to click on the title and display a post on it's own so the URL would look like www.mysite.com/blog/?id=1 or something like that. Here is the PHP function to display the post from MySQL. all on one page. function GetBlogPosts($inId=null, $inTagId =null) { if (!empty($inId)) { $query = mysql_query("SELECT * FROM blog_posts WHERE id = " . $inId . " ORDER BY id DESC LIMIT 2"); } else if (!empty($inTagId)) { $query = mysql_query("SELECT blog_posts.* FROM blog_post_tags LEFT JOIN (blog_posts) ON (blog_post_tags.postID = blog_posts.id) WHERE blog_post_tags.tagID =" . $tagID . " ORDER BY blog_posts.id DESC"); } else { $query = mysql_query("SELECT * FROM blog_posts ORDER BY id DESC"); } $postArray = array(); while ($row = mysql_fetch_assoc($query)) { $myPost = new BlogPost($row["id"], $row['title'], $row['post'], $row['postfull'], $row["author_id"], $row['date_posted']); array_push($postArray, $myPost); } return $postArray; }
Hi,
<?php $connect = mysqli_connect('localhost', 'root', '1234', 'contact'); $query ='SELECT * FROM tbl_employee ORDER BY ID DESC'; $result = mysqli_query($connect, $query); ?>
<table id="employee_data" class="table table-striped table-bordered"> <thead> <tr> <td>Name</td> <td>Location</td> <td>Department</td> <td>Phone Number</td> </tr> </thead> <?php while($row = mysqli_fetch_array($result)) { echo ' <tr> <td>'.$row["name"].'</td> <td>'.$row["location"].'</td> <td>'.$row["department"].'</td> <td>'.$row['phone_number'].'</td> </tr> '; } ?> </table>
I'm not sure if this is the right section, if not, please move it on proper one, i'm still newbie. However, here's my problem, i'm using jquery to replace standard check boxes with images, and here's the code: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { /* see if anything is previously checked and reflect that in the view*/ $(".checklist input:checked").parent().addClass("selected"); /* handle the user selections */ $(".checklist .checkbox-select").click( function(event) { event.preventDefault(); $(this).parent().addClass("selected"); $(this).parent().find(":checkbox").attr("checked","checked"); } ); $(".checklist .checkbox-deselect").click( function(event) { event.preventDefault(); $(this).parent().removeClass("selected"); $(this).parent().find(":checkbox").removeAttr("checked"); } ); }); </script> Here's the css: <style type="text/css"> body { font: 12px/1.3 "Lucida Grande","Lucida","Arial",Sans-serif; } form { margin: 0 0 30px 0; } legend { font-size: 17px; } fieldset { border: 1; } .checklist { list-style: none; margin: 0; padding: 0; } .checklist li { float: left; margin-right: 10px; background: url(i/checkboxbg.gif) no-repeat 0 0; width: 105px; height: 80px; position: relative; font: normal 11px/1.3 "Lucida Grande","Lucida","Arial",Sans-serif; } .checklist li.selected { background-position: -105px 0; } .checklist li.selected .checkbox-select { display: none; } .checkbox-select { display: block; float: left; position: absolute; top: 55px; left: 10px; width: 85px; height: 23px; background: url(i/select.gif) no-repeat 0 0; text-indent: -9999px; } .checklist li input { display: none; } a.checkbox-deselect { display: none; color: white; font-weight: bold; text-decoration: none; position: absolute; top: 55px; right: 10px; } .checklist li.selected a.checkbox-deselect { display: block; } .checklist li label { display: block; text-align: center; padding: 8px; } .sendit { display: block; float: left; top: 118px; left: 10px; width: 115px; height: 34px; border: 0; cursor: pointer; background: url(i/sendit.gif) no-repeat 0 0; text-indent: -9999px; margin: 20px 0; } </style> And finally the form thing <ul class="checklist"><li><input name="jqdemo" value="value5" type="checkbox" id="choice_c"/><label for="choice_c">Some Text Here to be checked - clicked</label><a class="checkbox-select" href="#">Click</a><a class="checkbox-deselect" href="#">Cancel</a></li></ul> I would like that my text on top of checkboxes become clickable. Hi,
I have the following script which displays a banner image based on a cookie. It also displays a banner if there is no cookie. What I would like to do is to display the banners based on cookies, but instead of displaying the "no-cookie.gif" image, I want to insert some HTML content.
What would be the best way to do this?
$( document ).ready(function() {Thanks! |