Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $dbServername = "localhost";
- $dbUsername = "username";
- $dbPassword = "password";
- $dbName = "editabletext";
- $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $query = "SELECT raceScheduleLink FROM news";
- $result = mysqli_query($conn, $query);
- if($row = mysqli_fetch_array($result)) {
- $linkArray = Array();
- while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
- $linkArray[] = $row['raceScheduleLink'];
- //print_r($linkArray);
- }
- }
- $query = "SELECT raceScheduleText FROM news";
- $result = mysqli_query($conn, $query);
- if($row = mysqli_fetch_array($result)) {
- $titleArray = Array();
- while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
- $titleArray[] = $row['raceScheduleText'];
- //print_r($titleArray);
- }
- }
- $dom = new DOMDocument('1.0');//Create new document with specified version number
- $p_text = $titleArray[0];
- $p = $dom->createElement('a', $p_text);//Create new <p> tag with text
- $domAttribute = $dom->createAttribute('id');//Create the new attribute 'id'
- $domAttribute->value = 'description';//Add value to attribute
- $p->appendChild($domAttribute);//Add the attribute to the p tag
- $p->setAttribute('href', $linkArray[0]);
- $dom->appendChild($p);//Add the p tag to document
- echo $dom->saveHTML(); //Outputs the generated source code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement