oriental_express
Members-
Posts
113 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
oriental_express's Achievements
Member (2/5)
0
Reputation
-
creating image links from database
oriental_express replied to oriental_express's topic in PHP Coding Help
Once again you have helped me solve my problem -
creating image links from database
oriental_express replied to oriental_express's topic in PHP Coding Help
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 -
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.
-
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
-
Search function does not work, please help.
oriental_express replied to oriental_express's topic in PHP Coding Help
Thank you but still no luck -
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
-
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!
-
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
-
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.