PHP - Looping The Same Data On The Same Page
I'm trying to loop "Question" as a list of links (link is #id_number), and then later on the page loop "Question" and "Answer", anchored by the id_number tag.
It's looping "Question" just fine, but how do I then loop the same data again later in the same page? Code: [Select] <?php $username="username"; $password="password"; $database="database_name"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM ft_form_17 WHERE Include='Include'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> Header Goes here<br /><br /><br /> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"question"); //Question $f2=mysql_result($result,$i,"answer"); //Answer $f3=mysql_result($result,$i,"submission_id"); //id number ?> <a href="#<?php echo $f3; ?>"><?php echo $f1; ?></a><br /> <?php $i++; } ?> <br /><br /><br /> <strong><a name="<?php echo $f3; ?>"><?php echo $f1; ?></a></strong> <?php echo $f2; ?> Similar TutorialsHi Guys I have never reall worked with xml and im stuck. I am gathering data from a class. include "example/class.php"; $data = new Class; $request = $data->List_Accounts(); $res = $data->run_xml($request); echo "<pre>"; print_r($res); echo "</pre>"; Ok so this is the output i get from the print_r(); <pre><!--?xml version="1.0" encoding="utf-8"?--> <rpc request_id="43535"> <response code="0" text="OK"> <account datatype="list"> <name datatype="username">arf34</name> <type datatype="account_type">3</type> <descr datatype="string">Linux Virtual Hosting</descr> <server datatype="int">35</server> </account> <account datatype="list"> <name datatype="username">awecerfewve</name> <type datatype="account_type">3</type> <descr datatype="string">Linux Virtual Hosting</descr> <server datatype="int">34</server> </account> </response></rpc></pre> How could i them loop through this data and pull out certain types like username and account_type using a foreach loop???? Can anyone please help with this. Thanks Hi there, I am wanting to insert post data into my DB, this is guest information if i do a $safePost = filter_input_array(INPUT_POST); print_r($safePost); i get the following output. Array ( [action] => addGuestInfo [guestno] => 2 [bookingid] => 151 [customerid] => 22 [Guestname-0] => Jamie [Guestname-1] => Joe [GuestAge-0] => 4-3 [GuestInfo-0] => celiac [GuestAge-1] => 18 [GuestInfo-1] => wheat ) normally the guestname-0, guestage-0, guestinfo-0 would be in correct order but we have to ensure the just incase it isns't (see output above) we cater for that aswell, we can have upto 6 guest details coming in at once. so I need to loop through the data and insert into my DB. I have tried various for / foreach loops but cant seem to get it to group the data together I have tried things like below, but it inserts each record multiple times. $safePost = filter_input_array(INPUT_POST); foreach($safePost as $key => $value){ $exp_key = explode('-', $key); // for ($i =0; $i <= $guestcount; $i++) { switch ($exp_key[0]) { case 'Guestname': $booking->guestno = $exp_key[1]; $booking->guestname = $val; break; case 'GuestAge': $booking->guestno = $exp_key[1]; $booking->guestage = $val; break; case 'GuestInfo': $booking->guestno = $exp_key[1]; $booking->guestinfo = $val; break; default: break; } //CALLS FUNCTION TO INSERT TO DB result = lastInsertId(); $result= $booking->insertGuestDetails(); //} }
-First I want to say that I love this site and always check google before I submit questions but im lost. I'm into security and trying to learn a little Apache, Mysql, and PHP to understand the development cycle better. As practice im creating a notecard test review site. Create notecard Decks, add/delete questions etc. shuffle, then test yourself. I though I was doing good until I got to the page that shows the questions (test.php). Right now I pass the "deck_id" field in a GET to a "test.php?id=" page that runs a script that pulls out all the questions for that deck from my "questions" table and loops to show each question for that "deck". My loop works, (gets array from database and shows questions one by one), but it writes all the questions to the page at the same time. DUH. I want it to show one question with a "NEXT" button to show next question. This button clears the first question and writes the next one until they are all done. No grading or anything needed. Is there a way to do this gracefully? I dont know much javascript but looked up innerHTML and see i can update text that way but the PHP loop I have goes so fast it just end up showing the last question with no way to pause it between questions. Can anyone think of a way to do this? My problem is passing the data from page to page to page (I lose the array data) If this is impossible my other thoughts a 1) store current list of Q/A's in cookie (OR) 2) pass Q/A to another page with POSTS (OR) 3)store Q/A's to temporary sql table and use GETS in loop to show each one by one. "testing.php?question=1" 4) can i set a global variable that can pass the data to separate pages? 5)user iFrame so it looks like one page (dont know how) Im leaning to number 3 but want to hear your suggestions. (sorry very new) I'm using PHP and MySQL to display images on the first page.
When the image is clicked on I'm passing an ID to a new page.
I want that ID to display the ID data that's associated with that ID.
For example:
ID 1 should display - Title - title1, Details - details1, image - image1
and ID 2
ID 1 should dislay - Title - title2, Details - details2, image - image2
But only displaying ID 1 data not matter if the URL is - website.com/thedetials.php?id=1 or website.com/thedetials.php?id=2
In other words, it displays the same data even though the id in the URL is different.
Page 1
$sql="SELECT * FROM thetable"; $result = mysqli_query($con,$sql); echo " <ul>"; while($row = mysqli_fetch_array($result) { echo "<li'>"; echo "<a href='page2.php?id=$row[id]'><img src=$row[image]></a>"; echo "</li>"; } echo "</ul>"; ?> <?php // End while loop. mysqli_close($con); ?>Page 2 $id = $_GET['id']; $sql="SELECT id, title, details, image, FROM thetable"; $result = mysqli_query($con,$sql); $row = mysqli_fetch_array($result); ?> <?php echo $row['title'] ?> <?php echo $row['details'] ?> <img class='projectItem-pic' src="<?php echo $row['image']?>">If I use below - No data displays, not sure why. $sql="SELECT * FROM thetable WHERE id = $id";Can someone tell me what I'm doing wrong? Edited by patmon, 08 June 2014 - 09:22 PM. I must be mixing apples and oranges here or something trying to get two columns/fields of MySQL data to display.
The basic HTML page display OK and there are no MySQL Connection errors (finally resolved those).
<HTML snipped> <?php require '...<URL snipped>...'; if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="SELECT `name`, `id` FROM `roster`"; $result = mysqli_query($con,$sql); $num=mysqli_num_rows($result); mysqli_close($con); ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <td> <font face="Arial, Helvetica, sans-serif">NAME</font> </td> <td> <font face="Arial, Helvetica, sans-serif">ID</font> </td> </tr> <?php function mysqli_result($res, $row, $field=0) { $res->data_seek($row); $datarow = $res->fetch_array(); return $datarow[$field]; } $i=0; while ($i < $num) { $f1=mysqli_result($result,$i,$datarow[$field]); $f2=mysqli_result($result,$i,$datarow[$field]); ?> <tr> <td> <font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font> </td> <td> <font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font> </td> </tr> <?php $i++; } ?> </table> <?php ?> <HTML snipped>Any assistance is appreciated. Thanks very much. - FreakingOUT I have the following code Code: [Select] while($player = mysql_fetch_array($players)) { #Lets loop through all the players echo "<BR><input type=submit onclick=this.form.action='points.php?points=".$_GET['points']."&player=".$player['playerID']."&playerName=".$player['name']."' value='".$player['name']."'>"; }but the problem is that $player['name'] is always two words and it doesn't work. So I have removed '&playerName=".$player['name']."' but now don't know how to transfer that info. Is there a way of having the player name in the header or another way of sending this data to the next page? Another way of doing it is to check for the players name via there playerID number but this involves another call to the database which I am trying to avoid. Hi there. I have a page(portfolio.php) that shows all the pictures from my db. Now what i want is: when i click on the picture to send me to a page(portfolio_single.php) where other datas are shown but those datas that are related to that picture. ex: when i click first picture it will open (portfolio_single.php) showing the infos of that picture, then when i click to the secon picture it will open same page with different datas (retreiving them from db). Anyone have any idea how to do that? here is my portfolio.php: Code: [Select] <?php require_once('Connections/ecommerce_dbcon.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_ecommerce_dbcon, $ecommerce_dbcon); $query_portofolioPicRec = "SELECT picture FROM `form` ORDER BY formid DESC"; $portofolioPicRec = mysql_query($query_portofolioPicRec, $ecommerce_dbcon) or die(mysql_error()); $row_portofolioPicRec = mysql_fetch_assoc($portofolioPicRec); $totalRows_portofolioPicRec = mysql_num_rows($portofolioPicRec); ?> <!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> <title> Portfolio</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- Stylesheets --> <link rel="stylesheet" href="css/reset.css" /> <link rel="stylesheet" href="css/styles.css" /> <!-- Scripts --> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <!--[if IE 6]> <script src="js/DD_belatedPNG_0.0.8a-min.js"></script> <script> /* EXAMPLE */ DD_belatedPNG.fix('.button'); /* string argument can be any CSS selector */ /* .png_bg example is unnecessary */ /* change it to what suits you! */ </script> <![endif]--> </head> <body class="portfolio"> <div id="wrapper" class="container_12 clearfix"> <!-- Admin Login --> <h1 id="login" class="grid_4"> <form id='login' action="checkAdminLogin.php" method='POST' accept-charset='UTF-8'> <fieldset > <legend class="meta">Admin Login</legend> <input type='hidden' name='submitted' id='submitted' value='1'/> <table> <tr><th> <label for='username'>Name:</label> </th> <td><input type='text' name='username' id='username' maxlength="50" /> </td></tr> <tr><th> <label for='password'>Password:</label></th> <td><input type='password' name='password' id='password' maxlength="50" /> </td> <th><input type='submit' name='Submit' value='Login' /> </th></tr> </table> </fieldset> </form> </h1> <!-- Navigation Menu --> <ul id="navigation" class="grid_8"> <li><a href="contact.php"><span class="meta">Get in touch</span><br />Contact Us</a></li> <li><a href="blog.php"><span class="meta">Latest news</span><br />Blog</a></li> <li><a href="portfolio.php" class="current"><span class="meta">Our latest work</span><br />Portfolio</a></li> <li><a href="about.php"><span class="meta">Who are we?</span><br />About</a></li> <li><a href="index.php"><span class="meta">Homepage</span><br />Home</a></li> </ul> <div class="hr grid_12 clearfix"> </div> <!-- Portfolio Items --> <!-- Section 1 --> <!-- Section 3 --> <div class="catagory_1 clearfix"> <!-- Row 1 --> <div class="grid_3 textright" > <span class="meta">Our Latest and Greatest Work</span> <h4 class="title ">Portfolio</h4> <div class="hr clearfix dotted"> </div> <p>Here you can see all the cars that exist in our database. You can navigate through all of them.</p> </div> <div class="grid_9"> <table > <tr> <?php $portofolioPicRec_endRow = 0; $portofolioPicRec_columns = 3; // number of columns $portofolioPicRec_hloopRow1 = 0; // first row flag do { if($portofolioPicRec_endRow == 0 && $portofolioPicRec_hloopRow1++ != 0) echo "<tr>"; ?> <td><a class="portfolio_item float alpha" href="portfolio_single.php"> <span>Read More</span> <img class="" src="adminform_images/<?php echo $row_portofolioPicRec['picture']; ?>" alt=""/></a></td> <?php $portofolioPicRec_endRow++; if($portofolioPicRec_endRow >= $portofolioPicRec_columns) { ?> </tr> <?php $portofolioPicRec_endRow = 0; } } while ($row_portofolioPicRec = mysql_fetch_assoc($portofolioPicRec)); if($portofolioPicRec_endRow != 0) { while ($portofolioPicRec_endRow < $portofolioPicRec_columns) { echo("<td> </td>"); $portofolioPicRec_endRow++; } echo("</tr>"); }?> </table> </div> </div> <div class="hr grid_12 clearfix"> </div> <!-- Footer --> <p class="grid_12 footer clearfix"> <span class="float"><b> EpokaUniversity || All Rights Reserved © Copyright</b> || HarisKrasniqi, DiamantNeziri, HarisMemeti, KelmendTairi.</span> <a class="float right button" href="#">top</a> </p> </div><!--end wrapper--> </body> </html> <?php mysql_free_result($portofolioPicRec); ?> portofolio_single.php: suppose it is a table that contains the: name: (it will echo out the name of the picture depending on which picture u click) date: path: etc of the photo Is it possible to write a php script that would extract data from an external web page. I've been working with php for a few years as a hobby, but I've never seen this done or needed a reason to until now. Thanks in advance for any responses. This is the link to pull the page http://127.0.0.1/kudos/?viewkudoid=### This is the kudo-function.php page function get_kudo_info($viewkudoid){ global $wpdb; $tablename=acikudos_table_name(); $viewsql = "SELECT * FROM $tablename WHERE kudoid='$viewkudoid'"; $viewresult = $wpdb->get_results($viewsql); #$vewrow = mysql_fetch_assoc($viewresult); return $viewresult; } This is the kudo-view.php page function show_kudos($viewkudoid) { global $wpdb; $viewkudoid = $_GET['viewkudoid']; $getthekudo = get_kudo_info($viewkudoid); if ($viewkudoid == $getthekudo['kudoid']) { echo 'Congratulations, you have successfully fixed it!'; } else { echo 'Everything is displayed'; } } add_shortcode( 'kudosview', 'show_kudos' ); I know the issue is right in front of me but I can not find it. Hello, I've been hacking at this for about 5 hours, and have been unable to get my session data to pass through to the 3rd page. Here is my code. As you can see I've been trying all types of variation of retrieval. On page 2 I can pull the data from page 1 fine with REQUEST or the longer version.. But for some reason page 3 will not display the first_name and last_name... I'm desperate at this point. I have not been able to find a working answer. I'm running php 5 w/ trans... OFF (default) in .ini. Page 1 Code: [Select] <?php session_start(); ?> <?php $PHPSESSID = session_id(); echo "<strong>Session ID:</strong> $PHPSESSID"; "<br /><br />"; ?> <!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>0</title> </head> <body> <form method="post" action="multi_page_post_2.php"> <label>First Name</label> <input name="first_name" value="" width="50" type="text" /> <br /><br /> <label>Last Name</label> <input name="last_name" value="" width="50" type="text" /> <br /><br /> <input type="submit" name="submit" value="Enter your Data - Continue to Step 2 >>" /> </form> </body> </html> Page 2 Code: [Select] <?php session_start(); ?> <?php $PHPSESSID = session_id(); echo "<strong>Session ID:</strong> $PHPSESSID"; $first_name = $_REQUEST['first_name']; echo $first_name; ?> <?php echo "<br /><br />"; print_r($_SESSION); ?> <!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>Step 2</title> </head> <body> <h2>Step 2 - Is this data correct?</h2> <hr /> <strong>First Name:</strong> <?php echo $_SESSION['first_name'] = $_POST['first_name']; ?> <br /><br /> <strong>Last Name:</strong> <?php echo $_SESSION['last_name'] = $_POST['last_name']; ?> <br /><br /> <form method="post" action="multi_page_post_3.php"> <label>Sons First Name: </label> <input name="sons_first_name" value="" width="50" type="text" /> <br /><br /> <input type="submit" name="submit" value="YES! Continue to Step 3 >>" /> <input type="hidden" name="PHPSESSID" value="<?php echo $PHPSESSID ?>" /> <input type="button" value="No! Back to Previous Page" onClick="javascript: history.go(-1)"> </form> <br /><br /> <a href="" onclick="<?php session_destroy(); ?>">Session D E S T R O Y !</a> </body> </html> Page 3 Code: [Select] <?php session_start(); ?> <?php $PHPSESSID = session_id(); echo "<strong>Session ID:</strong> $PHPSESSID"; ?> <!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>Step 3</title> </head> <body> <h2>Step 3 - Is this data correct?</h2> <hr /> <strong>First Name:</strong> <?php echo $_SESSION['first_name'] = $_REQUEST['first_name']; ?> <br /><br /> <strong>Last Name:</strong> <?php echo $_SESSION['last_name']; ?> <br /><br /> <strong>Sons First Name:</strong> <?php echo $_REQUEST['sons_first_name']; ?> <br /><br /> <form method="post" action="multi_page_post_4.php"> <input type="hidden" name="PHPSESSID" value="<?php echo $PHPSESSID ?>" /> </form> <br /><br /> <a href="" onclick="<?php session_destroy(); ?>">Session D E S T R O Y !</a> </body> </html> index.php?page=1 that link style but there is not hard files it is all to be stored in the DB here is what i have got so far Code: [Select] <? $result = mysql_query("SELECT * FROM page") or die(mysql_error()); $row = mysql_fetch_array( $result ); if(isset($_GET['page'])) { echo $row['text']; } else { $result = mysql_query("SELECT * FROM page WHERE id='1'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo $row['text']; } ?> but always shows page ID 1 (home page) so i no i am missing something just not sure what hehe DB structu Code: [Select] menu ----id (auto increase) ----name (home, about etc) ----id2 (page weight) pages ----id (auto increase) ----name (page name home, about etc) ----text (page text) link structure from the menu Code: [Select] <? $result = mysql_query("SELECT * FROM menu ORDER BY id2") or die(mysql_error()); ?> <table> <? while($row = mysql_fetch_array( $result )) { ?> <tr><td> <a href="index.php?page=<? echo $row['id'];?>"><? echo $row['name']; ?></a> </td></tr> <? } ?> </table> dont think i have missed any info that i have on file but not sure why it will not link so thought of you guys hehe Thanx in advance I'm getting data from a remote XML file using the following as a result of a form: Code: [Select] <?php header('Content-type: text/xml'); //extract data from the post extract($_POST); //set POST variables $url = 'https://www.*******'; $fields = array( 'ESERIES_FORM_ID'=>urlencode($ESERIES_FORM_ID), 'MXIN_USERNAME'=>urlencode($MXIN_USERNAME), 'MXIN_PASSWORD'=>urlencode($MXIN_PASSWORD), 'MXIN_VRM'=>urlencode($MXIN_VRM), 'MXIN_TRANSACTIONTYPE'=>urlencode($MXIN_TRANSACTIONTYPE), 'MXIN_PAYMENTCOLLECTIONTYPE'=>urlencode($MXIN_PAYMENTCOLLECTIONTYPE), 'MXIN_CAPCODE'=>urlencode($MXIN_CAPCODE) ); //url-ify the data for the POST foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); //execute post $result = curl_exec($ch); //close connection curl_close($ch); ?> Which is displaying what was the remote XML page, but has brought it to my domain. How would I go about taking the results of the displaying XML page and displaying them on the next page rather than just displaying the XML data? Many thanks in advanced! I have been playing around with this. Thought I had it nailed, and then found that It was fubar when I started to add more entries to the database. I basically want to display 2 tables from my database on the page. One is called "players" the other is called "editlog". The output with my current script came out as this: and here is the dreaded code: <html> <body> <u><h3>Performance Point Monitor (PPM): Knights of Shadow WoW Officers.</h3></u> <?php include('/home/a3269923/public_html/ppm/admin/config.php'); include('/home/a3269923/public_html/ppm/admin/dbopen.php'); $query="SELECT * FROM players"; $result=mysql_query($query); $num=mysql_numrows($result); ?> <table border="1" style="position:absolute;width:500;height:10;left:0;top:70"> <tr> <th><font face="Arial, Helvetica, sans-serif">PLAYER</font></th> <th><font face="Arial, Helvetica, sans-serif">POINTS</font></th> <th><font face="Arial, Helvetica, sans-serif">DATE</font></th> </tr> <?php $i=0; while ($i < $num) { $f2=mysql_result($result,$i,"PLAYER_NAME"); $f3=mysql_result($result,$i,"ND_POINTS"); $f4=mysql_result($result,$i,"DATE ADDED"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> </tr> </table> <?php $i++; } ?> <?php include('/home/a3269923/public_html/ppm/admin/config.php'); include('/home/a3269923/public_html/ppm/admin/dbopen.php'); //USER LOG $query="SELECT * FROM editlog"; $result=mysql_query($query); $num=mysql_numrows($result); ?> <table border="1" style="position:absolute;width:600;height:10;left:510;top:70"> <tr> <th><font face="Arial, Helvetica, sans-serif">USER</font></th> <th><font face="Arial, Helvetica, sans-serif">TYPE</font></th> <th><font face="Arial, Helvetica, sans-serif">POINTS</font></th> <th><font face="Arial, Helvetica, sans-serif">NOTES</font></th> <th><font face="Arial, Helvetica, sans-serif">DATE</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"USER"); $f2=mysql_result($result,$i,"TYPE"); $f3=mysql_result($result,$i,"POINTS"); $f4=mysql_result($result,$i,"NOTE"); $f5=mysql_result($result,$i,"TIMESTAMP"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td> </tr> </table> <?php $i++; } ?> What am I doing wrong? Halp! I'm new to PHP and I have an html page I would like to pull specific data into certain areas on the page that I will modified for php. Here are some details. The page is a static html page that has the prices of 40+ products in a standard <li> list. When I update the prices in our database through our shopping cart, I have to change these prices manually in the html. https://www.novon.co...mic_mixers.html. It would be great if I could link the field for Base_Price in the products table to each affiliated <li> tag, I am pulling all the data I need into ($results) and can display it all but I don't know how to get just the single products Base_Price in my <li> tag. <?=$row['Base_Price'] ?> I know this code is not correct but to get the point across, can I create a variable that I define in each <li> tag with a statement like,,,, <?=$row['Base_Price with Product_Code=123456'] ?> I could create a new SQL query for each <li> like "SELECT Base_Price from Products WHERE Product_Code='123456' ", but that's a lot of calls to the DB and a lot of code on the page. And just so I weed out the hard core coders, I can not rebuild the entire page. This is too big of a project for me and my limited coding with PHP. Can anyone help?? Thanks in advance Michael I have a bunch of pdf's and I want to extract text from the last page of every pdf. I have a function to count the number of pages in each pdf. Does anyone know of a way that I could extract file from a specified file and page number. example: getData('example.pdf', 54); Hi, I am sending data from a form to a URL using $_GET but I would also like the user to be redirected to a thankyou page which is a different URL. Does anyone know if this is possible? Thanks, Hi people, I've been having trouble with this for a while now. Basically, i have this website: http://el07jpg.info . You can log in with username:doctor1 password:password1 Once you've logged on, u can click on "Patients". Then, if you click on a patient, it shows their info. Then at the bottom, I have links to glucose readings and heart rate readings... but when I click on either of those links, it goes back to the main page, showing all the patients.. The weird thing is that I got this to work for the first step, u click on the <a href> link of a patient, and it brings you to their page. Then I've done the EXACT same thing to link to the glucose or heart rate readings of that specific patient, but it doesn't work. I really can't see what i've done wrong. Although I noticed in the address bar, when I click on glucose readings for example, the url is http://el07jpg.info/index.php?op=patients&id=&reading=glucose (id should be equal to a number, like id=4, but there's no number... Any help would be much appreciated! Cheers! Code for op_patients.php page: <?php //Page if a set of records is selected from a single patient's page if ($_REQUEST[reading]+0) { $GLOBALS['html']['css'][]="default.css"; $reading_source=$_REQUEST[reading]+0; $sql="select * from {$reading_source}_readings where patientRFID='{$patient[patientRFID]}' "; $results=mysql_select_assoc($sql); if (!$results){ $GLOBALS[err][]="No records exist!"; exit; } $GLOBALS['html']['title']="Patient: {$patient[first_name]} {$patient[last_name]}'s {$reading_source} readings "; echo $reading_source; } //Page if a single patient is selected if ($_REQUEST[id]+0) { $GLOBALS['html']['css'][]="default.css"; $id=$_REQUEST[id]+0; $sql="select * from patients where doctorID='{$_SESSION[user][id]}' and patientID='$id' "; $patient=mysql_select_assoc($sql); if (!$patient){ $GLOBALS[err][]="The patient can't be found!"; exit; } $GLOBALS['html']['title']="Patient: {$patient[last_name]}, {$patient[first_name]} "; $output.=" <br> <table border='1' cellpadding='5' cellspacing='5' width='600'> <tr><td rowspan=6><img src=\"$patient[photo]\"> </td> <th>Name: </th><td>{$patient[first_name]} {$patient[last_name]} </td></tr> <tr><th>D.O.B: </th><td>{$patient[dob]} </td></tr> <tr><th>Email: </th><td>{$patient[email]} </td></tr> <tr><th>Phone Number: </th><td>{$patient[phone_no]}</td></tr> <tr><th>Address: </th><td>{$patient[address]}</td></tr> <tr><th><br> Comments:<br> </th> <td>{$patient[comments]} </td></tr> </table> <table border='1' cellpadding='5' cellspacing='5' width='600'> <tr><th colspan=3><br>Medical Readings<br><br></th></tr> <tr> <td align='center' width='300'> <a href='index.php?op=patients&id={$v[patientID]}&reading=glucose'>Glucose Readings</a> </td> <td colspan=2 align='center' width='300'> <a href='index.php?op=patients&id={$v[patientID]}&reading=heart'>Heart Rate Readings</a> </td> </tr> </table> "; echo $output; exit; } //Main Page showing all patients $GLOBALS['html']['title']="Patients"; $GLOBALS['html']['css'][]="default.css"; if(!$_SESSION[user][id]) { $er="Access Denied! Please Log in."; echo "<div style='color:red;'>$er</div>"; } else { $sql="select * from patients where doctorID='{$_SESSION[user][id]}' order by last_name"; $d=mysql_getarray_assoc($sql); $output=''; foreach ($d as $v){ $output.=" <tr><td> <a href='index.php?op=patients&id={$v[patientID]}'>{$v[last_name]}, {$v[first_name]}</a> </td></tr> "; } echo " <table width=80% align=left border='1' cellpadding='5' cellspacing='5' width='100%'> <tr><th class=popupheader align='left'> Patient Name<br><br> </th></tr> $output </table> "; } ?> |