PHP - Turning Each Array Value Into A Link
Hey i'm having trouble figuring out how to do this.
This is the code grabbing the users who are online and listing them one by one. Code: [Select] $qt=mysql_query("SELECT username FROM users WHERE lastvisit > '$tm' and online='ON'"); echo mysql_error(); while($nt=mysql_fetch_array($qt)){ echo "<tr><td> $nt[username] </td></tr>"; } ?> what i want to do is have each username be a hyperlink that links to their profile how would i go about this? cause i'm completely clueless on this. is there some way i can do it in the php or will i need to make a varchar column for each player that holds their profile link and grab that with the query too? Similar TutorialsI am trying to turn a .txt file into an array, count the items in the array, and display a random quote from it.
<p class = "center"> <?php $Proverb = file('../proverbs.txt'); $ProverbCount = count($Proverb); echo rand(0, $ProverbCount-1); ?> <br> © 2014 </p>The issue I am having is that it states the file does not exist: FULL PATH: G:\EasyPHP-5.3.2i\www\PHP_Projects\ChineseZodiacs\Includes\inc_footer.php TEXT FILE: G:\EasyPHP-5.3.2i\www\PHP_Projects\ChineseZodiacs\proverbs.txt Please help, thank you. having a problem turning this sql into a query and I need it to only update rows where id field is empty. Code: [Select] UPDATE systems SET naqahdah = naqahdah + naqahdah_mines * 2 I tried this out with failure Code: [Select] <?php mysql_query("UPDATE systems SET naqahdah= naqahdah + naqahdah_mines * 2 WHERE id <> ' ' "); ?> so i tried getting rid of WHERE and couldnt even get this to work. I tested the sql out it works fine. Code: [Select] <?php mysql_query("UPDATE systems SET naqahdah= naqahdah + naqahdah_mines * 2 "); ?> Hi, I'm pretty new to PHP, struggled my way through most of my encounters with PHP so far, but getting the hang of it I'm looking for a simple script that turns a number or word served by a weather station into a graphic. E.g. If the temp is 20 degrees, a graphic I've designed would be shown, or a cloud or the sun or whatever. At the moment the weather station feed is converted from 'webtags' in to php tags (temp is $temp, wind is $wind etc.) and these echo out as numbers and words on the website. I can sort of see how it would work in my head, but need a little help. Can anyone please point me in the right direction? Thanks (for reference site is www.southtyneweather.co.uk) I got a tab menu, where the user choose his category and a list of sub categories appear. Personally I like the old fashion way, where everything listed like in craiglist.com ... How can I turn the following tab menu, into a simple 3 column list? <!--CATEGORIES--> <div id="selCategories"> <div class="slidetabsmenu menu_fix"> <ul> <?php if(isset($groups) and $groups->num_rows()>0) { $i=0; foreach($groups->result() as $group) { ?> <li id="gr<?php echo $i;?>" class="<?php if($i == '0') echo "selected"; ?>"><a href="javascript:;" onclick="getCat('<?php echo $i ?>','<?php echo $groups->num_rows ?>',<?php echo $group->id;?>);"><span><?php echo $group->group_name;?></span></a></li> <?php $i++;} } ?> </ul> </div> <div class="clsInfoBox"> <div class="block"> <div class="grey_t"> <div class="grey_r"> <div class="grey_b"> <div class="grey_l"> <div class="grey_tl"> <div class="grey_tr"> <div class="grey_bl"> <div class="grey_br"> <div class="cls100_p"> <h4><span class="clsCategory"><?php echo $this->lang->line('CATEGORIES');?></span></h4> <div class="clsCategoryList clearfix" id="catInner"> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <!--END OF CATEGORIES--> Your tips, directions, and support is highly appreciated. right now i have my date system to say "X amount of seconds ago, X hours ago, X days ago, X years ago, How could i turn mktime() (1290874161) into a mm/dd/yyyy format? so it would say like, "Nov 27, 2010 at Hour:Minute" (whatever the hour/minute is) I recently had a need to check several arrays, and if an index wasn't set, set a variable to a given value. The code was such that I couldn't perform the isset check all at once. I then thought "wouldn't it be great if I could try the script, and catch the error or warning". Searching a bit, I came across the following script. I am a little nervous, however, that there might be negative consequences of doing so. Thoughts?
set_error_handler(function($errno, $errstr, $errfile, $errline, array $errcontext) { // error was suppressed with the @-operator if (0 === error_reporting()) { return false; } throw new ErrorException($errstr, 0, $errno, $errfile, $errline); }); try { dns_get_record(); } catch (ErrorException $e) { // ... } I have got a date field in my mysql database with events, and as you know date in MYSQL uses yyyy/mm/dd but I would first like to turn this around to dd/mm/yyyy but also turn this into for example "Tuesday - May 1990" would anyone like to point me into the right direction? Much appreciated! Hi guys, I have written a page that contains a form. When the user chooses a color, it is posted, then the posted value is re-written as a filename, sent through a function, and the image on the page uses the "colorized.gif" created by the function to make an image swap "onclick. Problem is, no matter the choice, it always changes the picture to orange! Here is the code for the form: <?php include('function.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PHP GD CONFIGURATOR</title> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Red<input type="radio" name="color" value="red" /> Orange<input type="radio" name="color" value="orange" /> Ivory<input type="radio" name="color" value="ivory" /> Black<input type="radio" name="color" value="black" /> <input type="submit" name="submit" value="submit" /> </form> <?php if($_POST['color'] != NULL){ echo $_POST['color']; $file =('gdimages/' . $_POST['color'] . '.gif'); createImg($file); } ?> <img src="default.jpg" name="lola" alt="lola dining chair" onclick="this.src = 'colorized.gif'" /> </body> </html> And here is the function... function createImg ($imgname1) { $base = imagecreatefromgif("gdimages/base.gif"); $top = imagecreatefromgif($imgname1); if ($top) { imagecopy($base, $top, 0, 0, 0, 0, 250, 250); imagejpeg($base, 'colorized.gif'); imagedestroy($base); } else{ header("Content-Type: text/html"); } } I really can't understand it...this is my first attempt at programming something new by myself...and I really need it to work!!! I also plan for this to work with combining more than 2 images from more than two choice menus...so debugging now is definitely necessary. Any suggestions? i run several wordpress on domains - and wthin the wordpress i have a plugin that allows uploads of images -within a certain plugin the interesting thing: image upload is - sometimes possible and sometinmes impossible: see here the circumstances - PHP Version : 5.3.28 PHP Safe Mode : On image upload is impossible - and on the same server - a second vhost PHP Version : 5.3.28 PHP Safe Mode : off image upload is possible why is this so - does it have to do with the safe-mode - Greetings all. I am building a website which will have a popup box. When a link is clicked on, the proper data will show in the box. I just need to know how I can detect which link was clicked. e.g. <a href="#">link one</a> <a href="#">link two</a> $a[1]="item1 | item2 | item3" $a[2]="item4 | item5 | item6" list($one, $two, $three)=explode("|",$a ) Where x is dependent on the link clicked. All the sites I have seen so far speak of basic array structures and how to set them up. If it makes any difference, the links are inside an unordered list setup. Thanks for any help. Hello all, I am working on a webpage which needs to be finished Friday so I am a bit stressing out, hence this post. I have made the following script: // Uitkomst van POST waardes echo"<pre>"; print_r($_POST); echo"</pre>"; // LET OP: De tabel "test_optie" is niet compleet gevuld en daarom werkt het script alleen als je start bij categorie 1. // Het is dus GEEN fout in de script, alleen de database is niet helemaal gevuld kostte me teveel tijd! echo" <html> <head> <style> select {float:left;width:250px;margin:0 5px 0 0;} </style> </head> <body> <form name='form' action='chainselect.php' method='post' /> <select name='veld1' onChange='document.form.submit()'> "; // Data opvragen $sql_categorie = mysql_query("SELECT * FROM plaatsnaam ORDER BY id") or die (mysql_error()); // Counter $a = 0; // Standaard geselecteerd echo"<option value='0' selected>Selecteer een plaats</option>"; while($row_categorie = mysql_fetch_array($sql_categorie)){ $a++; echo"<option value='$row_categorie[id]' ";if($_POST[veld1] == "$a"){echo"selected";}echo">$row_categorie[naam]</option>"; } echo" </select> <select name='veld2' onChange='document.form.submit()'> "; // Data opvragen $sql_rubriek = mysql_query("SELECT * FROM branche WHERE catid = '$_POST[veld1]'") or die (mysql_error()); $ant_rubriek = mysql_num_rows($sql_rubriek); // Huidige id veld2 om zodoende huidig veld te selecteren indien gewijzigd if(isset($_POST[veld2])){ $b = "$_POST[veld2]"; } // Als er geen data gevonden is dan de onderstaande option laten tonen. if($ant_rubriek <= 0){ echo"<option value='0'>-</option>"; } else{ // Standaard geselecteerd echo"<option value='0' selected>Selecteer een branche</option>"; while($row_rubriek = mysql_fetch_array($sql_rubriek)){ echo"<option value='$row_rubriek[id]' ";if($_POST[veld2] == "$row_rubriek[id]"){echo"selected";}echo">$row_rubriek[naam]</option>"; } } echo" </select> <select name='veld3' onChange='document.form.submit()'> "; // Data opvragen $sql_optie = mysql_query("SELECT * FROM filiaal WHERE catid = '$_POST[veld1]' AND rubid = '$_POST[veld2]'") or die (mysql_error()); $ant_optie = mysql_num_rows($sql_optie); // Huidige id veld3 om zodoende huidig veld te selecteren indien gewijzigd if(isset($_POST[veld3])){ $c = "$_POST[veld3]"; } // Als er geen data gevonden is dan de onderstaande option laten tonen. if($ant_optie <= 0){ echo"<option value='0'>-</option>"; } else{ // Standaard geselecteerd echo"<option value='0' selected>Selecteer een filiaal</option>"; while($row_optie = mysql_fetch_array($sql_optie)){ echo"<option value='$row_optie[id]' ";if($_POST[veld3] == "$row_optie[id]"){echo"selected";}echo">$row_optie[naam]</option>"; } } echo" </select> </form> </body> </html> "; ?> What I need now is the results shown linked to a page. U can see the dropdowns in action he www.inventar.nl/chainselect.php For example: In the first dropdown I select Groningen, in the 2nd drop I select Groningen, Restaurant and in the 3rd Groningen, Restaurant, Ni Hao Wok. This gives me the following: Quote Array ( [veld1] => 1 [veld2] => 2 [veld3] => 3 ) Now I have a page named nihao.php, this page needs to be linked to this array result. So if I do the above dropdowns it needs to open nihao.php Can anyone help me with this problem? I am really confused! Thanks in advance! Wheelie I know I'm doing it something right, but can someone tell me why only one table is showing up? Can you help me fix the issue? Heres my code: function showcoords() { echo"J3st3r's CoordVision"; $result=dbquery("SELECT alliance, region, coordx, coordy FROM ".DB_COORDFUSION.""); dbarray($result); $fields_num = mysql_num_fields($result); echo "<table border='1'>"; // printing table headers echo "<td>Alliance</td>"; echo "<td>Region</td>"; echo "<td>Coord</td>"; // printing table rows while($row = mysql_fetch_array($result)) { // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row AS $Cell) echo "<tr>"; echo "<td>".$row['alliance']."</td>\n"; echo "<td>".$row['region']."</td>\n"; echo "<td>".$row['coordx'].",".$row['coordy']."</td>\n"; echo "</tr>\n"; } echo "</table>"; mysql_free_result($result); } I have 2 rows inserted into my coords table. Just frustrated and ignorant to php. Hello.
I have a bit of a problem. When I fetch the link field from the database.i don't see an actual link on the page.
One more thing, what type of field should I use to store the link in the database? Probably there is where I went wrong.
All help is
Hi I've got this database I created with fields ProductId ProductName Image I've managed to get it to list the ID,productname, and Image urls in a list. My next step is to have the image field actually display an image and make it clickable: heres what I've done so far: Code: [Select] <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("productfeed", $con); $result = mysql_query("SELECT * FROM productfeeds"); echo "<table border='0'> <tr> <th>Firstname</th> <th>Lastname</th> <th>Image</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ProductID'] . "</td>"; echo "<td>" . $row['ProductName'] . "</td>"; echo "<td>" . $row['ImageURL'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Heres what I want to do: Code: [Select] while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ProductID'] . "</td>"; echo "<td>" . $row['ProductName'] . "</td>"; // my changes beneath echo "<td>" . <a href="<?php echo $row['ImageURL'];?>"> <img src="<?php echo $row['LinkURL']; ?>"> </a>. "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Can you guys point me in the right direction? Many thanks Hi Support, I have a form, where it collects user description input. I can collect the inputs and store it with newline. The issue is - how to collect the http link to actual hyperlink ref during display. The following is my code: <textarea name="description" cols="50" rows="10" id="description"><?php echo str_replace("<br>", "\n", $description);?></textarea></td> For example, User input: Hi, Check it out - http://www.google.com/ I would like to display google link as href so that Viewers can click the link and go to the page. Right now, it is not href and user need to copy the link to new tabs or pages and then it can come. Thanks for your help. Regards, Ahsan here's my code that i've used to send an email. Code: [Select] $link = "<a href=\"http://www.example.com/" . $num . "\">" . $num . "</a>"; $query = "SELECT content FROM emails"; $result = mysql_query($query) or die(); $email_content = mysql_result($result, 0); $email = sprintf($email_content, $first, $name, $from, $link, $record, $rec, $inc, $max); $email_body = stripslashes(htmlentities($email, ENT_QUOTES, 'UTF-8')); // this is sent to another php script via post.... $subject = $_POST['subject']; $message = nl2br(html_entity_decode($_POST['email_body'])); $to = "me@whatever.com"; $charset='UTF-8'; $encoded_subject="=?$charset?B?" . base64_encode($subject) . "?=\n"; $headers="From: " . $userEmail . "\n" . "Content-Type: text/html; charset=$charset; format=flowed\n" . "MIME-Version: 1.0\n" . "Content-Transfer-Encoding: 8bit\n" . "X-Mailer: PHP\n"; mail($to,$encoded_subject,$message,$headers); in the db, emails.content is of the text type and contains several lines of text with %4$s which inserts the value of $link into the body. when the email arrives, there is a link and it appears fine, with the value of $num hyperlinked. however when you click on it it doesn't go anywhere. when copying the link location from the email it gives me x-msg://87/%22http://www.example.com/16 what is x-msg? how can i get this to work properly? hi hope you all are fine. i have been working on a Email Form (like user fills up the form which send the information to our email) but i was having problem with (URL field i created) link of form is (http://services.shadowaura.com/allquotations/static.php) field which is not working is "Inspirational Website:" when i submit the form it says (Forbidden You don't have permission to access /allquotations/staticworking.php on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.) Can some one help me out ????????????? code behind this form is: Code: [Select] <?php /* Email Variables */ $emailSubject = 'Shadow Aura Contact Info!'; $webMaster = '*****@shadowaura.com'; /* Data Variables */ $Name = $_POST['Name']; $email = $_POST['email']; $Cell = $_POST['Cell']; $Phone = $_POST['Phone']; $CompanyName = $_POST['CompanyName']; $TypeOfBusiness = $_POST['TypeOfBusiness']; $Address = $_POST['Address']; $YourBudget = $_POST['YourBudget']; $HaveDomain = $_POST['HaveDomain']; $RunningWeb = $_POST['RunningWeb']; $WebLink = $_POST['WebLink']; $Inspiration1 = $_POST['Inspiration1']; $Inspiration2 = $_POST['Inspiration2']; $NumberPages = $_POST['NumberPages']; $UseFlash = $_POST['UseFlash']; $TimeFrame = $_POST['TimeFrame']; $Provided = $_POST['Provided']; $Comments = $_POST['Comments']; $body = <<<EOD <h1> Static Website Quotation </h1> <br> <b>Name of Client:</b>$Name<br> <b>Your Email:</b>$email<br> <b>Cell Number:</b>$Cell<br> <b>Line Phone Number:</b>$Phone<br> <b>Company Name:</b>$CompanyName<br> <b>Type of Business:</b>$TypeOfBusiness<br> <b>Address:</b>$Address<br> <b>Your Budget:</b>$YourBudget <br> <b>Do you have Domain:</b>$HaveDomain<br> <b>Your Site is Running:</b>$RunningWeb <br> <b>Website Link:</b><a href="$WebLink">$WebLink</a><br> <b>Inspiration:</b>$Inspiration1<br> <b>2nd Inspiration:</b>$Inspiration2<br> <b>Number of Pages:</b>$NumberPages<br> <b>Use Flash:</b>$UseFlash <br> <b>Time Frame:</b>$TimeFrame<br> <b>You will provide:</b>$Provided<br> <b>Comments:</b>$Comments<br> EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD <html> <head> <title>sent message</title> <meta http-equiv="refresh" content="3;URL=http://services.shadowaura.com/"> <style type="text/css"> <!-- body { background-color: #8CC640; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 20px; font-style: normal; line-height: normal; font-weight: normal; color: #fec001; text-decoration: none; padding-top: 200px; margin-left: 150px; width: 800px; } --> </style> </head> <div align="center">Your email will be answered soon as possible! You will return to <b>Shadow Aura Services</b> in a few seconds !</div> </div> </body> </html> EOD; echo "$theResults"; ?> I have a line like this it prints text link but I prefer image link how should i edit it I would appreciate some feedback Code: [Select] $templates['etiket'] = array('name' => t('ETİKET'), 'module' => 'uc_invoice_pdf', 'path' => $templates_uc_invoice_pdf_path, 'pdf_settings' => $pdf_settings); |