Psycho
Moderators-
Posts
12,157 -
Joined
-
Last visited
-
Days Won
129
Everything posted by Psycho
-
rsort will return true if it works or false if it does not. So... <?php echo "<body bgcolor=\"black\" text=\"white\" link=\"red\" vlink=\"red\">"; ?> <?php function dateConvert($date) { $eDat = explode("-",$date); $year = $eDat[0]; $nMon = $eDat[1]; $day = $eDat[2]; switch ($nMon) { case 1: $mont = "January"; break; case 2: $mont = "February"; break; case 3: $mont = "March"; break; case 4: $mont = "April"; break; case 5: $mont = "May"; break; case 6: $mont = "June"; break; case 7: $mont = "July"; break; case 8: $mont = "August"; break; case 9: $mont = "September"; break; case 10: $mont = "October"; break; case 11: $mont = "November"; break; case 12: $mont = "December"; break; } $out = $mont . " " . $day . ", " . $year; return $out; } ?> <?php // Connects to your Database $link = mysql_connect("?", "?", "?") or die(mysql_error()); mysql_select_db("?",$link) or die(mysql_error()); if (isset($_GET['id'])) { // First, we need to get the champs, so do some mysql stuffs. $qry0 = "SELECT * FROM `titlechamps` WHERE `title` = '".addslashes($_GET['id'])."';"; $res0 = mysql_query($qry0) or die('Qry zero error!'); if(!mysql_num_rows($res0)) echo "No champions have been crowned yet!"; else { while($list0 = mysql_fetch_assoc($res0)) { // We have at least one champ. // First, we have to do a little math. We need to determine // how many days have elapsed between the date won and today. $today = explode("-",date("Y-m-d", time())); $yesterday = explode("-",$list0['date']); $hi = gregoriantojd($today[1],$today[2],$today[0]); $lo = gregoriantojd($yesterday[1],$yesterday[2],$yesterday[0]); $days = round($hi - $lo); // We will add the days and name to an array for the header. $longestR[] = $days . " - " . $list0['name']; // We also add the most successful defences to another array. $sucessfulD[] = $list0['defenses'] . " - " . $list0['name']; if($list0['news'] != null) $body .= "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tbody><tr><td colspan=\"2\" bgcolor=\"#e0e0e0\" valign=\"top\" width=\"100%\"><i>".$list0['news']."</i></td></tr></tbody></table>\n"; $body .= "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tbody>\n". "<tr>\n". "<td width=\"115\" valign=\"top\" align=\"center\"><img src=\"".$list0['pic']."\" /></td>". "<td>". "<table width=\"100%\" cellspacing=\"1\" cellpadding=\"2\" border=\"0\"><tbody><tr>". "<td width=\"25\" bgcolor=\"#e0e0e0\" align=\"center\"><b>".$list0['num']."</b></td>". "<td bgcolor=\"#e0e0e0\"><font color=\"#ff0000\">".$list0['name']."</font></td>". "</tr></tbody></table>". "<table width=\"100%\" cellspacing=\"1\" cellpadding=\"2\" border=\"0\"><tbody>". "<tr><td align=\"center\" bgcolor=\"#e0e0e0\" width=\"50%\"><b>Successful Defenses</b></td><td align=\"center\" bgcolor=\"#e0e0e0\"><b>Event</b></td></tr>". "<tr><td align=\"center\">".$list0['defenses']."</td><td align=\"center\">".$list0['event']."</td></tr>". "<tr><td align=\"center\" bgcolor=\"#e0e0e0\"><b>Reign</b></td><td align=\"center\" bgcolor=\"#e0e0e0\"><b>Date Won</b></td></tr>". "<tr><td align=\"center\">$days</td><td align=\"center\">".dateConvert($list0['date'])."</td></tr>". "<tr><td colspan=\"2\"><i>".$list0['blurb']."</i></td></tr>". "</tbody></table>". "</td></tr>". "</tbody></table>\n"; } } // Now, determine the longest reign and most defenses ##### START CHANGES ##### $longestReign = (rsort($longestR))?$longestR[0]:'No champion has been crowned'; $successDefense = (rsort($sucessfulD))?$sucessfulD[0]:'No champion has been crowned'; ##### END CHANGES ##### //next, we need to assemble the header of the page. $query = "SELECT *, DATE_FORMAT(`datecreated`, '%M %e, %Y') AS datecreated FROM titlehistory WHERE id='".addslashes($_GET['id'])."';"; if ($r = mysql_query ($query)){ // Run the query. while ($row = mysql_fetch_array ($r)){ $head .= '<table border=0 cellspacing="0" cellpadding=3 width=575>'; $head .='<tr><td background="images/bg_bar4.gif" height=35> <font color="white">Title Histories</font></td></tr>'; $head .='<tr><td></td></tr>'; $head .='</table>'; $head .='<table border=0 cellspacing="0" cellpadding=3 width=575>'; $head .='<tr><td background="images/bg_bar3.gif" height=35 colspan=2> <font color=black>KOW '.$row['titlename'].'</font></td></tr>'; $head .='<tr><td width=200><img src="/images/' . $row['titleimage'] . '" width=208px height=156px border=0 alt="View KOW '.$row['titlename'].' History"></td><td valign=top>'; $head .='<table cellpadding="2" cellspacing="0" border="0" width=100%>'; $head .='<tr><td align=center bgcolor=#E0E0E0><b><font color="#000000">Date Created</font></b></td></tr><tr><td align=center>'.$row['datecreated'].'</td></tr>'; $head .='<tr><td bgcolor=#E0E0E0 align=center><b><font color="#000000">Status</font></b></td></tr>'; $head .='<tr><td align=center>'.$row['status'].'</td></tr>'; $head .='<tr><td bgcolor=#E0E0E0 align=center><b><font color="#000000">Longest Reign</font></b></td></tr>'; ##### START CHANGES ##### $head .='<tr><td align=center>'.$longestReign.'</td></tr>'; $head .='<tr><td bgcolor=#E0E0E0 align=center><b><font color="#000000">Most Successful Defenses</font></b></td></tr>'; $head .='<tr><td align=center>'.$successDefense.'</td></tr>'; ##### END CHANGES ##### $head .='</table>'; } } } else { print '<table border=0 cellspacing="0" cellpadding=3 width=575>'; print '<tr><td background="images/bg_bar4.gif" height=35> <font color="white">Title Histories</font></td></tr>'; print '</table>'; print '<table border=0 cellspacing="0" cellpadding=3 width=575>'; print '<tr><td background="images/bg_bar3.gif" height=35 colspan=4> <font color="#000000">Active Titles</font></td></tr>'; print '<tr>'; //Define the query $query = "SELECT * FROM titles WHERE status = 'Active'"; // Active rows if ($r = mysql_query ($query)){ // Run the query. while ($row = mysql_fetch_array ($r)){ print '<td><a href="titlehistory.php?id=' . $row['id'] . '" title="View KOW '.$row['titlename'].' History">'; print '<img src="/images/' . $row['titleimage'] . '" border=0 alt="View KOW '.$row['titlename'].' History" height="115px" width="115px"></a></td>'; } } else { die ('<p>Could not retrieve the data because <b>' . mysql_error() . '</b>. The query was $query.</p>'); }//End of query IF print '</tr>'; print '</table>'; print '<img src=images/spacer.gif><br>'; print '<table border=0 cellspacing=0 cellpadding=3 width=575><tr><td background="images/bg_bar3.gif" height=35 colspan=2> <font color="#000000">Inactive Titles</font></td></tr>'; print '<tr>'; //Define the query $query = "SELECT * FROM titles WHERE status = 'Inactive'"; // Inactive Rows if ($r = mysql_query ($query)){ // Run the query. while ($row = mysql_fetch_array ($r)){ print '<td><a href="titlehistory.php?id=' . $row['id'] . '" title="View KOW '.$row['titlename'].' History">'; print '<img src="/images/' . $row['titleimage'] . '" border=0 alt="View KOW '.$row['titlename'].' History" height="115px" width="115px"></a></td>'; } } else { die ('<p>Could not retrieve the data because <b>' . mysql_error() . '</b>. The query was $query.</p>'); } //End of query IF } print '</tr>'; print '</table>'; ?>
-
Yes, but you need to load all the data forr the select lists into the page. <html> <head> <script type="text/javascript"> // State lists var states = new Array(); states['Canada'] = ['Alberta','British Columbia','Ontario']; states['Mexico'] = ['Baja California','Chihuahua','Jalisco']; states['United States'] = ['California','Florida','New York']; // City lists var cities = new Array(); cities['Canada'] = new Array(); cities['Canada']['Alberta'] = ['Edmonton','Calgary']; cities['Canada']['British Columbia'] = ['Victoria','Vancouver']; cities['Canada']['Ontario'] = ['Toronto','Hamilton']; cities['Mexico'] = new Array(); cities['Mexico']['Baja California'] = ['Tijauna','Mexicali']; cities['Mexico']['Chihuahua'] = ['Ciudad Juárez','Chihuahua']; cities['Mexico']['Jalisco'] = ['Guadalajara','Chapala']; cities['United States'] = new Array(); cities['United States']['California'] = ['Los Angeles','San Francisco']; cities['United States']['Florida'] = ['Miami','Orlando']; cities['United States']['New York'] = ['Buffalo','New York']; function setStates(){ cntrySel = document.getElementById('country'); stateSel = document.getElementById('state'); stateList = states[cntrySel.value]; changeSelect(stateSel, stateList); setCities(); } function setCities(){ cntrySel = document.getElementById('country'); stateSel = document.getElementById('state'); citySel = document.getElementById('city'); cityList = cities[cntrySel.value][stateSel.value]; changeSelect(citySel, cityList); } //**************************************************************************// // FUNCTION changeSelect(fieldObj, valuesAry, [optTextAry], [selectedVal]) // //**************************************************************************// function changeSelect(fieldObj, valuesAry, optTextAry, selectedValue) { //Clear the select list fieldObj.options.length = 0; //Set the option text to the values if not passed optTextAry = (optTextAry)?optTextAry:valuesAry; //Itterate through the list and create the options for (i in valuesAry) { selectFlag = (selectedValue && selectedValue==valuesAry[i])?true:false; fieldObj.options[fieldObj.length] = new Option(optTextAry[i], valuesAry[i], false, selectFlag); } } </script> </head> <body onload="setStates();"> <form name="test" method="POST" action="processingpage.php"> Country: <select name="country" id="country" onchange="setStates();"> <option value="Canada">Canada</option> <option value="Mexico">Mexico</option> <option value="United States">United States</option> </select> <br> State: <select name="state" id="state" onchange="setCities();"> <option value="">Please select a Country</option> </select> <br> City: <select name="city" id="city"> <option value="">Please select a Country</option> </select> </form> cities['Canada'] = new Array(); cities['Canada']['Alberta'] = ['Edmonton','Calgary']; cities['Canada']['British Columbia'] = ['Victoria','Vancouver']; cities['Canada']['Ontario'] = ['Toronto','Hamilton']; </body> </html>
-
BNo need to split into an array if all you want to do is replace the space characters with a line break: var str="code name club price"; document.write(str.replace(/ /g, '<br />'));
-
This should get you started. I would add some more validation on the investment field as well <html> <head> <script type="text/javascript"> function validate(formObj) { //Remove non-numeric values stripNonNumeric(formObj['withdrawl']); stripNonNumeric(formObj['days']); //Ensure req field have value if (!formObj['investment'].value || !formObj['withdrawl'].value || !formObj['days'].value) { alert('All fields are required.'); return false; } return true; } function stripNonNumeric(fieldObj) { fieldObj.value = fieldObj.value.replace(/[^\d]/g, ''); } </script> </head> <body> <form name="stockinvest" onsubmit="return validate(this);" method="get" action="index.php"> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td>Starting Investment:</td> <td><input type="text" name="investment" value="$1,000,000" /></td> </tr> <tr> <td>Daily Withdrawal:</td> <td><input type="text" name="withdrawl" value="0" /></td> </tr> <tr> <td>Days to invest:</td> <td><input type="text" name="days" value="31" /></td> </tr> <tr> <td colspan="2" align="center"><button type="submit">Calculate</button></td> </tr> </table> </form> </body> </html>
-
You know the amount that you are increasing strength by, right? This should work: echo "your stats are now " . ($player->strength + $statupdate);
-
What he said ^^^ Basically the script first checks to see if (isset($_POST['train'])) { if the value for the train field has been posted. If so, then the script attempts to perform the training. Else, it will display the form.
-
This should do it. Look throught he code and see if you can understand the logic. It's pretty strait forward <?php /*************************************/ /* ezRPG Gym script */ /* Written by Chris From Wa */ /* http://code.google.com/p/ezrpg */ /* http://www.bbgamezone.com/ */ /* http://www.caraudiocentral.net */ /*************************************/ include("lib.php"); define("PAGENAME", "CAC World Gym...Pump You Up!"); $player = check_user($secret_key, $db); include("templates/private_header.php"); if (isset($_POST['train'])) { $statupdate=($player->energy*$player->Awake)/100; $awakereduce=($player->Awake-5); $energyreduce=($_POST['trainamount']); //Check that player has Awake Left if ($player->Awake <= 0) { echo "You are too tired to train."; } //Check that player has energy Left else if ($player->energy <=0) { echo "You have no energy left"; } //check that player has paid taxes else if ($player->Taxes_Owed >0) { echo "<strong>You Deadbeat!</strong> <br>We already told you. You have to pay your property taxes before you can use our gym.<p>"; echo "You didn't think we knew that kind of stuff about you, did ya!<br>"; echo "Pay your taxes or we'll also put that video of you and the goat on youtube"; } //Perform the training else { switch($_POST["train"]) { case "Strength": $updatestrength = $db->execute("UPDATE `players` SET `strength`= `strength`+?, `Awake`=?, `energy`= `energy`-? WHERE `id`=?", array($statupdate, $awakereduce, $energyreduce, $player->id)); break; case "Agility": //$updatestrength = $db->execute("UPDATE `players` SET `strength`= `strength`+?, `Awake`=?, `energy`= `energy`-? WHERE `id`=?", array($statupdate, $awakereduce, $energyreduce, $player->id)); break; case "Stamina": //$updatestrength = $db->execute("UPDATE `players` SET `strength`= `strength`+?, `Awake`=?, `energy`= `energy`-? WHERE `id`=?", array($statupdate, $awakereduce, $energyreduce, $player->id)); break; } echo "You just trained\n" . $energyreduce . "times" ; echo "$energyreduce"; } } else { echo "<h3>Welcome to the CAC World Gym!</h3><br>If you're a homeowner in our lovely city, all of our equipment is yours to use <strong>FREE!</strong><p>"; echo "The city just requires that you have all your property taxes paid in full<br>"; echo "You currently owe\n$<strong>" . $player->Taxes_Owed . "\n</strong>in taxes<p>"; echo "You can currently train\n<strong>" . $player->energy . "</strong>\ntimes<p>"; echo "<strong>How many times would you like to train</strong><p>"; echo "<form method=\"post\" action=\"gym.php\">"; echo "<input type=\"text\" name=\"trainamount\" value=\"$player->energy\"/><p> "; echo "<strong>What area would you like to work on?</strong><br>"; echo "<select name=\"train\"\n"; echo "<option value=\"Strength\">Strength</option>\n"; echo "<option value=\"Speed\">Speed</option>\n"; echo "<option value=\"Defense\">Defense</option\n"; echo "<input type=\"submit\" value=\"Train\" />\n"; } include("templates/private_footer.php"); ?>
-
Soe of that logic is out of place. I think this will work better for you: <?php $statupdate=($player->energy*$player->Awake)/100; $awakereduce=($player->Awake-5); $energyreduce=($_POST['trainamount']); include("templates/private_header.php"); //Check that player has Awake Left if ($player->Awake <= 0) { echo "You are too tired to train."; } //Check that player has energy Left else if ($player->energy <=0) { echo "You have no energy left"; } //check that player has paid taxes else if ($player->Taxes_Owed >0) { echo "<strong>You Deadbeat!</strong> <br>We already told you. You have to pay your property taxes before you can use our gym.<p>"; echo "You didn't think we knew that kind of stuff about you, did ya!<br>"; echo "Pay your taxes or we'll also put that video of you and the goat on youtube"; } //Perform the training else { switch($_POST["train"]) { case "Strength": $updatestrength = $db->execute("UPDATE `players` SET `strength`= `strength`+?, `Awake`=?, `energy`= `energy`-? WHERE `id`=?", array($statupdate, $awakereduce, $energyreduce, $player->id)); break; case "Agility": //$updatestrength = $db->execute("UPDATE `players` SET `strength`= `strength`+?, `Awake`=?, `energy`= `energy`-? WHERE `id`=?", array($statupdate, $awakereduce, $energyreduce, $player->id)); break; case "Stamina": //$updatestrength = $db->execute("UPDATE `players` SET `strength`= `strength`+?, `Awake`=?, `energy`= `energy`-? WHERE `id`=?", array($statupdate, $awakereduce, $energyreduce, $player->id)); break; } echo "You just trained\n" . $energyreduce . "times" ; echo "$energyreduce"; } include("templates/private_footer.php"); ?>
-
That a LOT of unnecessary code. Make life easier on yourself. 1. Give functions logical names. 'action' or 'handleChboxes' don't give enough information as to what is being done. 2. Pass appropriate values (i.e. don't pass an arbitrary value such as 'select' that you then need to translate into the value you really need - true) 3. Don't repeat/copy code unnecessarily. The main part of the code above is duplicated with only 1 line being different. This function would do all that the above would do and would be much more efficient function checkAll(checkBool) { for(var i = 0; i <= document.myForm.elements.length; i++) { if(document.myForm.elements[i].type == 'checkbox') { document.myForm.elements[i].checked = checkBool; } } } (I would also pass the form name to that function to make it more modular) And you would call it like this: <li><a href="#" onClick="checkAll(false)">deselect all</a></li> <li><a href="#" onClick="checkAll(true)">select all</a></li>
-
This might not be the most efficinet, but it works: <html> <head> <script type="text/javascript"> var t=1; var intime=0; //showData(data){ //} function insRow(r) { intime=intime+1; var x=document.getElementById('myTable').insertRow(t); var date=x.insertCell(0); var h=x.insertCell(1); var d=x.insertCell(2); var r=x.insertCell(3); var del=x.insertCell(4); //date.innerHTML="<input type='text' size='10' name='date"+t+"'>"; var date1= document.createElement('input'); date1.name="date"+t; date1.value="date"+t; date1.id="date"+t; date1.size='10'; date.appendChild(date1); var hours= document.createElement('input'); hours.name='hours'+t; hours.value='hours'+t; hours.id='hours'+t; h.appendChild(hours); var des= document.createElement('textarea'); des.name='descrition'+t; des.id='descrition'+t; des.cols='20'; des.rows='5'; d.appendChild(des); //des.innerHTML="<textarea rows='5' name='descrition"+t+"' cols='20'></textarea>" var sel = document.createElement('select'); sel.name = 'remarks' + t; sel.id = 'remarks' + t; sel.options[0] = new Option('Done', 'Done'); sel.options[1] = new Option('ongoing', 'ongoing'); r.appendChild(sel); del.innerHTML="<input type='button' value='Delete' onclick='deleteRow(this)'>"; t++; document.time.time1.value=intime; } function deleteRow(r) { var i=r.parentNode.parentNode.rowIndex; document.getElementById('myTable').deleteRow(i); t=t-1; while (document.getElementById('date'+(i+1))) { nextID = (i+1); dateObj = document.getElementById('date'+nextID); dateObj.name = 'date'+i; dateObj.value = 'date'+i; dateObj.id = 'date'+i; hoursObj = document.getElementById('hours'+nextID); hoursObj.name = 'hours'+i; hoursObj.value = 'hours'+i; hoursObj.id = 'hours'+i; descObj = document.getElementById('descrition'+nextID); descObj.name = 'descrition'+i; descObj.id = 'descrition'+i; remObj = document.getElementById('remarks'+nextID); remObj.name = 'remarks'+i; remObj.id = 'remarks'+i; i++; } intime=intime-1; document.time.time1.value=intime; /* i comment this one coz i cant seem to update the content of every cell in a row for (c=1;c<=intime;c++){ var x=document.getElementById('myTable').rows; var y=x[c].cells; y[c].innerHTML="NEW CONTENT"; }*/ } </script> </head> <body> <form name ='time' > <table id="myTable" border="1"> <input type="text" size='1'name='time1'value=''> <tr><td>Date</td> <td>Hours</td> <td>Description</td> <td>Remarks</td> <td><input type="button" onclick="insRow(this)" value="Insert row"></td> </tr> </table> </form> </body></html>
-
I would suggest using the db id of your images combined with a php script to retrieve your images outside the web root. Then your image tags would look something like this: <img src="getimage.php?id=24" /> The script for getimage.php could look something like this (left out validations that should occur): <?php $id = $_GET['id']; $result = mysql_query("SELECT path FOM images WHERE id = $id"); $image = mysql_fetch_assoc($result); $path = $image['path']; $extension = substr($path, -3); if($extension == "jpg"){ header("Content-type: image/jpeg"); }elseif($extension == "gif"){ header("Content-type: image/gif"); } readfile($path); ?>
-
Here's a function modified from this post: http://www.phpfreaks.com/forums/index.php?topic=209261.0 (funny what you can find with a search) It works for links created in either of the two formats: www.mysite.com/directory.file.php [urlwww.mysite.com/directory.file.php[/url] function makeClickableLink($text) { $link = preg_replace('% ### Not preceded by an url start. (?<!url[=\]]) ( ### Protocol or start. (?: (??:https?|ftp)://) | www\. ) ### Body. (?> ### Gobble all non-space with the exception of [/url] (??!\[/url\])\S)+ ### Avoid ending punctuation. (?<!\p{P}) ) ### Not followed by an url end. (?!\[/url\]) ) %x', '<a href="$1">$1</a>', $text); return $link; }
-
Take a look at the solution posted here: http://www.webmasterworld.com/javascript/3341791.htm
-
This is attempting to ASSIGN a value of 1 to the variable $count and, if successful, returns true. while ($count=1) This does a COMPARISON of $count to see if it is equal to 1, and returns true if it is. while ($count==1)
-
You code makes no sense. You iterrate through each record in the result set (as an array) and add it to another array - creating a mutidimensional array. Then you attempt to search for "x" in the multidimentional array $arr and replace it with the variable $img (which always contains "images/x.jpg"). Also in the loop you are always redefining the value of $replace, so when you echo the value you will only get the value from the last iterration through the loop. To be honest I have no clue what you are trying to accomplish. Explain what results you are getting from your query and how you want to display those results.
-
It's the same as if (isset($ReviewRating)) { $rating = $ReviewRating; } else { $rating = ''; } It's called the ternary operator and can be described like this: ( [CONDITION] ) ? [trUE RETURN VALUE] : [FALSE RETURN VALUE] It is very useful for assigning one of two values to a variable based on a condition - such as in the example you posted. But, it can be used in many different contexts as well. Example: <?php echo "You have " . (($items<10) ? 'less than 10' : '10 or more') . " items in your cart"; ?>
-
question about how to display data row after row in a webpage?
Psycho replied to Redlightpacket's topic in PHP Coding Help
Based upon my interpretation of your post you want to display the records left-to-right in a three column format. I pointed you to a possible solution based on that. I don't know what you mean by '...one set of "table code" to make my data display in all of my tables' If each record is "complex" and is displayed within it's own table then you could simply modify the code I pionted you to to display each record (within a table) within each cell of a parent table that is three columns wide. You asked a "general" question and so a general response was given. If you have specific code you are currently using that you need specific help with, you need to post the code. -
question about how to display data row after row in a webpage?
Psycho replied to Redlightpacket's topic in PHP Coding Help
Take a look at my earlier post today on the same subject: http://www.phpfreaks.com/forums/index.php/topic,212688.msg969332.html#msg969332 -
How do i send variable from page to page .. please help
Psycho replied to yanivkalfa's topic in Javascript Help
OK, I would have been VERY helpful to see the actual code you have so we could provide more concrete help as opposed to gereralities. So you apparently have the images on the page with IDs, just put the images within anchor tags such as this: <a href="#" id="imgLink0"><img src="#" id="imgdiv0"></a> Then modify your script to something like this: document.getElementById('imgdiv0').src=Picsarray[0]; document.getElementById('imgLink0').href=Picsarray[0]; document.getElementById('imgdiv0').src=Picsarray[1]; document.getElementById('imgLink0').href=Picsarray[1]; document.getElementById('imgdiv0').src=Picsarray[2]; document.getElementById('imgLink0').href=Picsarray[2]; Personally I would probably take an entirely different approach, but this should work for what you already have. -
[SOLVED] Need to output arrays received to multiple lines.
Psycho replied to nitromaster's topic in PHP Coding Help
<?php $columns = 5; $currCol = 1; $photos = $facebook->photos_getAlbums($profile_id, ''); echo "<table>\n"; foreach($photos as $userData) { if ($currCol==1) { echo "<tr>\n"; } echo "<td><div style=\"text-align: center; padding: 10px;\">"; echo "<a href=\"http://apps.facebook.com/add.php?aid="; echo "{$userData['aid']}&owner={$userData['owner']}\">"; echo "<sn:photo pid=\"{$userData['cover_pid']}\" size=\"s\" />"; echo "<br/><a href=\"http://apps.facebook.com/appname/add.php?aid="; echo "{$userData['aid']}&owner={$userData['owner']}\">"; echo "{$userData['name']}</a><br/>"; echo "{$userData['size'] photo" . (($userData['size']!=1)?'s':''); echo "</div></td>"; if ($currCol==$columns) { echo "<\tr>\n"; $currCol=0; } $currCol++; } echo "</table>\n"; ?> -
How do i send variable from page to page .. please help
Psycho replied to yanivkalfa's topic in Javascript Help
I'm really not following what you are trying to do. Your question is way to general to provide any specific help. If you were to provide a link to the page you already have with some more specific instructions it would be helpful. However I will try to parapharase your request into what I think you are asking. You havea page in which an image is displayed. There is a next button/link on the page that will display the next image in the album. But, you also want the image itself to be a link to open the image full-size. If that is correct, I would have a question for you. Do you have two versions of each image (small & large) or are you using JavaScript to change the size of the image on-the-fly? -
It might be helpful for others if you posted the solutino (and marked the thread solved). I'm also curious why you are using IDs on the options and not just using a value for them.
-
How to print results of mysqli_query to browser
Psycho replied to woodworks's topic in PHP Coding Help
Don't forget to use teh search function in this forum. If you were to find a post of someone asking how to display data (in a specific situation) chances are the responses will include more than one response which hopefully explain the "why". There is no one way to do anything in programming. There are always alternatives and which is the best one may not always be the same in different situations. -
<?php $text = " Just a simple text"; $text = str_replace(' ', '$nbsp;', $text); echo $text; //Output: "$nbsp;$nbsp;$nbsp;$nbsp;$nbsp;Just a simple text" ?> But, you might want to consider just using PRE tags as they will also preserve line-breaks and possibly other problem characters as well.
-
How to print results of mysqli_query to browser
Psycho replied to woodworks's topic in PHP Coding Help
That depends COMPLETELY on the context in which you want to display the results. Personally I suggest creating a static HTML page with "test" data and then creating your PHP to match. In some cases I would just hard-code the functioality to write the data to the page. In other's (such as a report listing) I might create a function or class to display the data tomaintain consistency. Those are used in instances where you run multiple queries at once. I never do that myself. I would suggest sticking with running queries individually - at least initially. Because debugging will be more complicated otherwise. Once you are more familiar with PHP/MySQL, then you can venture into the more complicated. The examples int he manual seem to provide a pretty good explanation in my opinion. As for books, I would suggest looking for some good online tutorials. A google search for "PHP MySQL Tutoria" brings up some good results. If anything doesn'ty make sense to you then you can post on these forums.