
anthony-needs-you
Members-
Posts
52 -
Joined
-
Last visited
Never
Everything posted by anthony-needs-you
-
code not pulling results out
anthony-needs-you replied to anthony-needs-you's topic in PHP Coding Help
tried them, but still nothing The code displays the right number of columns and rows, just no data. . . -
can anyone see why this: <?php include ($_SERVER['DOCUMENT_ROOT'].'/admin/library/config.php'); include ($_SERVER['DOCUMENT_ROOT'].'/admin/library/opendb.php'); ?> <table cellspacing="3" cellpadding="3"> <?php $query = "SELECT id, vImage, vName, vDesc, vPrice FROM vehicles WHERE vCategory = 'lease' ORDER BY id"; $result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error()); if(mysql_num_rows($result)==0) { echo(' <span class="noVehicles"><strong>No Vehicles Listed</strong></span> '); } while(list($id, $vName, $vDesc, $vPrice, $vImage) = mysql_fetch_array($result)) { if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 2; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo '<td><div class="stocklisting-row"> <div class="stockphoto"><img src="vehicles/<?php echo $vImage;?>" width="125" /></div> <div class="stocktext"> <div class="stockname"><?php echo $vName;?></div> <div class="stockdesc"><?php echo $vDesc;?></div> <div class="stockprice">£<?php echo $vPrice;?> a month</div> <div class="stockmore"><a href="specification.php?id=<?php echo $id;?>">view details</a></div> </div> </div></td>'; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i < $max_columns) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; } } ?> </tr> </table> <?php include ($_SERVER['DOCUMENT_ROOT'].'/admin/library/closedb.php'); ?> doesnt pull the results in this area: echo '<td><div class="stocklisting-row"> <div class="stockphoto"><img src="vehicles/<?php echo $vImage;?>" width="125" /></div> <div class="stocktext"> <div class="stockname"><?php echo $vName;?></div> <div class="stockdesc"><?php echo $vDesc;?></div> <div class="stockprice">£<?php echo $vPrice;?> a month</div> <div class="stockmore"><a href="specification.php?id=<?php echo $id;?>">view details</a></div> </div> </div></td>'; it displays the correct rows just with empty values? I think this part maybe wrong: while(list($id, $vName, $vDesc, $vPrice, $vImage) = mysql_fetch_array($result))
-
cool cheers
-
Hi i'm currently using this to set 1 column of results: <?php //check if the starting row variable was passed in the URL or not if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) { //we give the value of the starting row to 0 because nothing was found in URL $startrow = 0; //otherwise we take the value from the URL } else { $startrow = (int)$_GET['startrow']; } $query = "SELECT id, vName, vDesc, vPrice, vImage FROM vehicles ORDER BY id DESC LIMIT $startrow, 5"; $result = mysql_query($query) or die('Error : ' . mysql_error()); if(mysql_num_rows($result)==0) { echo(' <span class="noVehicles"><strong>No Vehicles Listed</strong></span> '); } while(list($id, $vName, $vDesc, $vPrice, $vImage) = mysql_fetch_array($result, MYSQL_NUM)) { ?> <div class="stocklisting"> <div class="stockphoto"><img src="pics/<?php echo $vImage;?>" width="125" /></div> <div class="stocktext"> <div class="stockname"><?php echo $vName;?></div> <div class="stockdesc"><?php echo $vDesc;?></div> <div class="stockprice">£<?php echo $vPrice;?> a month</div> <div class="stockmore"><a href="specification.php?id=<?php echo $id;?>">view details</a></div> </div> </div> <?php } ?> I now need to change this to a 2 column layout. I have found this script: <?php $dataTest = array('a','b','c','d','e','f','g'); $table = '<table>'; $counter = 0; // find total number of items in array. If it's not an even number // we need to add 1 so as to avoid breaking the table by // omitting the final cell $total = count($dataTest); if ($total%2 != 0) { $total+=1; } // loop through the array for ($i=0;$i<count($dataTest);$i++) { if ($counter%2 == 0) { // first column $table .= '<tr><td>' . $dataTest[$i] . '</td>'; } else { // second column $table .= '<td>' . $dataTest[$i] . '</td></tr>'; } $counter++; } // complete table and output results $table .= '</table>'; echo $table; ?> Does anyone know how to tie the two together? many thanks for any help
-
does anyone know how i would attach an attachment to this email script?
-
How do i create an email attachment using this script <?php error_reporting(E_NOTICE); function valid_email($str) { return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; } if($_POST['name']!='' && $_POST['telephone']!='' && $_POST['e_mail']!='' && $_POST['county']!='' && valid_email($_POST['e_mail'])==TRUE && strlen($_POST['message'])>5) { $to = '[email protected]'; $headers = 'From: '.$_POST['e_mail'].''. "\r\n" . 'Reply-To: '.$_POST['e_mail'].'' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $subject = "Website Enquiry - contact page"; $name = "Name: " . $_POST["name"] . "\r\n"; $telephone = "Telephone: " . $_POST["telephone"] . "\r\n"; $county = "County: " . $_POST["county"] . "\r\n"; $repair = "Repair: " . $_POST["repair"] . "\r\n"; $enquiry = "Message: " . $_POST["message"] . "\r\n"; $body = "$name\n $telephone\n $repair\n $county\n $enquiry\n"; //$message = htmlspecialchars($_POST['message'] && $_POST['first_name'] && $_POST['last_name']); if(mail($to, $subject, $body, $headers)) {//we show the good guy only in one case and the bad one for the rest. echo '<div class="success-msg">Thank you '.$_POST['name'].'. Your message was sent</div>'; } else { echo '<div class="error-msg">Message not sent. Please make sure you\'re not running this on localhost and also that you are allowed to run mail() function from your webserver</div>'; } } else { echo '<div class="error-msg">Please make sure you filled all the required fields, that you entered a valid email and also that your message contains more then 5 characters.</div>'; } ?> this is the html upload <input name="photo" id="photo" size="30" type="file" class="fileUpload" /> Any help is appreciated
-
the problem i'm getting with that is if you type in a destination and leave the other fields to any it will pull all of the holidays from the table and not just the destination do you know why?
-
if i leave the destination field blank the any's will pull all of the holidays
-
hi everyone, i have a search with ranges its working fine except for the 'any ...' fields here is the html <span class="search-subhed">Holiday Type?</span><br /> <select name="breakType" class="field"> <option selected="selected">-- please select --</option> <option value="holidaybreaks">Holiday Breaks</option> <option value="cruises">Cruises</option> <option value="citybreaks">City Breaks</option> <option value="sporting">Sporting Holidays</option> <option value="flights">Flights</option> <option value="hotel">Hotel Bookings</option> </select><br /> <span class="search-subhed">Destination?</span><br /> <input name="where" type="text" value="" class="field" /><br /> <span class="search-subhed">Price?</span><br /> <select name="pricerange" class="field"> <option value="0:10000" selected="selected">Any price</option> <option value="0:500">£0-£500</option> <option value="501:1000">£501-£1000</option> <option value="1001:2000">£1001-£2000</option> <option value="2000:10000">Over £2000</option> </select><br /> <span class="search-subhed">Duration?</span><br /> <select name="stay" class="field"> <option value="1:42" selected="selected">Any duration</option> <option value="1:1">1 night</option> <option value="2:2">2 nights</option> <option value="3:3">3 nights</option> <option value="4:4">4 nights</option> <option value="5:5">5 nights</option> <option value="6:6">6 nights</option> <option value="7:7">7 nights</option> <option value="8:8">8 nights</option> <option value="9:9">9 nights</option> <option value="10:10">10 nights</option> <option value="12:12">12 nights</option> <option value="14:14">14 nights</option> <option value="21:21">21 nights</option> <option value="21:42">Over 21 nights</option> </select><br /> <input name="search" type="submit" id="search" value="Search" /> and here is part of the php if($breakType == 'holidaybreaks') { list($min,$max) = explode(':',$_POST['pricerange'],2); list($minstay,$maxstay) = explode(':',$_POST['stay'],2); $result = mysql_query("SELECT departureDate, expireDate, airport, destination, resort, hotel, duration, board, price, description, customerRef, mystiqueRef, stars FROM holiday WHERE duration BETWEEN '$minstay' AND '$maxstay' AND price BETWEEN '$min' AND '$max' AND destination LIKE '%$where%'"); When 'any price' or 'any duration' is selected with a destination it shows no results?
-
Hi i have some sort by buttons: <form method="POST" action="<?php echo($_SERVER['PHP_SELF']); ?>"> <input name="resort" value="resort" type="image" onMouseOver="this.src='elements/images/layout/r-resort-active.gif'" onMouseOut="this.src='elements/images/layout/r-resort-inactive.gif'" src="elements/images/layout/r-resort-inactive.gif" class="button" border"0"> </form> This is the code it posts to: if(isset($_POST['authorDate'])){ $authorDate=$_POST['authorDate']; $type="authorDate"; }elseif(isset($_POST['hotel'])){ $hotel=$_POST['hotel']; $type="hotel"; }elseif(isset($_POST['destination'])){ $destination=$_POST['destination']; $type="destination"; }elseif(isset($_POST['resort'])){ $resort=$_POST['resort']; $type="resort"; }elseif(!isset($_POST[''])){ $type="hotel"; } and this is the part of the code it sorts via $type: $query = "SELECT id, destination, author, resort, hotel, authorDate, description, stars FROM reviews ORDER BY $type LIMIT $startrow, 10"; It works in firefox but not in IE does anyone know why?
-
you star, thanks
-
Hi everyone, i am trying to create a search fuction with a price range. The html for the price range is: <select name="pricerange" class="field"> <option selected="selected">any price</option> <option value="0:100">£0 - £100</option> <option value="101:300">£101 - £300</option> <option value="301:500">£301 - £500</option> </select> and the php is list($min,$max) = explode(':',$_POST['pricerange'],2); $result = mysql_query("SELECT departureDate, expireDate, airport, destination, resort, hotel, duration, board, price, description, customerRef, mystiqueRef, stars FROM holiday WHERE destination LIKE '%$where%' AND duration LIKE '%$stay%' AND price BETWEEN '%$min' AND '%$max'"); The price range is not working?
-
[SOLVED] searching for multiple keywords
anthony-needs-you replied to anthony-needs-you's topic in PHP Coding Help
Thanks works perfectly -
Hi i have two bits of code. On their own they work fine. How would i put them together? $result = mysql_query("SELECT departureDate, expireDate, airport, destination, resort, hotel, duration, board, price, description, customerRef, mystiqueRef, stars FROM holiday WHERE destination LIKE '%$where%'");[code] $result = mysql_query("SELECT departureDate, expireDate, airport, destination, resort, hotel, duration, board, price, description, customerRef, mystiqueRef, stars FROM holiday WHERE duration LIKE '%$stay%'");[/code]
-
cool cheers i will play around with this thanks all
-
Hi i was hoping that someone maybe able to tell me how to code a price range drop down search menu. I am unsure as to what to enter as the option value: <span class="search-subhed">Where?</span><br /> <input name="where" type="text" value="Enter keywords / Hotel Name" class="field" /><br /> <span class="search-subhed">Price?</span><br /> <select name="price" class="field"> <option selected="selected">any price</option> <option>£0 - £100</option> <option>£101 - £300</option> <option>£301 - £500</option> </select><br /> <span class="search-subhed">Duration?</span><br /> <select name="duration" class="field"> <option selected="selected">any duration</option> <option value="1">1 night</option> <option value="2">2 nights</option> <option value="5">5 nights</option> <option value="6">6 nights</option> <option value="7">7 nights</option> <option value="10">10 nights</option> <option value="14">14 nights</option> </select> here is the php i am planning to use: select * from holiday where price between 0 and 100
-
Thanks for the tip i will read up on this
-
Hi i insert my dates from a calander into my mysql database with this: $expireDate = date("Y-m-d", strtotime($_POST['expireDate'])); The client wants it displayed in the input box before being inserted in uk format d-m-Y. If i do this using the above code the database doesnt understand it. I can display it after inserting it but how do i display it in the uk format before insert?
-
it doesnt show an error. Does it look correct? Its to be used to display results based on a reference number being searched (customerRef). Although say a do a search for a reference number I know that is in the test table it just displays nothing, same vice verser
-
no it just doesnt show any search results. When i search without the join its fine?
-
Does anyone know why this table join doesnt work $result = mysql_query(" SELECT t.departureDate, t.expireDate, t.airport, t.destination, t.resort, t.hotel, t.duration, t.board, t.price, t.description, t.customerRef, t.mystiqueRef, t.stars, c.departureDate, c.expireDate, c.airport, c.destination, c.resort, c.hotel, c.duration, c.board, c.price, c.description, c.customerRef, c.mystiqueRef, c.stars FROM test AS t LEFT JOIN cyprus AS c ON t.customerRef = c.customerRef WHERE c.customerRef OR t.customerRef LIKE '%$search%'") or die(mysql_error()); When i search one table it with this its ok $result = mysql_query("SELECT departureDate, expireDate, airport, destination, resort, hotel, duration, board, price, description, customerRef, mystiqueRef, stars FROM test WHERE customerRef LIKE '%$search%'"); but with the join the search shows no results?
-
searching multiple tables in database
anthony-needs-you replied to anthony-needs-you's topic in PHP Coding Help
this is the code as is $result = mysql_query(" SELECT t.departureDate, t.expireDate, t.airport, t.destination, t.resort, t.hotel, t.duration, t.board, t.price, t.description, t.customerRef, t.mystiqueRef, t.stars, c.departureDate, c.expireDate, c.airport, c.destination, c.resort, c.hotel, c.duration, c.board, c.price, c.description, c.customerRef, c.mystiqueRef, c.stars FROM test AS t LEFT JOIN cyprus AS c ON t.customerRef = c.customerRef WHERE c.customerRef LIKE '%$search%'") or die(mysql_error()); if i take out the LIKE clause, it does show a syntax error Both test table and cyprus table both have customerRef, although the inputed values are different -
searching multiple tables in database
anthony-needs-you replied to anthony-needs-you's topic in PHP Coding Help
its still showing no results, could it be the way its displayed? echo " <h3 class=\"hol-subhed\">$destination</h3> <div id=\"hol-wrapper\"> <div class=\"holiday-hedlistwrap\"> <ul class=\"hol-hedlist\"> <li class=\"long\">Destination</li> <li class=\"med\">Airport</li> <li class=\"long\">Resort</li> <li class=\"long\">Hotel</li> <li class=\"med\">Board</li> <li class=\"med\">Duration</li> <li class=\"med\">Depart On</li> <li class=\"small\">Price</li> </ul> </div> <div class=\"holiday-detailswrap\"> <ul class=\"hol-details\"> <li class=\"long\">$destination</li> <li class=\"med\">$airport</li> <li class=\"long\">$resort</li> <li class=\"long\">$hotel</li> <li class=\"med\">$board</li> <li class=\"med\">$duration</li> <li class=\"med\">$departureDate</li> <li class=\"small\">£$price</li> </ul> <div class=\"clearboth\" id=\"foo\"><!--empty--></div> </div> <div class=\"holiday-descwrap\"> <ul class=\"hol-hedlist\"> <li class=\"huge\">Description</li> <li class=\"med\">Rating</li> <li class=\"med\">Ref. No.</li> </ul> </div> <div class=\"holiday-detailswrap\"> <ul class=\"hol-details\"> <li class=\"huge\">$description</li> <li class=\"med\"> $stars</li> <li class=\"ref\">$customerRef</li> </ul> <div class=\"clearboth\" id=\"foo\"><!--empty--></div> </div> <div class=\"holiday-descwrap\"> <ul class=\"hol-hedlist\"> <li class=\"huge\">Operator Ref</li> <li class=\"med\"></li> <li class=\"med\"></li> </ul> </div> <div class=\"holiday-detailswrap\"> <ul class=\"hol-details\"> <li class=\"huge\">$mystiqueRef</li> <li class=\"med\"></li> <li class=\"ref\"></li> </ul> <!--hol-footer--> <div class=\"clearboth\" id=\"foo\"><!--empty--></div> </div> "; } -
searching multiple tables in database
anthony-needs-you replied to anthony-needs-you's topic in PHP Coding Help
would i also have to change these? while($r=mysql_fetch_array($result)) { $airport=$r["airport"]; $destination=$r["destination"]; $resort=$r["resort"]; $hotel=$r["hotel"]; $duration=$r["duration"]; $price=$r["price"]; $description=$r["description"]; $customerRef=$r["customerRef"]; $mystiqueRef=$r["mystiqueRef"]; $stars=$r["stars"]; $expireDate=$r["expireDate"]; $board=$r["board"];