Jump to content

oriental_express

Members
  • Posts

    113
  • Joined

  • Last visited

    Never

Everything posted by oriental_express

  1. Hi there and thanks for reply: If is try this: <tr><td><b>Image</b></td><td><a href='{$row['URL']}'> <img src='{$row['ImageURL']}'></a> the error is returned as this: ( ! ) Fatal error: Cannot use object of type stdClass as array in C:\wamp\www\Test\product.php on line 28 Call Stack # Time Memory Function Location 1 0.0032 374216 {main}( ) ..\product.php:0 If is try this: <tr><td><b>Image</b></td><td><a href='$row['URL']'> <img src='$row['ImageURL']'></a> //removed brackets the error is returned as this: ( ! ) Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\Test\product.php on line 28 Inside the database I have a column called ImageURL and its just urls of the image path (external url) Basically I want to hyper link that image with a url to wherever I want to point it. Does this help in any way? Thank you
  2. Hi there I've been working with some code to display a single record on page. This all works fine and I'm able to pull what I want from the database. My problems is trying to use that data and turning it into something else like a link. I have a field in the database called image url which contains rows of image urls. So here is the problem area of the code: <?php //////Displaying Data///////////// $id=$_GET['id']; // Collecting data from query string if(!is_numeric($id)){ // Checking data it is a number or not echo "Data Error"; exit; } $fetch=mysql_query("select * from productfeeds where ProductID=$id "); $row=mysql_fetch_object($fetch); echo mysql_error(); echo "<table>"; echo " <tr><td><b>ProductID</b></td><td>$row->ProductID</td></tr> <tr><td><b>ProductName</b></td><td>$row->ProductName</td></tr> <tr><td><b>ProductPrice</b></td><td>$row->ProductPrice</td></tr> //problem area for me <tr><td><b>Image</b></td><td>$row->ImageURL</td></tr> echo "</table>"; I'm trying to edit this part of the code: <tr><td><b>Image</b></td><td>$row->ImageURL</td></tr> I've tried this: <tr><td><b>Image</b></td><td><a href='{$row['URL']}'> <img src='{$row['ImageURL']}'></a> and <tr><td><b>Image</b></td><td><a href='$row['URL']'> <img src='$row['ImageURL']'></a> //removed brackets but I'm just getting errors. Can you guys help please? Thank you very much.
  3. Hi there I'm not sure I suppose what I'm trying to do with LinkURL is to make the image clickable? All other areas has $rows so I thought I would try it. is it possible to have a href link inbetween an echo function? Where am I going wrong ?
  4. 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: <?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: 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
  5. Hello there I'm having a bit of trouble getting my search function to work. this is my search script: http://michael-nguyen.com/greeneco/search.php <form action="<?=$PHP_SELF?>" method="post" name="search" class="style1"> <div align="center">Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="id">ID</option> <Option VALUE="name">Name</option> <Option VALUE="pledge">Pledge</option> <Option VALUE="points">Points</option> <Option VALUE="costs">Costs</option> <Option VALUE="kwh">Kwh</option> <Option VALUE="carbon">Carbon</option> <Option VALUE="classification">Classificationn</option> <Option VALUE="energysaving">Energy Saving</option> <Option VALUE="enabled">Enabled</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </div> </form> <span class="style1"> <table border="1" width="100%"> </span> <tr><strong> <td width="35" class="style1"><span class="style5">ID</span></td> <td width="78" class="style1"><span class="style5">Name</span></td> <td width="78" class="style1"><span class="style5">Pledge</span></td> <td width="132" class="style1"><span class="style5">Points</span></td> <td width="194" class="style1"><span class="style5">Cost</span></td> <td width="78" class="style1"><span class="style5">Kwh</span></td> <td width="78" class="style1"><span class="style5">Carbon</span></td> <td width="72" class="style1"><span class="style5">Classification</span></td> <td width="150" class="style1"><span class="style5">Energy Saving</span></td> <td width="91" class="style1"><span class="style5">Enabled</span></td></strong> </tr> <p class="style1"> <? //This is only displayed if they have submitted the form if ($searching =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($find == "") { echo "<p>Please enter a search term"; exit; } // Otherwise we connect to our Database mysql_connect('localhost','admin','pass') or die(mysql_error()); mysql_select_db("table") or die(mysql_error()); // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified $results = mysql_query("SELECT * FROM table WHERE upper($field) LIKE'%$find%'"); //And we display the results while ($a = mysql_fetch_array($results)) { echo'<TR> <TD>'.$a['id'].'</TD> <TD>'.$a['name'].'</TD> <TD>'.$a['pledge'].'</TD> <TD>'.$a['points'].'</TD> <TD>'.$a['cost'].'</TD> <TD>'.$a['kwh'].'</TD> <TD>'.$a['carbon'].'</TD> <TD>'.$a['classification'].'</TD> <TD>'.$a['energysaving'].'</TD> <TD>'.$a['enabled'].'</TD> </TR>'; }; print("</TABLE>"); } else { print("No results to display"); }; //This counts the number or results - and if there wasn't any it gives them a little message explaining that { echo ""; } ?> I'm very sure I have the database connection correct but it just doesn't seem to display any results. Thank you for your replies in advance. Michael
  6. Hi all, I have left it as an attachment, and instruction manual for download: http://phpexpertsystem.com/instructions.doc Thanks MCHL [attachment deleted by admin]
  7. Hello everyone I finished my project in May and I graduated with a 1st class Degree in BSc Computing. Woohoo Now I'm back for my MSc. Thank you to everyone who contributed especially MCHL! I remember reading that someone wanted a tutorial to be made out of this on how to use CSV files to display information in an expert system manner. Here it is working http://www.phpexpertsystem.com/computer/ I couldn't figure out how to "end" the decision tree properly. MCHL Let me know if you have to time to do this as I'm swamped for work :'( or I could just post up the code? Best regards Michael PS thank you very much! Much appreciated!
  8. Thank you for your reply but my problem with that approach is that it kinda distorts the way it looks in the textarea, one line might have more text then the other and it condenses and makes it hard to work out with column belongs to which. Is there such thing as making columns in a textarea ? thank you
  9. Hi there again I'm back I hope everyone is ok! Ok I last said that I wanted to use sessions to track answers but I think I want to put that on the back burner for a minuite as I think I need to implement something more important. Remember we talked about editing a CSV file and then just up load it ? Trouble is that it requires ftp log in which is kinda of a hassle. With suggestion from my tutor I am now going to use a web interface that will be able to add delete edit values. For now I am stuck. File form.php <?php $file = fopen("questions.csv", "r"); while ($data = fgetcsv($file, 1000)) { $questions[]= $data; } fclose($file); ?> <form action="save.php" method="post"> <p><br> Line no. <input type="text" value="<?php echo $questions[0][1]; ?>" size="15" name="save" /> <p> Questions <input type="text" value="<?php echo $questions[0][2]; ?>" size="15" name="save" /> <p> Answer 1 <input type="text" value="<?php echo $questions[0][3]; ?>" size="15" name="save" /> </p> <p>Answer 1 Line no. <input type="text" value="<?php echo $questions[0][4]; ?>" size="15" name="save" /> </p> <p>Answer 2 <input type="text" value="<?php echo $questions[0][5]; ?>" size="15" name="save" /> </p> <p>Answer 2 Line no. <input type="text" value="<?php echo $questions[0][6]; ?>" size="15" name="save" /> </p> <p> <input name="SUBMIT" type="SUBMIT" value="Edit File" /> <input name="RESET" type="RESET" /> </p> </p> </FORM> The above echos a form of the data values in textfield from a csv file. When a user edits the file all s/he does is clicks edit which should re edit the csv file. File save.php for now I have <?php $file = fopen("questions.csv", "w"); while ($data = fgetcsv($file, 1000)) { $questions[]= $data; } fwrite($file, $_POST['save']); fclose($file); header('Location: http://127.0.0.1/Tree/phptextedit/form.php'); ?> I know that is incorrect because it wipes out the whole csv file and replaces it with only one of the edit values from the form. ie its not editing properly. What is confusing me is when we do "$questions[]= $data;" this is all loaded into memory but how would do it so that a file knows whats whats ? How does a fa CSV file know [ 0][1] is ? I was thinking of doing something along the lines of if ($questions[0][1] == $_GET['save']) && ***** [0][1] of CSV file ***** { fwrite($file, $_GET['save']); ***** [ 0][1] of CSV file ***** thats where I have a problem ? First of all can such a thing be done ? Is this the right step ? I appreciate if someone could guide me as Im not interested in direct answers. Thank you again.
  10. thank you mchl, let me see what i can cough up. Might be a while thanks again !
  11. lol try it on other body parts. Its an exellent example cause your even able to correct previous questions and then go down a different tree path. Where should i be looking to just display all previous questions ?
  12. Thats greate !! This is what I'd live to accomplish This is an example on the NHS website http://www.selfhelpguide.nhs.uk/help/bodykey/questions/index.aspx?nodes=FlgWPcj%2f1Ow%3d Is it possible to dispall ALL previous questions and answers to it ? Where should I start looking ? Thank you
  13. Hi there everyone. I finished my exams and now concentrating on this project ready for hand in on 1st May. I been thinking that I would like to display the previous question but I have a feeling that I will need some ajax component, this will be slightly more difficult. Is there any other easier way to do this considering the time I have left ? I can't see it happening without the use of ajax. Could anyone confirm please. http://minhtri-nguyen.com/tree.php http://minhtri-nguyen.com/questions.csv
  14. Thats great, so yeah.....it works. Now thats been done I've practically finished 80% of the project (software wise) and only completed 20% of written work. I just gotta touch up on extra stuff like formating the html, thinking of a good way to display an answer either to produce a new page or just simply echo the answers underneath..not sure if thats gonna be neat with the radio buttons etc. Now I just got to do my project write up. Massive weight of my shoulders now. I've been thinking of the sessions.......this I would like to implement as collecting information would be useful to a non programmer that might use this script for their own exper system. I'll be around to update
  15. http://minhtri-nguyen.com/tree.php this not working ? fine on my end, can anyone else confirm please ?
  16. Hello everyone, i think i've cracked it for now The script is able to go to any questions that is in the CSV file or text file http://minhtri-nguyen.com/tree.php http://minhtri-nguyen.com/questions.csv I've also uploaded the CSV file to you can see what is going on The CSV is a load of nonsense because I just wanted to test. Script needs to be improved so watch this space......... Comment are appreciated
  17. it only takes one person to report you for spam and you'll start having trouble with your host and website however reliable the website is. you should use subscription based software such as aweber as they require the the person to opt into your email list so its impossible for anyone to report spam legitimtely as they "opt in" downside is you gotta pay a monthly fee upside is you have greater control of your email campaign as well as being legit. if aweber is not an option for you then I'd advise that you MUST have your readers opt in your list (by confirming their email address by clicking the link in the email address) and also have an unsubscribe link for all emails. you'll be alright for sending the set of emails to notify your readers that they must opt in to your newsletter. I think theres a script that can do this called phplist.com.... not sure
  18. No worries mate, your work comes first ! Thanks again for support ! Have a good christmas !
  19. hi mchl i'm going to pm you what ive done as i dont want to post my code just yet for google indexing reasons I progressed quite abit i believe
  20. Hello there again. Been so busy with baby etc, loss alot of sleep grrr I've been playing around with the script and your right, how come it doesn't go past the second question ? even though $i is assigned the number 2 and if you select it again why does it not add 2 to it again ? I've tried to work around it by doing something like <?php if ($questions[$i][3] == $_POST['answer']){ // $i = $i + 1; //$questions[$i][3]; $i = $questions[$i][3] == an element in $questions[$i]; // trying to do something like that but I know the value in the element is just a value and not an integer ? does that make sense ? } elseif ($questions[$i][5] == $_POST['answer']){ $i = $i + 2; } ?> I would like some hints to what im doing wrong ? and again no direct answers please
  21. Hi there am abit stuck How would is how would I assign a variable based on the element in an array ? as of now i have $a = $apples[$a][3] // but does not work So what ever number is in pocket 3 will be assigned to $a. So the number in pocker 3 might be 7 so it should assign 7 to $a. Without tell me the aswer i would like some hints please Thanks in advance
  22. Thats not entirely true. I made a thread on forum and google index the thread after about a few days. The more popular the website the more the spiders crawl and at the same time updating page ranks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.