PHP - Moved: Change Table Background Image On Click
This topic has been moved to JavaScript Help.
http://www.phpfreaks.com/forums/index.php?topic=347058.0 Similar TutorialsHi, I've making a script that's almost a todo list, and i want to have 3 colors to the posts. Post under 7 days old should be green, and thoose older then 7 days yellow and over 14 days should be red. How could i do that? Every post i timestamp when stored in my MYSQL table. Here is my code: Code: [Select] <?php $servername='localhost'; $dbusername='root'; $dbpassword=''; $dbname='store'; connecttodb($servername,$dbname,$dbusername,$dbpassword); function connecttodb($servername,$dbname,$dbuser,$dbpassword) { global $link; $link=mysql_connect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error()); } $result = mysql_query("SELECT * FROM henvendelser ORDER by id desc ") or die(mysql_error()); echo "<table cellspacing='12px' cellpaddomg='5px' align='center'>"; echo "<tr> <th>ID</th> <th> Opprettet </th> <th>Navn</th> <th>Telefon</th> <th>Emne</th> </tr>"; while($row = mysql_fetch_array( $result )) { echo "<tr> <td>"; echo $row['id']; echo "</td> <td>"; echo date("d.m.y", strtotime($row["date"])); echo "</td> <td>"; echo "<a href=\"detaljer.php?view=$row[id]\">$row[Navn]</a>"; echo "</td> <td>"; echo $row['Telefon']; echo "</td> <td>"; echo $row['Emne']; echo "</td> </tr>"; } echo "</table>"; ?> This creates an image 1500x1500 pixels. But it creates it in black... how can i make it white. And i have to use imagecreatetruecolor() not imagecreate(). <?php $im = imagecreatetruecolor(1500,1500); // Output the image to the browser header('Content-type: image/jpg'); imagejpeg($im); imagedestroy($im); ?> Thanks! This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=350544.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=319094.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=331191.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=349151.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=355565.0 Well here is the original code in my script file, and it has a background color Green now: [/php]$article_content = "<center><table style='color: #FFFF31; background: Green; width: 400px; border: 1px solid #9BDDFF;'><tr><td><i><b><u>Welcome to Mysidia City's fishing pool</b></u></i><br><br><br> Before you actually begin your fishing career, I'd strongly recommend you to doublecheck if you have a fishing rod already since it is apparently required for every fisherman here. <br><br><br><a href='fishing.php?act=1'>Enter</a> the fishing pool now if you have a fishing rod already or <br>Visit this <a href='fishingquiz.php'>Page</a> to take the fishing quiz and earn yourself an old rod to begin with. <td></tr></table><br><center><img src='picuploads/other/lakeofrage.png'></center>";[/php] Now I wish to replace the background color with a background image, what should I do? The image url is provided below: http://www.pokemansion.net/picuploads/other/seadrabg.png hello, would anyone could point me in the right direction. ?? i have 2 language buttons along the top on my web site. Code: [Select] <div class="flags"> <ul> <li><a href="#"><img src="templates/template1/images/flags/France.png" alt="France"/></a></li> <li><a href="#" class="current"><img src="templates/template1/images/flags/United Kingdom(Great Britain).png" alt="United kingdom" /></a></li> </ul> </div><!-- #flats --> how do i make it so that if i click on one it will change the sites language. ??? i have it all set up in the db so that there is a default language and if i change the default language the language changes but what code do i need to use to make my buttons changes the language? could anyone point me to some jscript or ajax or something please... many thanks rick Hello friends,
I am trying to achieve a simple thing, but I do not know jquery/javascript much. When I click on a forst list item in one div , I want to show corresponding 1st li in the second div. I have 6 list items in total and related 6 li in second div.
Also when I click on any list item in first div, it will be borderd, this I achieved. But I am not able to bring the related li in the second div.
Hope I make myself clear.
Here is my code
<style> .selected img { border:2px solid #090; } .visible { display:block; } .invisible { display:none; } </style> <div id="all"> <ul> <li class="selected"><img src="image1.JPG" /></li> <li><img src="image2.JPG" /><br /></li> <li><img src="image3.JPG" /><br /></li> </ul> </div> <div class="container"> <ul> <li class="visible"><img src="related_image1.JPG" /></li> (In these list items there may be img or content) <li class="invisible"><img src="related_image2.JPG" /></li> <li class="invisible"><img src="related_image3.JPG" /></li> </ul> </div> <script type="text/javascript"> $('#all ul li').on('click', function(){ $(this).addClass('selected').siblings().removeClass('selected'); $('.container ul li:nth-child(1)').fadeout(); // Don't know this line is correct or not }); </script>Any help guys ? Edited by Jaswinder, 19 July 2014 - 08:57 PM. Every other time a user/users click on a link I want the link to change to a different url the next time a user clicks onto that link.
For example two links
url1.html
url2.html
url1.html shows up when a user clicks that link the link auto changes to then when a new user clicks the linke url2.html then back to url1.html and so on?
Don't know where to start on how I would do this let alone have the server remember to keep which ever link to be held for the next user?
Hi, I have some files stored in mysql db. I have created a web page which shows the list of tutorials from db. at first i was creating a separate php page for each tutorial, but later i have decided that it would be easier and simpler if i can create one php page and whenever i click the tutorials it will change the content of this page. example: when i click "tut002" from list. it will change the content of tutorials.php . I have these tutorials in .html format here is the code i have in turorials.php once again, whenever i click a tutorial this include part needs to change automatically to whatever i click Code: [Select] echo '<div class="content">'; include ("inc/tut001.html"); echo '</div>'; it will be really appreciated if you have a sample code for this. sorry for my english. thank to whoever interested in this matter. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=320488.0 Hi all, I'm just wondering what the best solution to my current problem would be. Ive created a website where users can upload photos to a database, the photos are then shown in the admin section as a list. My DB structure is as such.. PHOTO SRC THEME 1.jpg images/1.jpg 1 2.jpg images/2.jpg 0 3.jpg images/3.jpg 0 4.jpg images/4.jpg 1 This is then reflected in the admin page, I need a button which will alter all photo's with the theme '1' and change them to '0', like a reconcile button, is this possible? How would you go about it? Thanks everyone hi, i am trying to generate image gallery. but the problem is that when i upload the png files its thumbnail is generated with black background. JPEG an GIF thumbnail are generated successfully. i want to make background transparent. is there any solution that how i can get rid of it. i am using imagecreatetruecolor($thumbwidth, $thumbheight ); to generate thumbnail I need a button in php to change my background color every 5 presses with a random one, every five presses the color have to change once and need to stay for the next 5 presses. here is my code <head>
<title>click 5 times</title> Hi, How can I get others informations on another page by clicking on one row's value I have this code, but it doesn't work: while($row = mysql_fetch_array($result)) { echo "<tr><p>"; echo "<th><p>" . $row['fname'] . " " . $row['lname'] . "</p></th>"; echo"<th><p><a href='student.php?id='".$row['topic']."'\'>".$row['topic']."</p></a></th>"; echo "</tr>"; } echo "</table>"; Student.php <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("college", $con); $result = mysql_query("SELECT * FROM students"); $topic = $_Get['topic']; while($row = mysql_fetch_array($result)) { echo "<tr><p>"; echo "<th><p>" . $row['month']." " .$row['datetime']."</p></th>"; echo"<th><p>". $row['topic'] ."</p></th>"; echo "<th><p>" . $row['gender'] . "</p></th>"; echo "<th><p>" . $row['fname'] . " " . $row['lname'] . "</p></th>"; echo "<th ><p>" . $row['id'] . "</p></th>"; echo "</tr>"; echo "</table>"; mysql_close($con); } ?> Hi, I have an image map mixed in with php, and it won't click when I click the mouse on it, it won't work. Any help greatly appreciated. Thanks. Derek here is the code where I use it. Code: [Select] if(isset($_GET['newLocation'])) { $_SESSION['current_location']=$_GET['newLocation']; } if(!isset($_SESSION['current_location']) && !isset($_SESSION['current_background']) && !isset($_SESSION['currentMonster'])) { $_SESSION['current_location'] = 0; $_SESSION['current_monster'] = 0; $_SESSION['current_background'] = 0; } if($_SESSION['current_location'] != 0) { if(!isset($_SESSION['current_background']) && !isset($_SESSION['current_monster'])) { $_SESSION['current_monster'] = 0; $_SESSION['current_background'] = 0; } if(isset($_GET['further'])) { //below is- inside the locations array, teardrop ocean (1) the background image is 4(example)+1 is set, then //do this if(isset($locations[$_SESSION['current_location']]['background_images'][$_SESSION['current_background']+1])) { $_SESSION['current_background']+=1; } if(isset($locations[$_SESSION['current_location']]['monster_images'][$_SESSION['current_monster']+1])) { $_SESSION['current_monster']+=1; } } elseif(isset($_GET['back'])) { if(isset($locations[$_SESSION['current_location']]['background_images'][$_SESSION['current_background']-1])) { $_SESSION['current_background']-=1; } if(isset($locations[$_SESSION['current_location']]['monster_images'][$_SESSION['current_monster']-1])) { $_SESSION['current_monster']-=1; } } // I dont have any $_SESSION['background'] var //$currentBackground=$_SESSION['background'][$_SESSION['current_background']]; $currentBackground = $locations[$_SESSION['current_location']]['background_images'][$_SESSION['current_background']]; //I dont have any $_SESSION['monster'] var //$currentMonster=$_SESSION['monster'][$_SESSION['current_monster']]; $currentMonster=$locations[$_SESSION['current_location']]['monster_images'][$_SESSION['current_monster']]; } else { //?newLocation=1 means set it to Teardrop ocean. $currentBackground = ' <img src="aradia.jpg" width="256" height="328" border="0" usemap="#Map" /> <map name="Map" id="Map"> <area shape="rect" coords="5,176,81,249" href="?newLocation=1"/> </map>'; $currentMonster = ''; } Hi, I have looked everywhere for a way to do this and would be grateful for a pointer in the right direction. I want to change the background color of the div with the id of "loggedin", depending on the status. The status currently echos text depending on the value. Code: [Select] <div class="grid_12" id="loggedin"> <div> <ul id="loggedin"> <li><?php global $current_user; get_currentuserinfo(); echo 'Status : ' . $current_user->status . "\n";?></li> <li> <?php if ($current_user->status=="RED") echo "Red info"; ?> <?php if ($current_user->status=="GREEN") echo "Green info"; ?> <?php if ($current_user->status=="BLUE") echo "Blue info"; ?> <?php if ($current_user->status=="YELLOW") echo "Yellow info"; ?> </li> </div> </div> Thanks I am trying to have an UPDATE query run when I click an image on a web page. I just need to have the image call the function to run the mysql from the corresponding php file. The image is a form object, which I need the php function to recognize when it is clicked, and then run the query(ies) within. I don't really know much php, so the php code is based on a snippet I have from one of my other sites, which works fine over there, but I am missing something here that is keeping it from doing the same here. The page already loads and displays all values in a list associated with $show_id, so that variable is already being pulled from the web page in to the php code. I'm not going to paste the entire books.php file here as there are too many things it does which doesnt have anything to do with this little add-on I am making. I just need to be able to pull that variable in to the query below and have it run when I click on the icon associated with it. The php file also already has the proper config and settings files linked to it that connect to the database, so I do not need to set that up here. It is just a form, calling a function, and running the query. It is also not visible to the user side. It is in an admin page, only visible and accessible to me. This is code I have in the php file: function UpdateAllShowBooks() { if(strlen(($_POST['retired'])) > 0){ $sql = "UPDATE ttb_books SET status_id = '2' WHERE show_id='$show_id'"; $db = new database(); $db->myquery($sql, 1); header('Location:books.php?show_id=$show_id'); die(); } if(strlen(($_POST['upcoming'])) > 0){ $sql = "UPDATE ttb_books SET status_id = '37' WHERE show_id='$show_id'"; $db = new database(); $db->myquery($sql, 1); header('Location:books.php?show_id=$show_id'); die(); } if(strlen(($_POST['current'])) > 0){ $sql = "UPDATE ttb_books SET status_id = '1' WHERE show_id='$show_id'"; $db = new database(); $db->myquery($sql, 1); header('Location:books.php?show_id=$show_id'); die(); } } This is the current image/form html: <center><table width=25%> <tr><td valign="top" align="center"> <!--<form method="post" action="books.php?show_id={show_id}">--> <form method="post" action="books.php" name="retired"> <input type="image" src="../images/icon-Red_Light.png" width="20" name="retired" alt="Set status to Out of Print" title="Set status to Out of Print" onclick="return confirm('Set ALL status to Out of Print?')"> <input name="shid1" type="hidden" id="shid1" value="{show_id}" /> </form> </td><td valign="top" align="center"> <form method="post" action="books.php" name="upcoming"> <input type="image" src="../images/icon-Yellow_Light.png" width="20" name="upcoming" alt="Set status to Upcoming Release" title="Set status to Upcoming Release" onclick="return confirm('Set ALL status to Upcoming Release?')"> <input name="shid2" type="hidden" id="shid2" value="{show_id}" /> </form> </td><td valign="top" align="center"> <form method="post" action="books.php" name="current"> <input type="image" src="../images/icon-Green_Light.png" width="20" name="current" alt="Set status to In Print" title="Set status to In Print" onclick="return confirm('Set ALL status to In Print?')"> <input name="shid3" type="hidden" id="shid3" value="{show_id}" /> </form> </td></tr> </table></center> So clicking on the form image would call the function with that mysql string and update all items in the list accordingly. At this time, when I click the image, it reloads the page fine, but it is not activating the sql in the function and making the Update occur. Thank you for any help you can provide. I really appreciate it. |